src/video/wayland/SDL_waylandvideo.c


Log

Author Commit Date CI Message
Frank Praznik 650612fd 2022-08-13T16:54:27 wayland: Eliminate excessive calls to SetFullscreen Eliminate excessive calls to SetFullscreen by removing the calls in the libdecor and xdg-toplevel config callbacks. These calls were being made there in case something explicitly called the window minimization function from within SDL, which unsets fullscreen, and as minimizing a window in Wayland is just a suggestion to the compositor and doesn't actually change the window state or communicate anything back to the application, it was necessary to call SetFullscreen in every call to the config functions just in case something minimized a window via SDL_MinimizeWindow() and later needed to restore it. GNOME in particular had issues when fullscreen set/unset operations were being hammered, leading to overlapping acks and commits when switching to fullscreen. With the new video system flag to disable unsetting fullscreen when minimizing a window, these calls in the configuration functions are no longer needed and can be removed. This significantly reduces calls to the SetFullscreen() function, reverts #6044 while fixing the issue, and fixes a similar problem when hiding and showing a window initially created with fullscreen flags.
Frank Praznik cc9cc202 2022-08-13T16:43:15 video: Add video device quirk flags and apply them to the video subsystem Add quirk flags to the video device struct and add flags to allow video backend drivers to disable mode switching and disable unsetting the fullscreen mode when minimizing a window. As certain platforms can have multiple video backends compiled in at once, #ifdefs, as used by other platforms, aren't suitable as different backends on the same platform may not need the same quirks. This replaces the formerly dedicated 'disable_display_mode_switching' boolean as additional quirks are needed by the Wayland backend. Helper functions have also been added to simplify reading the flag states.
Guldoman 5f682e77 2022-08-10T20:01:15 wayland: Remove freed display from `SDL_WaylandOutputData->output_list`
Ryan C. Gordon 20a76b0e 2022-07-25T23:06:58 video: removed unused devindex argument from bootstrap's create method.
Frank Praznik e427e80b 2022-06-14T10:41:18 wayland: Use the output descriptions from xdg-output when available Some compositors will provide 'nicer' / 'human readable' output descriptions via the xdg-output protocol. Use these description strings, when available, instead of the model name provided by wl-output. On compositors such as GNOME where this is provided, the display names provided to applications by SDL will now match those in the desktop display settings panel. On compositors where this data isn't provided, the old behavior of using the model string provided by wl-output will remain unchanged. Additionally, per the protocol spec, output data provided by xdg-output should supersede wl-output data, so this is the recommended behavior in general.
Frank Praznik a20516d4 2022-05-16T10:35:56 wayland: Swap emulated mode dimensions in more cases Some compositors (GNOME for example) don't set the transform flag when dealing with portrait mode displays, so the video modes won't have the width/height swapped in all cases where they should be. Check for both the 90/270 degree transform flag and if the display is taller than it is wide when determining whether to swap the width and height of the emulated video modes, and adjust the comparison logic when size testing against the native mode to account for this.
Frank Praznik e1c83504 2022-05-15T10:35:59 wayland: Add a hint to disable video mode emulation under Wayland Add the hint "SDL_VIDEO_WAYLAND_MODE_EMULATION", which can be used to disable mode emulation under Wayland. When disabled, only the desktop and/or native display resolution is exposed.
Frank Praznik e9d3dcea 2022-05-14T18:32:05 wayland: Unify integer and fractional output scaling Previously, scale values used by the displays and surfaces were always integers, with fractional scale values only being calculated when the backbuffer and viewport sizes were being determined. Now, if xdg-output is available, the fractional scale of output displays is calculated when the displays are enumerated and the true scale values of the output devices are used whenever possible. This unifies the integer and fractional scaling systems, allows for the use of more accurate scale values that minimize overdraw when windows straddle multiple outputs, and lays the groundwork for the pending Wayland scaling protocols that will report the preferred scale values per-surface instead of per-output.
Ethan Lee 6222bd31 2022-05-11T16:26:43 wayland: Don't create a new libdecor context if one already exists
Ethan Lee 6f88cbe4 2022-05-11T16:04:34 wayland: Support xdg_decoration requesting client-side decorations. Don't be fooled by the diff size - this ended up being a big refactor of the shell surface management, masked only by some helper macros I wrote for the popup support. This change makes it so when xdg_decoration is supported, but CSD is requested, the system bails on xdg support entirely and resets all the windows to use libdecor instead. This transition isn't pretty, but once it's done it will be smooth if decorations are an OS toggle since libdecor will take things from there. In hindsight, we really should have designed libdecor to be passed a toplevel, having it manage that for us keeps causing major refactors for _every_ change.
Ethan Lee c37090f9 2022-04-18T12:30:08 wayland: Add support for TOOLTIP/POPUP_MENU
David Gow 9c2f46b0 2022-04-12T15:23:22 Wayland: Add SDL_HINT_VIDEO_WAYLAND_PREFER_LIBDECOR This hint allows libdecor to be used even when xdg-decoration is available. It's mostly useful for debugging libdecor, but could in theory be used by applications which want to (for example) bundle their own libdecor plugins.
Frank Praznik fa4c5198 2022-03-28T21:32:30 video: wayland: Expose more resolutions for mode emulation Expose as many emulated display modes as possible. They will currently display stretched to the display's native desktop aspect, but if an application requires a hardcoded resolution, it will work at minimum. Aside from the change in the emulated display mode list, the Wayland event handling code had to be updated to support separate scaling for the x and y axes, as square pixels are no longer guaranteed.
Ethan Lee d875416a 2022-03-28T15:32:30 wayland: Minor fix for old compilers
Frank Praznik 4d76c9cb 2022-03-25T20:35:07 video: wayland: Use wp-viewporter for fullscreen with non-native resolutions Wayland doesn't support mode switching, however Wayland compositors can support the wp_viewporter protocol, which allows for the mapping of arbitrarily sized buffer regions to output surfaces. Use this functionality, when available, for fullscreen output when using non-native display modes and/or when dealing with scaled desktops, which can incur significant overdraw without this extension. This also allows for the exposure of arbitrarily sized, emulated display modes, which can be useful for legacy compatability.
Ethan Lee 713a6754 2022-03-26T22:26:15 wayland: Relax the check for mismatching output scales
Ethan Lee 5655be15 2022-03-26T19:57:39 wayland: Avoid overwriting xdg_output position with wl_output position
Ethan Lee 40417b18 2022-03-26T19:55:04 wayland: Work around a GNOME xdg_output scaling issue
Ethan Lee ab74b6a3 2022-03-24T15:34:29 wayland: Remove some now-redundant casts
Ethan Lee ee52ad08 2022-03-24T15:32:25 wayland: Minor fixes for old compilers
Frank Praznik 0dae35bf 2022-03-19T15:58:47 video: wayland: Use xdg-output for retrieving the desktop dimensions Using wl-output to get the desktop display dimensions and dividing by the integer scale factor will not return the correct result when using a desktop with fractional scaling (e.g. a 3840x2160 display at 150% will incorrectly report the scaled desktop area as 1920x1080 instead of 2560x1440). Use the xdg-output protocol, if available, to retrieve the correct desktop dimensions and offset. Versions 1 through 3 of the protocol are supported.
Florian "sp1rit"​ 9125b244 2022-03-23T13:46:25 wayland: Basic support for zwp_tablet_*v2 protocol
Ethan Lee 13337e17 2022-03-23T13:27:01 wayland: The rest of the wayland-client 1.18 requirement... Git, please
Cameron Gutman cc40f732 2022-01-26T21:09:39 wayland: Round the refresh rate rather than truncating it A 59999 mHz monitor should be reported as 60 Hz, not 59 Hz.
Ethan Lee ed3442d7 2022-01-19T15:47:52 wayland: Fix building with SDL_OPENGL=OFF
Sam Lantinga 120c76c8 2022-01-03T09:40:00 Updated copyright for 2022
Ethan Lee 72e53e4b 2021-11-28T19:25:22 wayland: Clear driverdata before calling ResetDisplayModes
Sam Lantinga 57366285 2021-11-23T20:14:18 Only send display events for hotplugged displays, not the initial state
Sylvain d31251b0 2021-11-21T22:30:48 use SDL's functions version inplace of libc version
Ethan Lee a7a54e64 2021-11-18T00:43:55 wayland: Add support for display connect/disconnect events
Ethan Lee 5cc23868 2021-11-15T11:52:43 wayland: Add support for SDL_DisplayOrientation
Ethan Lee ae67c7d2 2021-11-09T01:30:00 Implemented SDL_SetWindowMouseRect() on Wayland
Cameron Gutman 2bf36bfa 2021-10-24T21:28:04 wayland: Implement WaitEventTimeout() and SendWakeupEvent() We can have spurious wakeups in WaitEventTimeout() due to Wayland events that don't end up causing us to generate an SDL event. Fortunately for us, SDL_WaitEventTimeout_Device() handles this situation properly by calling WaitEventTimeout() again with an adjusted timeout.
Cameron Gutman 408a93a1 2021-10-23T15:43:04 wayland: Use multi-thread event reading APIs Wayland provides the prepare_read()/read_events() family of APIs for reading from the display fd in a deadlock-free manner across multiple threads in a multi-threaded application. Let's use those instead of trying to roll our own solution using a mutex. This fixes an issue where a call to SDL_GL_SwapWindow() doesn't swap buffers if it happens to collide with SDL_PumpEvents() in the main thread. It also allows coexistence with other code or toolkits in our process that may want read and dispatch events themselves.
David Gow 25f9e32b 2021-10-02T16:52:43 wayland: Don't let multiple threads dispatch wayland events at once wl_display_dispatch() will block if there are no events available, and while we try to avoid this by using SDL_IOReady() to verify there are events before calling it, there is a race condition between SDL_IOReady() and wl_display_dispatch() if multiple threads are involved. This is made more likely by the fact that SDL_GL_SwapWindow() calls wl_display_dispatch() if vsync is enabled, in order to wait for frame events. Therefore any program which pumps events on a different thread from SDL_GL_SwapWindow() could end up blocking in one or other of them until another event arrives. This change fixes this by wrapping wl_display_dispatch() in a new mutex, which ensures only one thread can compete for wayland events at a time, and hence the SDL_IOReady() check should successfully prevent either from blocking.
Ethan Lee 8e54698a 2021-09-22T13:26:44 wayland: Add support for high-DPI cursors
Andrei Alexeyev 68ca35c3 2021-08-11T21:40:46 wayland: fix memleak in output listener
Sebastian Krzyszkowiak 2e6dac87 2021-08-09T01:47:42 wayland: Add a hint to allow disabling libdecor use Useful for testing xdg-shell path with compositors like Weston.
Cameron Gutman b08b1bde 2021-08-03T22:50:58 linux: remove d-bus lazy init dead code Lazy init in X11/Wayland is dead code since dbdbae4
Ethan Lee 32f909f7 2021-08-03T13:30:57 wayland: Remove redundant waylanddyn.h includes. All files including waylanddyn.h already include waylandvideo.h first.
Ethan Lee e5594e66 2021-07-30T16:03:01 wayland: Prefer our SSD implementation if available
Ethan Lee 74162b74 2021-07-29T13:27:31 wayland: Add support for text-input-unstable-v3
Ethan Lee 03185e74 2021-07-27T18:35:00 wayland: Tag/Check wl_output objects as well, fixes crashes when libdecor is in use
Simon Zeni 6aae5b44 2021-07-27T17:12:26 Remove wl-shell and xdg-shell-unstable-v6 support (#4323) * wayland-protocol: update wayland.xml to 1.19.0 * wayland: remove shell_surface field from SDL_SysWMinfo * wayland: remove wl_shell support * waypand-protocols: update xdg-shell.xml to 1.20 * wayland: remove xdg-shell-unstable-v6 support * wayland: deprecate wl shell surface syswm info, add xdg surface
Christian Rauch 9e6fcbe7 2020-06-11T22:10:28 wayland: client-side decoration
meyraud705 4ada14a2 2021-07-21T13:39:10 Replace libc functions to SDL equivalent in wayland video subsystem Wayland video subsystem uses a mix of libc and SDL function. This patch switches libc functions to SDL ones and fixes a mismatch in memory allocation/dealoccation of SDL_Cursor in SDL_waylandmouse.c (calloc on line 201 and SDL_free on line 313) which caused memory corruption if custom memory allocator where provided to SDL.
Ethan Lee d956636c 2021-06-04T18:39:47 wayland: Implement FlashWindow
Ethan Lee 151f9538 2021-06-02T11:41:44 wayland: Implement RaiseWindow with xdg-activation
Ethan Lee 8e3ec34d 2021-04-20T12:40:40 wayland: Refactor toplevel mapping, implement HideWindow
Ethan Lee 509228c4 2021-04-18T22:26:27 wayland: Implement GetDisplayDPI
Ethan Lee fcbfe33c 2021-04-18T09:45:22 wayland: Implement SetWindowModalFor
Ethan Lee 0f518002 2021-04-18T09:33:57 wayland: Removed unused GetDisplayModes/SetDisplayMode functions
Ethan Lee 46df195b 2021-04-18T09:33:06 wayland: Implement GetDisplayBounds
Ethan Lee ed24c345 2021-04-16T21:35:50 wayland: Implement basic window move events via wl_surface_listener. This unearthed an unspeakably large amount of bugs in the wl_output enumerator, notably the fact that the wl_output user pointer was to temporary memory! This was "fixed" in e862856, and was then pointed out as a leak in 4183211, which was undone in d9ba204. The busted fix was correct that the malloc was an issue, but wrong about _why_; SDL_AddVideoDisplay copies by value and does not reuse the pointer, so generally you want your VideoDisplay to be on the stack, but of course the callbacks don't allow that, so a malloc was a workaround. But we can do better and just host our temporary display inside WaylandOutputData because that will be persistent while also not leaking. Wait, wasn't I talking about move events? Right, that: wl_surface_listener does at least give us the ability to know what monitor we're on, even though we have no idea where we are on the monitor. All we need to do is check the wl_output against the display list and then push a move event that both indicates the correct display while also not being _too_ much of a lie (but enough of a lie to where our event doesn't get discarded as "undefined" or whatever). The index check for the video display is what spawned the great nightmare you see before you; aside from the bugfix this is actually a really basic patch.
Ethan Lee f88d91d5 2021-04-12T23:47:23 wayland: Minor whitespace fix
Ethan Lee d785dab5 2021-04-12T23:37:53 wayland: Add unscaled resolutions to the display mode list
Ethan Lee 7510245a 2021-04-08T14:08:35 wayland: Create the data_device only after both device_manager and input exist. There is no guarantee on what order the Wayland interfaces will come in, but the callbacks were assuming that wl_data_device_manager would could before wl_seat. This would cause certain desktops to not have any data_device to work with, meaning certain features like the clipboard would silently no-op.
David Edmundson 6fd37194 2021-04-07T16:03:41 wayland: Fix leaked zxdg_decoration_manager
David Edmundson f6a09ef1 2021-04-07T16:16:23 wayland: Drop support for kwin specific decoration management KWin has supported the shared and formalised zxdg_decoration since Plasma 5.16 which came out mid 2019. Whilst it made sense to support them both for a while, it should not be needed for future SDL releases.
Ryan C. Gordon dbdbae44 2021-04-02T14:35:11 linux: (de)initialize d-bus at init and quit. Previously we had different subsystems quitting it, in conflict, and risked multiple threads racing to init it at the same time. Fixes #3643.
Ethan Lee eeee7308 2021-03-29T16:57:03 wayland: Implement IME support. Note that this is purely to make it possible to enter text that requires composition - for example, before this commit Kanji input didn't work at all. The big problem this still has is that we need the window position, and this is still not implemented. Once we have this information we can do the equivalent of XTranslateCoordinates to put the rectangle where we want it.
Ethan Lee 57a927e8 2021-02-12T14:27:58 wayland: Explicitly set min/max size for xdg-shell
Sam Lantinga d9ba2044 2021-02-08T16:55:01 Backed out changeset 852a7bdbdf4b This causes a use-after-free memory error
Christian Rauch 4183211a 2021-02-08T16:01:37 free the 'display' after it was added to global list
Sam Lantinga ff297753 2021-02-04T10:46:34 Fixed compiler warning
Sebastian Krzyszkowiak e862856e 2021-02-01T08:57:39 wayland: Don't crash when the properties of already existing wl_output change
Christian Rauch a4467846 2021-01-31T19:09:44 free the 'data_device_manager'
Sebastian Krzyszkowiak 3ae2ec34 2021-01-31T19:06:37 wayland: Fix transform and scale handling when setting display mode
Cameron Gutman a0d3c6c6 2021-01-25T21:42:14 Rename SetWindowGrab() to SetWindowMouseGrab()
Cameron Gutman e1f73e64 2021-01-23T16:22:44 Refactor keyboard grab to be managed by the video core This gives us flexibility to add others hints to control keyboard grab behavior without having to touch all of the backends. It also allows us to possibly expose keyboard grab separately from mouse grab for applications that want to manage those independently.
Ethan Lee e787282b 2021-01-23T15:40:22 Implement Wayland_SetWindowResizable
Cameron Gutman bd553ea8 2021-01-20T21:17:20 Implement support for inhibiting the screensaver on Wayland We support both the org.freedesktop.ScreenSaver D-Bus API (same as the X11 backend) and the Wayland idle_inhibit_unstable_v1 protocol. Some Wayland compositors only support one or the other, so we need both to for broad compatibility.
Cameron Gutman 19236b46 2021-01-21T21:49:13 Implement support for minimizing windows on Wayland This required a bit of extra code to deal with the transition from minimized back to fullscreen
Cameron Gutman d789ba83 2021-01-19T18:20:07 Implement keyboard grab support for Wayland Use zwp_keyboard_shortcuts_inhibit_manager_v1 to allow SDL applications to capture system keyboard shortcuts like Alt+Tab when keyboard grab is enabled via SDL_HINT_GRAB_KEYBOARD.
Sam Lantinga 9130f7c3 2021-01-02T10:25:38 Updated copyright for 2021
Sam Lantinga 76980e30 2020-10-08T16:42:20 Added events for dynamically connecting and disconnecting displays, with an iOS implementation
M Stoeckl a78b9763 2020-07-14T19:18:16 Reuse Wayland connection from availability check
M Stoeckl 052a1373 2020-07-12T19:11:15 Merge VideoBootStrap::available into VideoBootStrap::create The two are only ever called together, and combining them makes it possible to eliminate redundant symbol loading and redundant attempts to connect to a display server.
Tudor Brindus 1a291ab1 2020-04-17T13:55:44 wayland: add support for SDL_SetWindowGrab
Ryan C. Gordon 02469877 2020-04-07T13:30:46 wayland: Support wayland compositors with wl_seat version < 5 (thanks, Nia!). Fixes Bugzilla #5074.
Sam Lantinga a8780c6a 2020-01-16T20:49:25 Updated copyright date for 2020
Michael Forney cdbeae52 2019-12-29T23:10:39 wayland: support wl_data_device_manager version < 3
Sam Lantinga afdb40af 2019-08-05T23:38:48 Fixed bug 4689 - SDL fails to detect compositor shutdown on Wayland -- program keeps running M Stoeckl To reproduce: 1. Run any SDL-based program with a Wayland compositor, orphaning it so that it doesn't have an immediate parent process. (For example, from a terminal, running `supertux2 & disown`.) The program should use the wayland backend, i.e. by setting environment variable SDL_VIDEODRIVER=wayland. 2. Kill the compositor process. Results: - The SDL program will keep running. Expected results: - The SDL program should close. (What close should mean here, I'm not sure - is injecting an SDL_Quit the appropriate action when a video driver disconnects?) Build data: 2019-06-22, hg tip (12901:bf8d9d29cbf1), Linux, can reproduce with sway, weston, and other Wayland oompositors.
Sebastian Krzyszkowiak 797b2813 2019-06-12T00:55:05 wayland: HiDPI support
Sylvain Becker cddb285c 2019-03-12T20:04:08 Fixed bug 4513 - Wayland, fix crash when remove event is sent (from Sebastian Krzyszkowiak)
Sam Lantinga 5e13087b 2019-01-04T22:01:14 Updated copyright for 2019
Sebastian Krzyszkowiak 5f980514 2018-11-04T21:08:40 wayland: ask xdg-decoration protocol extension to use server-side decorations if possible.
Ryan C. Gordon 62494a2e 2018-10-31T15:03:41 Merge SDL-ryan-batching-renderer branch to default.
Ryan C. Gordon a5ebd4d7 2018-10-29T10:14:59 wayland: ask KDE protocol extension to use server-side decorations if possible.
Sam Lantinga 5febdfce 2018-09-24T11:49:25 Fixed whitespace
Ryan C. Gordon c8ac9096 2018-06-24T22:42:36 wayland: Implemented xdg-wm-base support. This is just in parity with the existing zxdg-shell-unstable-v6 code. Making the Wayland target robust (and uh, with title bars) is going to take a lot of work on top of this.
Ryan C. Gordon cd532207 2018-02-07T13:13:55 wayland: Add support for xdg-shell protocol (unstable v6). This is meant to be the desktop-enhanced version of wl_shell. Right now we just match what the existing wl_shell code does, but there are other areas of functionality available to us now, that we can fill in later. This uses the "unstable" API, since this is what ships in Ubuntu 17.10 (as part of Wayland 1.10), but Wayland 1.12 promotes this to stable with extremely minor changes. We will add support for the stable version when it makes sense to do so.
Sam Lantinga 8111a632 2018-01-03T10:49:26 Fixed bug 4013 - Wayland: fix videoquit on multimonitor system Vladimir On multimonitor system Wayland_VideoQuit invalid deiniting. Tested in Centos7 + Weston
Sam Lantinga e3cc5b2c 2018-01-03T10:03:25 Updated copyright for 2018
Brandon Schaefer e27f12e0 2017-09-29T10:07:37 wayland: Fix bug 3814 -Wmissing-field-initializers
Sam Lantinga 50efbda7 2017-08-28T00:43:14 Fixed mingw Windows build, since SDL_vulkan_internal.h includes windows.h
Sam Lantinga ce2b1644 2017-08-28T00:11:38 Be clear that disabling Vulkan surface support disables the entire SDL Vulkan integration
Ryan C. Gordon 25e3a1ec 2017-08-27T22:15:57 vulkan: Initial Vulkan support! This work was done by Jacob Lifshay and Mark Callow; I'm just merging it into revision control.
Philipp Wiesemann 6c0aea42 2017-05-25T23:00:58 wayland: Fixed freeing memory of SDL_malloc() with plain free().
Sam Lantinga d3591800 2017-01-03T00:44:05 Fixed bug 3519 - SDL_GetDisplayMode fails to report mode.format when using Wayland backend Ryan C. Gordon Kristian says you can't do it with Wayland, and that going forward, it'll just handle whatever you throw at it anyhow. https://twitter.com/hoegsberg/status/816148272402165761 So I say we mark it SDL_PIXELFORMAT_RGB888, which is what my X11 display currently reports, and leave it at that.