Commit Graph

136 Commits

Author SHA1 Message Date
Dario Russo 1ba3525816 Fix mistakes in spelling and grammar 2016-12-21 17:47:57 +01:00
Emmanuel Gil Peyrot 89837523b5 wayland: destroy input before closing the display connection.
Fixes a segfault introduced in libwayland
e8ad23266f36521215dcd7cfcc524e0ef67d66dd, where a poison value has been
introduced to catch this kind of use-after-free bug.
2016-11-27 02:01:14 +00:00
wm4 4d75514321 vo: change messy handling of fullscreen and other flags
Before this commit, all VOs had to toggle the option flag themselves,
now command.c does it.

I can't really comprehend why it required every VO to do this manually.
Maybe it was for rejecting the property/option change if the VO didn't
support a specific capability. But then it could have checked the VOCTRL
result. In any case, I don't care, and successfully changing the
property without doing anything (With some VOs) is fine too. Many things
work this way now, and it's simpler overall.

This change will be useful for cleaning up VO option handling.
2016-08-30 23:52:16 +02:00
Rostislav Pehlivanov cb2cb540f4 wayland: reject resize events with either dimension being 0
Newer versions of mutter/gnome now ask mpv to resize to 0 by 0 pixels.
2016-08-29 13:21:54 +01:00
wm4 37d6604d70 x11, wayland: always round up wait times
If wait_us is >0 and <500, the wait time gets rounded down 0,
effectively turning this into busy waiting. Round it up instead.
2016-08-26 20:22:33 +02:00
Rostislav Pehlivanov dea738a245 wayland_common: check for NULL current_output on fs switching
Prevents segfaults when a fullscreen switch is issued before fully
initializing the VO.
Doesn't change anything since the schedule_resize is only there to
resize in case the image size switches, which happens long after init.
2016-08-01 22:16:40 +02:00
Rostislav Pehlivanov 08a4af5e6e wayland_common: provide the real scaled window resolution
It makes more sense to completely abstract this scaling inside the
backend so that internally the player only works with real actual
drawn pixels.
2016-08-01 00:31:34 +02:00
Rostislav Pehlivanov 45687c17f7 wayland_common: fix fullscreen image switching bug
The problem was that when in fullscreen, switching between images did
not issue a resize event, causing none of the images to be rendered
correctly.
This fixes the problem by issuing a resize event with the screen width
and height.
This commit also moves the zeroing of the events field to when it gets
retrieved by mpv rather than randomly after a resize in the vo/backend
code.
2016-07-30 15:33:00 +02:00
Rostislav Pehlivanov 2f986a5980 wayland_common: prevent black bars on most non-native aspect ratios
ssurface_handle_configure()'s width and height are just hints given by
the compositor, the application's free to not respect those strictly and
to compensate for e.g. aspect ratio.
This prevents crazy scenarios in which pictures with portrait aspect
ratios have a huge black area to make them 16:9 or whatever the
compositor feels like.
2016-07-30 15:32:57 +02:00
Rostislav Pehlivanov 3fe5ff99c6 wayland_common: clip window size to the display output size
With X11 it was usually left up to the window manager to prevent huge
windows from being out of range, but no Wayland compositor will do
this right now.

Hugely improves usability when using mpv as an image viewer.
2016-07-30 00:02:40 +02:00
Rostislav Pehlivanov f918ec4b2b wayland_common: flush wakeup_pipe on a wakeup
Missed during the recent changes.
Also simplify error checking code and check for POLLNVAL
as well (the display fd was never actually checked to be valid).
2016-07-30 00:02:39 +02:00
Rostislav Pehlivanov f3f4e048d8 wayland_common: remove untested/unusable wayland dnd code
Not worth keeping 200 lines of untestable as of today code which might
be broken, if it hasn't been already.
2016-07-30 00:02:39 +02:00
wm4 16d276308a x11, wayland: do not accidentally close FD 0
Both backends have code to close each FD of their wakeup_pipe array.
This array is default-initialized with 0, which means if the backends
exit before the wakeup pipe is created (e.g. when probing), they would
close FD 0.

