summaryrefslogtreecommitdiffstats
path: root/video/out/wayland_common.c
Commit message (Collapse)AuthorAgeFilesLines
* wayland: fix segfault on uninitNiklas Haas2019-05-261-1/+1
| | | | Probably the same issue as #6732
* wayland: fix various memory leaksdudemanguy2019-05-211-0/+33
|
* wayland_common: rename “shell” into “wm_base”Emmanuel Gil Peyrot2019-02-171-10/+10
| | | | | | | | 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-41/+12
|
* wayland: use xdg-decoration if availableemersion2018-11-191-13/+43
|
* wayland_common: require wl_compositor of version 3Rostislav Pehlivanov2018-05-201-3/+2
| | | | | We already did require it, in order to call set_buffer_scale. This just makes it error out more gracefully.
* wayland_common: fix maximized stateRostislav Pehlivanov2018-05-201-13/+21
| | | | Window size should not change if the window has been maximized or tiled.
* wayland_common: update to stable xdg-shellEmmanuel Gil Peyrot2018-04-291-44/+44
| | | | | 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: fix idle_inhibitor protocol segfaultRostislav Pehlivanov2018-02-091-0/+1
| | | | The pointer is used as a state and wasn't zeroed after seeks.
* vo: add support for externally driven renderloop and make wayland use itRostislav Pehlivanov2017-12-051-0/+15
| | | | | | | | | | | Fixes display-sync (though if you change virtual desktops you'll need to seek to re-enable display-sync) partially under wayland. As an advantage, rendering is completely disabled if you change desktops or alt+tab so you lose no performance if you leave mpv running elsewhere as long as it isn't visible. This could also be ported to other VOs which supports it.
* wayland_common: check monitor scaleRostislav Pehlivanov2017-10-221-3/+9
| | | | | | | Since we divide by it in a couple of places and compositors can be crazy, its better to be safe than sorry. Also checks cursor spawn durinig init (pointless since it does again on cursor entry but its more correct).
* wayland_common: improve cursor code and scale cursor properlyRostislav Pehlivanov2017-10-221-26/+34
| | | | | | 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: don't scale the cursor wl_bufferRostislav Pehlivanov2017-10-191-1/+0
| | | | | Only gnome does something as stupid as always applying scaling to the cursor rather than just using a larger sized one with HIDPI.
* wayland_common: init output_list during main struct initRostislav Pehlivanov2017-10-121-1/+2
| | | | | Otherwise if display connection or xkb init failed the uninit function could segfault.
* wayland_common: require wl_output v2 and send MP_INPUT_RELEASE_ALL on uninitRostislav Pehlivanov2017-10-111-8/+13
| | | | | | Every compositor (including toy compositors) has had support for wl_output v2 since forever, so there's little point in supporting degraded output for 5 year old releases (especially considering we require zxdg6 which is far more recent).
* wayland_common: adjust default cursor size and scale its bufferRostislav Pehlivanov2017-10-101-2/+3
| | | | | | | It turns out compositors which do scaling scale the cursor as well, so every single surface needs to get scaled too. Also, 32 corresponds to the default size for both GTK+ and KDE.
* wayland_common: implement output tracking, cleanups and bugfixesRostislav Pehlivanov2017-10-091-194/+236
| | | | | | | | | | | | | | | | | | 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.
* wayland_common: allow vo_wayland_uninit(NULL)Niklas Haas2017-10-071-0/+2
| | | | ...again
* Revert "wayland_common: add support for embedding"Rostislav Pehlivanov2017-10-051-5/+0
| | | | This reverts commit 8d8d4c5cb1b3553215a8ba547d4db463fdc88831.
* wayland_common: respect close eventsRostislav Pehlivanov2017-10-051-3/+9
| | | | | Overlooked. Also add a comment and only set the parent if WinID is set.
* wayland_common: add support for embeddingRostislav Pehlivanov2017-10-051-0/+4
|
* wayland_common: reset the LIVE_RESIZING flag when resizing endsRostislav Pehlivanov2017-10-051-10/+14
| | | | | | The VO code resets each flag individually, and it doesn't do it for this one. Also make the prints use the struct names rather than the hardcoded ones, forgot to add those to the last wayland_common commit.
* wayland_common: don't hardcode protocol names during registryRostislav Pehlivanov2017-10-041-8/+8
| | | | Use the interface names from the wl_interface structs they provide.
* wayland_common: rewrite from scratchRostislav Pehlivanov2017-10-031-793/+927
| | | | | | | | | | | | 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: allow vo_wayland_uninit(NULL)Niklas Haas2017-09-211-0/+3
|
* input: merge mouse wheel and axis keycodesJames Ross-Gowan2017-09-031-4/+4
| | | | | | | | | | | | | | | | | | | | | | Mouse wheel bindings have always been a cause of user confusion. Previously, on Wayland and macOS, precise touchpads would generate AXIS keycodes and notched mouse wheels would generate mouse button keycodes. On Windows, both types of device would generate AXIS keycodes and on X11, both types of device would generate mouse button keycodes. This made it pretty difficult for users to modify their mouse-wheel bindings, since it differed between platforms and in some cases, between devices. To make it more confusing, the keycodes used on Windows were changed in 18a45a42d524 without a deprecation period or adequate communication to users. This change aims to make mouse wheel binds less confusing. Both the mouse button and AXIS keycodes are now deprecated aliases of the new WHEEL keycodes. This will technically break input configs on Wayland and macOS that assign different commands to precise and non-precise scroll events, but this is probably uncommon (if anyone does it at all) and I think it's a fair tradeoff for finally fixing mouse wheel-related confusion on other platforms.
* input: use mnemonic names for mouse buttonsJames Ross-Gowan2017-09-031-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | mpv's mouse button numbering is based on X11 button numbering, which allows for an arbitrary number of buttons and includes mouse wheel input as buttons 3-6. This button numbering was used throughout the codebase and exposed in input.conf, and it was difficult to remember which physical button each number actually referred to and which referred to the scroll wheel. In practice, PC mice only have between two and five buttons and one or two scroll wheel axes, which are more or less in the same location and have more or less the same function. This allows us to use names to refer to the buttons instead of numbers, which makes input.conf syntax a lot easier to remember. It also makes the syntax robust to changes in mpv's underlying numbering. The old MOUSE_BTNx names are still understood as deprecated aliases of the named buttons. This changes both the input.conf syntax and the MP_MOUSE_BTNx symbols in the codebase, since I think both would benefit from using names over numbers, especially since some platforms don't use X11 button numbering and handle different mouse buttons in different windowing system events. This also makes the names shorter, since otherwise they would be pretty long, and it removes the high-numbered MOUSE_BTNx_DBL names, since they weren't used. Names are the same as used in Qt: https://doc.qt.io/qt-5/qt.html#MouseButton-enum
* wayland_common: organize and correctly map mouse buttonsRostislav Pehlivanov2017-03-171-4/+8
| | | | | | | The function tried to do something clever but ignored the fact that the middle button followed the left button rather than the right. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* Fix mistakes in spelling and grammarDario Russo2016-12-211-3/+3
|
* wayland: destroy input before closing the display connection.Emmanuel Gil Peyrot2016-11-271-1/+1
| | | | | | Fixes a segfault introduced in libwayland e8ad23266f36521215dcd7cfcc524e0ef67d66dd, where a poison value has been introduced to catch this kind of use-after-free bug.
* vo: change messy handling of fullscreen and other flagswm42016-08-301-2/+2
| | | | | | | | | | | | | | 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.
* wayland: reject resize events with either dimension being 0Rostislav Pehlivanov2016-08-291-0/+2
| | | | Newer versions of mutter/gnome now ask mpv to resize to 0 by 0 pixels.
* x11, wayland: always round up wait timeswm42016-08-261-1/+1
| | | | | If wait_us is >0 and <500, the wait time gets rounded down 0, effectively turning this into busy waiting. Round it up instead.
* wayland_common: check for NULL current_output on fs switchingRostislav Pehlivanov2016-08-011-2/+3
| | | | | | | 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.
* wayland_common: provide the real scaled window resolutionRostislav Pehlivanov2016-08-011-3/+5
| | | | | | It makes more sense to completely abstract this scaling inside the backend so that internally the player only works with real actual drawn pixels.
* wayland_common: fix fullscreen image switching bugRostislav Pehlivanov2016-07-301-3/+4
| | | | | | | | | | | 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.
* wayland_common: prevent black bars on most non-native aspect ratiosRostislav Pehlivanov2016-07-301-0/+3
| | | | | | | | | 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.
* wayland_common: clip window size to the display output sizeRostislav Pehlivanov2016-07-301-5/+7
| | | | | | | | 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.
* wayland_common: flush wakeup_pipe on a wakeupRostislav Pehlivanov2016-07-301-8/+10
| | | | | | 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).
* wayland_common: remove untested/unusable wayland dnd codeRostislav Pehlivanov2016-07-301-183/+1
| | | | | Not worth keeping 200 lines of untestable as of today code which might be broken, if it hasn't been already.
* x11, wayland: do not accidentally close FD 0wm42016-07-211-2/+5
| | | | | | | | | | 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.
* wayland_common: make function declaration consistentRostislav Pehlivanov2016-07-211-23/+21
| | | | Half the code had a space before the arguments and half didn't.
* wayland: port to the new wakeup/wait_events frameworkRostislav Pehlivanov2016-07-211-61/+33
| | | | | | | | | | | | 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.
* vo_wayland: fix high CPU usage due to busy pollingRostislav Pehlivanov2016-07-191-3/+3
| | | | | | 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.
* wayland: mark existing dnd entry print as debug rather than an errorRostislav Pehlivanov2016-05-311-1/+1
| | | | | | | | 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>
* wayland: correctly report display refresh rateRostislav Pehlivanov2016-05-311-4/+6
| | | | | | | | | | | | 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>
* wayland: implement HIDPI supportRostislav Pehlivanov2016-05-301-6/+27
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* wayland: use the advertised size in fullscreenEmmanuel Gil Peyrot2016-05-081-7/+0
| | | | | | | | | | | | | | | 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.
* Revert "wayland: set fs mode on every configure"Emmanuel Gil Peyrot2016-03-191-6/+5
| | | | | | | | | Prevents an infinite loop of configure event and set_fullscreen request on Weston and other compositors respecting the protocol. Fixes #2817 This reverts commit eb6b2b6e50e6e3d3db41190ad818d8b966750734.
* wayland: set fs mode on every configureAlexander Preisinger2016-02-071-5/+6
| | | | | Check and set the fullscreen mode on every surface configure event. This prevents gnome from resizing mpvs fullscreen window to a smaller size.
* 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.
* mpv_talloc.h: rename from talloc.hDmitrij D. Czarkoff2016-01-111-1/+1
| | | | This change helps avoiding conflict with talloc.h from libtalloc.
* wayland: fix typo in error messageAlessandro Ghedini2015-12-271-1/+1
|
* Revert "vo_wayland: define opaque region"Ricardo Vieira2015-10-201-9/+0
| | | | | | This reverts commit c10fb4ce9fcd3dbbf69741eb8499c4cfabbf5412. 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.
* vo_opengl: wayland: switch to new internal APIwm42015-10-011-6/+4
|
* input: add append argument to file drop eventKevin Mitchell2015-08-301-1/+1
| | | | | | 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.
* vo_wayland: Wait for frame callbacksJari Vetoniemi2015-08-211-5/+60
| | | | | | | 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: define opaque regionJari Vetoniemi2015-03-231-0/+9
| | | | | This allows compositor to optimize rendering, as it will know mpv is not transparent.
* vo_wayland: share frame callbacks.Jari Vetoniemi2015-03-231-0/+30
| | | | | | |