summaryrefslogtreecommitdiffstats
path: root/video/out/wayland_common.h
Commit message (Collapse)AuthorAgeFilesLines
* wayland: make resizing betterDudemanguy2020-02-131-1/+3
| | | | | | | | | Resizing the window while preserving the aspect ratio actually kind of sucked. The window size could make big dramatic changes which was pretty unintuitive with respect to where the mouse was actually located. Instead, let's just do some math to ensure that the window size is always contained inside the width/height reported by handle_toplevel_config while preserving the aspect ratio. Fixes #7426.
* wayland: toplevel config fixesDudemanguy2020-02-061-0/+2
| | | | | | | | | | | | | | | | | | | | | | | There were a couple of erroneous things in the handle_toplevel_config function. Firstly, looping through the different states was not handled correctly. Launching a window as maximized (can happen in sway for example) was always stuck on true and would never be set to false. Fix this by always checking if XDG_TOPLEVEL_STATE_MAXIMIZED is found or not. Also do a similar thing for the fullscreen state. Additionally, there were some issues with resizing windows and window-scale going back to old sizes. The root of this problem is that the width and height arguments of handle_toplevel_config aren't actually guarenteed to be the actual width and height of the surface. There are times when mpv will set the surface size on its own (like with window-scale) which will be unknown to the toplevel listener. To complicate matters, there are times when we do want to use the width and height arguments (like when resizing with the mouse). Fix this by checking if the width and height arguments reported by handle_toplevel_config changed from the previous call of the function. If the value is different, then we go ahead and use them when setting mpv's geometry. If not, then we just ignore it.
* wayland: remove wayland-frame-wait-offset optiondudemanguy2020-01-311-2/+1
| | | | | | | | | | | | | | | | | This originally existed as a hack for weston. In certain scenarios, a frame taking too long to render would cause vo_wayland_wait_frame to timeout which would result in a ton of dropped frames. The naive solution was to just to add a slight delay to the time value. If a frame took too long, it would likely to fall under the timeout value and all was well. This was exposed to the user since the default delay (1000) was completely arbitrary. However with presentation time, this doesn't appear to be neccesary. Fresh frames that take longer than the display's refresh rate (16.666 ms in most cases) behave well in Weston. In the other two main compositors without presentation time (GNOME and Plasma), they also do not experience any ill effects. It's better not to overcomplicate things, so this "feature" can be removed now.
* wayland: fix cursor behavior on an edge casedudemanguy2019-12-041-1/+0
| | | | | | | | | | | | | | | | | This small regression was introduced by #7216. Previously, the wayland backend used a trick which kept track of the previous fullscreen state and used that logic for showing the cursor. Since vo_opts now keeps track of the current fullscreen state, most of this stopped being neccessary. However, there was one edge case where the cursor didn't behave the same: passing a fullscreen flag for the inital window. The cursor would initially be visible here which is not desirable. This can be remedied pretty easily by just setting the cursor visiblity to false if the pointer entry event occurs on fullscreen. The only thing we need to do is to make sure that the autohide delay isn't completely disabled (i.e. the cursor is always visible). Hence the need for the previous commit.
* wayland: update remaining legacy VOCTRL usage to optionsPhilip Langdale2019-12-021-1/+0
| | | | | | | | | | | The remaining legacy VOCTRLs are for the fullscreen and border properties. For fullscreen this largely just replacing the private state field with the vo option but there are small semantic differences that we need to be careful of. For the border setting, it's trivial as we don't have external mechanisms for changing the state, but I also can't test it as I'm not using a compositor that supports it.
* wayland: update Maximize and Minimize handling to use new optionsPhilip Langdale2019-12-011-1/+3
| | | | | | | | | | | I wanted to get this done quickly as I introduced the new VOCTRL behaviour for minimize and maximize and it was immediately made legacy, so best to purge it before anyone gets confused. I did not sort out fullscreen as that's more involved and not something I've educated myself about yet. But I did replace the VOCTRL_FULLSCREEN usage with the new option change mechanism as that seemed simple enough.
* wayland: make the edge grab zone width user configurablePhilip Langdale2019-11-291-0/+2
| | | | | | | Rather than hard-coding the edge grab zone width, we can make it user configurable. It seems worthwhile to have separate configs for pointer and touch usage as the defaults should be different, and a user might have both input methods in use.
* wayland: add grab zone for resizing window with mousePhilip Langdale2019-11-291-0/+2
| | | | | | | | Today, we support resizing wayland windows when we detect a touch event in a defined grab zone. As part of implementing pseudo-decorations, we should have equivalent functionality for mouse input. And if we detect support for actual decorations we will not activate the grab zone as the decorations will provide this.
* wayland: fix presentation timeDudemanguy9112019-10-201-0/+2
| | | | | | | | | | There's 2 stupid things here that need to be fixed. First of all, vulkan wasn't actually using presentation time because somehow the get_vsync function in context.c disappeared. Secondly, if the mpv window was hidden it was updating the ust time based on the refresh_usec but really it should simply just not feed any information to the vsync info structure. So this adds some logic to assume whether or not a window is hidden.
* wayland: add various render-related optionsdudemanguy2019-10-201-1/+7
| | | | | The newest wayland changes have some new logic that make sense to expose to users as configurable options.
* wayland: add presentation timedudemanguy2019-10-201-1/+27
| | | | | Use ust/msc/refresh values from wayland's presentation time in mpv's ra_swapchain_fns.get_vsync for the wayland contexts.
* wayland: use callback flag + poll for buffer swapdudemanguy2019-10-101-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The old way of using wayland in mpv relied on an external renderloop for semi-accurate timings. This had multiple issues though. Display sync would break whenever the window was hidden (since the frame callback stopped being executed) which was really annoying. Also the entire external renderloop logic was kind of fragile and didn't play well with mpv's internal structure (i.e. using presentation time in that old paradigm breaks stats.lua). Basically the problem is that swap buffers blocks on wayland which is crap whenever you hide the mpv window since it looks up the entire player. So you have to make swap buffers not block, but this has a different problem. Timings will be terrible if you use the unblocked swap buffers call. Based on some discussion in #wayland, the trick here is relatively simple and works well enough for our purposes. Instead we basically build a way to block with a timeout in the wayland buffer swap functions. A bool is set in the frame callback function that indicates whether or not mpv is waiting for a frame to be displayed. In the actual buffer swap function, we enter into a while loop waiting for this flag to be set. At the same time, the wl_display is polled to block the thread and wakeup if it receives any events from the compositor. This loop only breaks if enough time has passed or if the frame callback bool is received. In the near future, it is better to set whether or not frame a frame has been displayed in the presentation feedback. However as a first pass, doing it in the frame callback is more than good enough. The "downside" is that we render frames that aren't actually shown on screen when the player is hidden (it seems like wayland people don't like that). But who cares. Accurate timings are way more important. It's probably not too hard to add that behavior back in the player though.
* wayland: don't show cursor when fullscreeningdudemanguy2019-09-211-0/+1
|
* wayland: reconfigure cursor on pointer enter eventThomas Weißschuh2019-09-211-0/+1
| | | | | | | | | | | | | | | | | | | | | On wayland the cursor has to be configured each time the pointer enters. Currently if the window (re)gains the focus, the pointer is not hidden, even when configured. After the mouse has been moved the pointer hides correctly. https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_pointer: wl_pointer::enter - enter event ... When a seat's focus enters a surface, the pointer image is undefined and a client should respond to this event by setting an appropriate pointer image with the set_cursor request. Fixes #6185. Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
* wayland_common: rename “shell” into “wm_base”Emmanuel Gil Peyrot2019-02-171-1/+1
| | | | | | | | This is the naming xdg-shell stable adopted, it doesn’t make much sense to keep using “shell” everywhere with all functions calling it “wm_base”. Finishes what 76211609e3c589dafe3ef9a36cacc06e8f56de09 started.
* wayland: remove KDE server-decoration supportemersion2018-11-191-2/+0
|
* wayland: use xdg-decoration if availableemersion2018-11-191-0/+2
|
* wayland_common: fix maximized stateRostislav Pehlivanov2018-05-201-0/+1
| | | | Window size should not change if the window has been maximized or tiled.
* wayland_common: update to stable xdg-shellEmmanuel Gil Peyrot2018-04-291-3/+3
| | | | | This removes support for older compositors using the unstable version, but those will still use Xwayland by default, so not a big loss.
* wayland_common: improve cursor code and scale cursor properlyRostislav Pehlivanov2017-10-221-0/+1
| | | | | | It seems the cursor hadn't had its position properly adjusted when scaled. Hence, bring back correct buffer scaling to make the cursor look fine. Also the cursor surface now gets created sooner so that's better.
* wayland_common: implement output tracking, cleanups and bugfixesRostislav Pehlivanov2017-10-091-13/+8
| | | | | | | | | | | | | | | | | | This commit: - Implements output tracking (e.g. monitor plug/unplug) - Creates the surface during registry (no other dependencies) - Queues the callback immediately after surface creation - Cleaner and better event handling (functions return directly) - Better reconfigure handling (resizes reduced to 1 during init) - Don't unnecessarily resize (if dimensions match) Apart from that fixes 2 potential memory leaks (mime type and window title), 2 string ownership issues (output name and make need to be dup'd), fixes some style issues (switches were indented) and finally adds messages when disabling/enabling idle inhibition. The callback setter function was removed in preparation for the commit which will use the frame event cb because it was unnecessary.
* Revert "wayland_common: add support for embedding"Rostislav Pehlivanov2017-10-051-1/+0
| | | | This reverts commit 8d8d4c5cb1b3553215a8ba547d4db463fdc88831.
* wayland_common: add support for embeddingRostislav Pehlivanov2017-10-051-0/+1
|
* wayland_common: rewrite from scratchRostislav Pehlivanov2017-10-031-107/+73
| | | | | | | | | | | | The wayland code was written more than 4 years ago when wayland wasn't even at version 1.0. This commit rewrites everything in a more modern way, switches to using the new xdg v6 shell interface which solves a lot of bugs and makes mpv tiling-friedly, adds support for drag and drop, adds support for touchscreens, adds support for KDE's server decorations protocol, and finally adds support for the new idle-inhibitor protocol. It does not yet use the frame callback as a main rendering loop driver, this will happen with a later commit.
* wayland_common: remove untested/unusable wayland dnd codeRostislav Pehlivanov2016-07-301-5/+0
| | | | | Not worth keeping 200 lines of untestable as of today code which might be broken, if it hasn't been already.
* wayland: port to the new wakeup/wait_events frameworkRostislav Pehlivanov2016-07-211-4/+3
| | | | | | | | | | | | 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.
* wayland: implement HIDPI supportRostislav Pehlivanov2016-05-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Relicense some non-MPlayer source files to LGPL 2.1 or laterwm42016-01-191-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* vo_opengl: wayland: switch to new internal APIwm42015-10-011-1/+1
|
* vo_wayland: Wait for frame callbacksJari Vetoniemi2015-08-211-0/+7
| | | | | | | 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.
* vo_wayland: share frame callbacks.Jari Vetoniemi2015-03-231-0/+5
| | | | | | | | 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.
* wayland_common: fix changing videos when fullscreenAlexander Preisinger2014-09-101-1/+0
| | | | I broke it again.
* wayland: print some useful outptu infoAlexander Preisinger2014-09-031-0/+2
| | | | | Prints output informations, useful for finding out if we detect the right mode and for debugging.
* wayland: dynamically report display fpsAlexander Preisinger2014-08-181-1/+2
| | | | | | | | 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.
* wayland: move subsurfaces to wayland voAlexander Preisinger2014-06-151-5/+0
| | | | | | | 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.
* wayland: don't use VOCTRL_UPDATE_SCREENINFOwm42014-05-061-1/+1
| | | | Not very tested. Appears to work.
* wayland/shm: Use subsurfaces for OSDAlexander Preisinger2014-04-161-1/+8
|
* wayland: fix fullscreen & resizing for goodAlexander Preisinger2014-01-071-1/+4
| | | | | | | I added enough logic to never set ontop or fullscreen twitce. This commit keeps also the size of the video if multiple videos are played. If the ratio differs the width will be kept at the same size and only the height changes.
* Revert "wayland/egl: use redraw callback"Alexander Preisinger2014-01-041-2/+0
| | | | | | | | | | | Because of this commit there were problems displaying the frmase in their right order. This reverts commit 96e75d234a4df1a09f38eaf932d00d79dccdc324. Conflicts: video/out/gl_wayland.c video/out/wayland_common.h
* wayland/egl: misc fixes and cleanupsAlexander Preisinger2014-01-041-1/+0
|
* wayland/egl: use redraw callbackAlexander Preisinger2014-01-041-0/+3
| | | | | | | This solves the issue where we would not receive any frame events. The difference to my earlier tests is that now it looks like eglSwapBuffers uses it's own event queue or something similiar along the lines. Becaues the performance is the same as without any redraw callback.
* wayland/egl: add egl_context to the wayland stateAlexander Preisinger2014-01-041-0/+20
| | | | | | | | | | | At the moment there are visual glitches when we resize the window. This happens because in wayland there a special function for resizing EGL windows. To prevent the glitches move the egl_context to the wayland state in wayland_common.h and add a new control function to gl_wayland.c to wrap the vo_wayland_control function to check for resize events. With the new control wrapper the glitches are gone and the resizing is fluid.
* wayland: implement dropping files on the VO windowAlexander Preisinger2014-01-041-0/+5
| | | | Needs some proper testing.
* wayland: better name for mouse coordinatesAlexander Preisinger2013-10-251-2/+2
| | | | | I had to look up what the surf_x and surf_y members do. That means the name is not very good. Also a comment.
* wayland: fix fullscreen transparent border regionsAlexander Preisinger2013-10-251-0/+2
| | | | | | | The default behavior of weston changed some time ago to not fill the surface black for fullscreen windows. Now let mpv draw the whole screen in fullscreen mode.
* wayland: use mp_input_test_draggingAlexander Preisinger2013-10-201-0/+2
| | | | | | Instead of removing dragging we now test if it we should drag the window or not. Because if the OSC shows up we can not drag the window because that would cause mouse events that makes the OSC disappear.
* Revert "wayland: don't create our own log context"Alexander Preisinger2013-09-121-0/+1
| | | | | | | This reverts commit beab54506e61bc080880e827e351439f76542e68. Conflicts: video/out/wayland_common.c
* wayland: update license headersAlexander Preisinger2013-09-091-7/+5
|
* wayland: don't create our own log contextAlexander Preisinger2013-08-261-1/+0
| | | | This was more problematic than useful ([vo/wayland/wayland])
* wayland: remove shm listener for the backendAlexander Preisinger2013-08-251-1/+0
| | | | | | The obtained information from the shm listener isn't used by anything and is also wrong now in wayland git master branch because of new shm formats which need a different way of saving the supported formats.
* wayland/egl: rework resizing (again)Alexander Preisinger2013-08-251-12/+5
| | | | | | | | | Moves a good chunk of the resizing code to wayland_common.c. This makes it possible to share it with future video drivers. It doesn't resizit it immediatly, it calcutlates the new position and size and then shedules a resizing event. This removes the ugly callback and void pointer from the wayland data structure.
* wayland: separate shm and cursor contextAlexander Preisinger2013-08-191-2/+2
| | | | | | The display, window, keyboard and cursor structures are now cleanly and logically separated. Also could prevent a future bug where no shm format is set when the cursor image is loaded (Never happened until now).
* wayland: switch to the new mp_msg apiAlexander Preisinger2013-07-311-0/+1
|
* wayland: use a unified struct for the stateAlexander Preisinger2013-07-181-56/+51
| | | | | | | | | | This commit removes the pointer to the single different structures for input and window and puts them as anonymous structures inside the wayland_state structure. This has the disadvantage of passing the substructure to the listeners, but the advantage is that we don't have to allocate them and check for NULL pointers. This makes it more reliable and easier to follow.
* video: remove fullscreen flags chaoswm42013-07-181-7/+0
|