Initialize the FDs with -1. Then we call close(-1) in these situations,
which is perfectly allowed and has no bad consequences.
2016-07-21 15:18:32 +02:00
Rostislav Pehlivanov c6b83fec7d wayland_common: make function declaration consistent
Half the code had a space before the arguments and half didn't.
2016-07-21 14:45:40 +02:00
Rostislav Pehlivanov c0ef3cf9c2 wayland: port to the new wakeup/wait_events framework
This fits natively into the vo/backend and allows to simplify the
polling code.
One new change is the fact that surface_handle_enter flags VO_EVENT_WIN_STATE
and VO_EVENT_RESIZE instead of only VO_EVENT_WIN_STATE. Before this, the code
hackily relied on the timeout and the loop in the wait_frame function to track
and set the scaling factor. Instead, this triggers mpv to run a schedule_resize
and adjust the new VO output dimensions immediately. This is also more accurate
since surface_handle_enter() gets called when a surface is created, moved and
resized, which is exactly what the rest of the player might be interested in.
2016-07-21 14:45:38 +02:00
Rostislav Pehlivanov e11a20a812 vo_wayland: fix high CPU usage due to busy polling
There's no need to call wl_display_flush() since all the client-side
buffered data has already been flushed prior to polling the fd.
Instead only check for POLLIN and the usual ERR+HUP.
2016-07-19 10:01:51 +02:00
Rostislav Pehlivanov e44882d792 wayland: mark existing dnd entry print as debug rather than an error
It gets printed on every alt+tab or desktop switch under mutter and
weston, and offers no useful information since it's handled by
destroying the previous entry.

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2016-05-31 11:22:57 +02:00
Rostislav Pehlivanov 29ea6e5e4a wayland: correctly report display refresh rate
This commit will cause the wayland backend and vo to correctly report
the display frame rate. This didn't work as VOCTRL_GET_DISPLAY_FPS was
received way too early, before the window was created (and thus
current_output set).

The VO will now signal VO_EVENT_WIN_STATE after window initialization
and upon a resize.

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2016-05-31 11:22:55 +02:00
Rostislav Pehlivanov 098ff4174c wayland: implement HIDPI support
The wayland protocol exposes scaling done by the compositor to
compensate for small window sizes on small high DPI displays. If the
program ignores the scaling done, what'll happen is the compositor is
going to ask the program to be scaled down by N times the window size and
then it'll upscale the program's surface by N times. The scaling
algorithm seems to be bilinear so the scaling is quite obvious.

This commit sets up callbacks to listen for the scaling factor of each
output and, on rescale events, notifies the compositor that the
surface's scale is what the compositor asked for and changes the
player's surface to the appropriate size, causing no scaling to be done
by the compositor.

Compositors not supporting this interface will ignore the callbacks and do
nothing, keeping program behaviour the same. For compositors supporting
and using this interface (mutter), this will fix the rendering to be pixel
precise as it should be.

Both the opengl wayland backend and the wayland vo have been fixed to support
this. Verified to not break either on weston and mutter.

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2016-05-30 20:17:26 +02:00
Emmanuel Gil Peyrot f99e48ae6a wayland: use the advertised size in fullscreen
When we receive the wl_shell_surface::configure event, it makes sense
to respect the aspect ratio of the video in windowed mode, but in
fullscreen it forces compositing and wastes resources (until atomic
modesetting is available everywhere and we can stop having
desynchronised planes).

Weston mitigates a resolution mismatch by creating black surfaces and
compositing them around the fullscreen surface, placed at the middle,
while GNOME puts it at the top-left and leaves the rest of the desktop
composited below, both of them producing a subpar experience.

Fixes #3021, #2657.
2016-05-08 19:47:08 +02:00
Emmanuel Gil Peyrot f0ba2a54e6 Revert "wayland: set fs mode on every configure"
Prevents an infinite loop of configure event and set_fullscreen
request on Weston and other compositors respecting the protocol.

Fixes #2817

This reverts commit eb6b2b6e50.
2016-03-19 14:09:13 +01:00
Alexander Preisinger eb6b2b6e50 wayland: set fs mode on every configure
Check and set the fullscreen mode on every surface configure event.
This prevents gnome from resizing mpvs fullscreen window to a smaller size.
2016-02-07 15:44:54 +01:00
wm4 8a9b64329c Relicense some non-MPlayer source files to LGPL 2.1 or later
This covers source files which were added in mplayer2 and mpv times
only, and where all code is covered by LGPL relicensing agreements.

There are probably more files to which this applies, but I'm being
conservative here.

A file named ao_sdl.c exists in MPlayer too, but the mpv one is a
complete rewrite, and was added some time after the original ao_sdl.c
was removed. The same applies to vo_sdl.c, for which the SDL2 API is
radically different in addition (MPlayer supports SDL 1.2 only).

common.c contains only code written by me. But common.h is a strange
case: although it originally was named mp_common.h and exists in MPlayer
too, by now it contains only definitions written by uau and me. The
exceptions are the CONTROL_ defines - thus not changing the license of
common.h yet.

codec_tags.c contained once large tables generated from MPlayer's
codecs.conf, but all of these tables were removed.

From demux_playlist.c I'm removing a code fragment from someone who was
not asked; this probably could be done later (see commit 15dccc37).

misc.c is a bit complicated to reason about (it was split off mplayer.c
and thus contains random functions out of this file), but actually all
functions have been added post-MPlayer. Except get_relative_time(),
which was written by uau, but looks similar to 3 different versions of
something similar in each of the Unix/win32/OSX timer source files. I'm
not sure what that means in regards to copyright, so I've just moved it
into another still-GPL source file for now.

screenshot.c once had some minor parts of MPlayer's vf_screenshot.c, but
they're all gone.
2016-01-19 18:36:06 +01:00
Dmitrij D. Czarkoff ea442fa047 mpv_talloc.h: rename from talloc.h
This change helps avoiding conflict with talloc.h from libtalloc.
2016-01-11 21:05:55 +01:00
Alessandro Ghedini 1f62f38106 wayland: fix typo in error message 2015-12-27 19:20:59 +01:00
Ricardo Vieira 251107076b Revert "vo_wayland: define opaque region"
This reverts commit c10fb4ce9f.

This is already done in vo_wayland.c:resize,324 doing it here makes the window bigger before the video resizes showing a black area while dragging the border.
2015-10-20 00:15:07 +02:00
wm4 bd87598af9 vo_opengl: wayland: switch to new internal API 2015-10-01 22:57:02 +02:00
Kevin Mitchell c80b7eed53 input: add append argument to file drop event
This puts in place the machinery to merely append dropped file to the playlist
instead of replacing the existing playlist. In this commit, all front-ends
set this to false preserving the existing behaviour.
2015-08-30 05:28:24 -07:00
Jari Vetoniemi e05dc7bfb7 vo_wayland: Wait for frame callbacks
Privdes small api for vo_wayland where one can request frame callback
and then wait for it.

This will make vo_wayland play video smoothly.
2015-08-21 00:01:01 +02:00
Jari Vetoniemi c10fb4ce9f vo_wayland: define opaque region
This allows compositor to optimize rendering, as it will know mpv is not
transparent.
2015-03-23 21:53:32 +01:00
Jari Vetoniemi 3714430cdf vo_wayland: share frame callbacks.
Define frame callback logic in wayland_common.c
As this should be used by opengl renderer as well.

Preferably drawing should be skipped entierly when no frame callbacks
are received. However, for now only swap buffers is skipped.
2015-03-23 21:53:32 +01:00
wm4 445b3fbf82 buid: readd -Wparentheses
This warning wasn't overly helpful in the past, and warned against
perfectly fine code. But at least with recent gcc versions, this is the
warning that complains about assignments in if expressions (why???), so
we want to enable it.

Also change all the code this warning complains about for no reason.
2015-03-02 19:09:25 +01:00
torque 3b269ac0a0 input: add MOUSE_ENTER keybinding.
Signed-off-by: wm4 <wm4@nowhere>
2015-02-18 00:03:16 +01:00
wm4 fc524e8a07 command: unify handling of fullscreen and other VO flags
The "ontop" and "border" properties already used a common
mp_property_vo_flag() function, and the corresponding VOCTRLs used the
same conventions. "fullscreen" is pretty similar, but was handled
slightly similar. Change how VOCTRL_FULLSCREEN behaves, and use the same
helper function for "fullscreen" as the other flags.
2015-01-16 23:07:13 +01:00
wm4 460ef9c7a4 wayland: implement key modifiers
Includes shift, ctrl, alt, meta.
2015-01-12 16:41:00 +01:00
wm4 10532b99e5 wayland: don't compute absurd window size
For some reason, schedule_resize() can be called with everything set to
0. The code couldn't handle wl->window.aspect set to 0, converting NaNs
to integers. Just work this around.

(I have no idea what I'm doing. This is probably a corner case caused
by my broken-ish wayland setup.)
2015-01-12 15:21:26 +01:00
Sergey Kvachonok 01717dcd2c vo_wayland: Add "multimedia" keyboard key bindings.
libxkbcommon keysyms are the same as X11 keysyms (sans prefix),
so I simply copied the missing subsection from x11_common.c.

Signed-off-by: Sergey Kvachonok <ravenexp@gmail.com>
Signed-off-by: wm4 <wm4@nowhere>
2014-11-29 19:13:47 +01:00
Alexander Preisinger 29467736cf wayland: use reported rete and delay
If native-keyrepeat is true then we set the rate and delay reported by the
compositor.
2014-09-19 17:38:24 +02:00
Alexander Preisinger 369868e404 wayland_common: fix changing videos when fullscreen
I broke it again.
2014-09-10 19:21:52 +02:00
wm4 e267ff93f3 video: rename VOCTRL_GET_WINDOW_SIZE
Make it clear that this accesses the un-fullscreened window size.
2014-09-05 01:52:16 +02:00
Alexander Preisinger fc68c9269d wayland: print some useful outptu info
Prints output informations, useful for finding out if we detect the right mode
and for debugging.
2014-09-03 21:35:26 +02:00
Alexander Preisinger 8bd5df3ac1 wayland: only save current mode of outputs
Other ones are not needed.
2014-09-03 21:35:26 +02:00
wm4 68ff8a0484 Move compat/ and bstr/ directory contents somewhere else
bstr.c doesn't really deserve its own directory, and compat had just
a few files, most of which may as well be in osdep. There isn't really
any justification for these extra directories, so get rid of them.

The compat/libav.h was empty - just delete it. We changed our approach
to API compatibility, and will likely not need it anymore.
2014-08-29 12:31:52 +02:00
Alexander Preisinger 614ff883bc wayland: replace deprecated xkbcommon functions
Available and stable since forever (xkbcommon 0.2).
2014-08-20 17:16:18 +02:00
Alexander Preisinger 752dce9284 wayland: dynamically report display fps
Only reports the most recently entered output if the window is displayed on
2 or more outputs. Should be changed to the lowest fps of all outputs the
window is visible. Until no one complains this will have to wait.

Look for the VO framedropping for more information on this topic.
2014-08-18 22:00:39 +02:00
Alexander Preisinger 69a160f187 wayland: pointer interface is created after theme
Just always load the theme. It gets freed properly and dosn't bother anyone.

Fixes #1012.

CC: @mpv-player/stable
2014-08-13 22:34:18 +02:00
Alexander Preisinger 6ec39b4641 wayland: remove redundant line 2014-08-06 12:58:39 +02:00
Alexander Preisinger f175f2c38f wayland: changes for nested compositors
Adds necessary checks for nested compositors which only have limited
interfaces. Might also be useful for other minimal compositors.
2014-08-06 12:55:51 +02:00
wm4 4c533fbb16 vo: remove vo_mouse_movement() wrapper
So that VO backends don't have to access the VO just for that.
2014-07-27 21:53:29 +02:00
Alexander Preisinger 73121dbcc1 wayland: move subsurfaces to wayland vo
Subsurfaces are only used by the wayland vo. Thats why it makes sense to move
all osd and subsurface specific parts to the vo_wayland.c

Also destroy the subsurfaces and subcompositor properly.
2014-06-15 14:46:27 +02:00