src/video/wayland/SDL_waylandwindow.c


Log

Author Commit Date CI Message
Frank Praznik b5483f2c 2022-12-01T18:03:36 Fix formatting on Wayland and Pipewire function signatures Fixes the formatting on some function signatures that clang-format missed. (cherry picked from commit 378b1c286a9c3206e827a47f0147384e92c4c2b2)
Sam Lantinga b8d85c69 2022-11-30T12:51:59 Update for SDL3 coding style (#6717) I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base. In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted. The script I ran for the src directory is added as build-scripts/clang-format-src.sh This fixes: #6592 #6593 #6594 (cherry picked from commit 5750bcb174300011b91d1de20edb288fcca70f8c)
David Edmundson d7664a6e 2022-07-11T19:28:37 Support wayland fractional scale protocol The new protocol adds support for more native communication of fractional scaling. Everything in the wayland backend already existed only our fractional scale was calculated implicitly through a combination of output size guesswork for fullscreen windows. This new protocol makes that explicit, providing a more robust solution and a solution for non-fullscreen surfaces. The fallback code is still left in place for now whilst compositors gain support.
Sylvain Becker fb0ce375 2022-11-27T17:38:43 Cleanup add brace (#6545) * Add braces after if conditions * More add braces after if conditions * Add braces after while() conditions * Fix compilation because of macro being modified * Add braces to for loop * Add braces after if/goto * Move comments up * Remove extra () in the 'return ...;' statements * More remove extra () in the 'return ...;' statements * More remove extra () in the 'return ...;' statements after merge * Fix inconsistent patterns are xxx == NULL vs !xxx * More "{}" for "if() break;" and "if() continue;" * More "{}" after if() short statement * More "{}" after "if () return;" statement * More fix inconsistent patterns are xxx == NULL vs !xxx * Revert some modificaion on SDL_RLEaccel.c * SDL_RLEaccel: no short statement * Cleanup 'if' where the bracket is in a new line * Cleanup 'while' where the bracket is in a new line * Cleanup 'for' where the bracket is in a new line * Cleanup 'else' where the bracket is in a new line (cherry picked from commit 6a2200823c66e53bd3cda4a25f0206b834392652 to reduce conflicts merging between SDL2 and SDL3)
Frank Praznik fe396e30 2022-11-19T11:28:31 wayland: Use the cached window size when switching from non-floating to floating window state When changing the window state from non-floating to floating (e.g. leaving fullscreen), libdecor can send bogus content sizes that are +/- the height of the window title bar and start 'walking' the window height in one direction or the other with every transition. The floating window size is known, so use the cached value instead of the size reported by libdecor when restoring the floating state.
Hubert Maier 5dc93451 2022-11-06T20:49:37 JANITORIAL : Correct some more spelling mistakes (#6489)
Frank Praznik 4223e6ac 2022-10-26T13:14:50 wayland: Early-out sooner when requesting fullscreen on a popup Exit the fullscreen sequence sooner if it is requested that a popup window be fullscreen. The surface commit formerly in this path is irrelevant and can be removed as previous changes made it so that SetFullscreen() is no longer called from anywhere except Wayland_SetWindowFullscreen().
Frank Praznik 6391ad97 2022-10-09T11:11:55 wayland: Factor out common libdecor frame commit code The pattern of: libdecor_state_new() libdecor_frame_commit() libdecor_state_free() was used in several places. Factor it out into a common function.
Frank Praznik b0a9396b 2022-10-09T11:06:20 wayland: Remove XDG surface geometry calls These were needed to fix some buggy behavior regarding committing old buffer sizes when entering fullscreen that has since been corrected. Remove them.
Frank Praznik 914a65e0 2022-10-06T12:39:36 wayland: Don't unset min/max values when entering fullscreen via a compositor event If the compositor is entering fullscreen and hasn't removed any constraints itself, it's already too late at this point. Remove the unnecessary call. Restoring the limits when exiting fullscreen is still required, though, as they may have been removed when entering fullscreen via an SDL request.
Frank Praznik 69cf5fb0 2022-10-04T13:09:35 wayland: Remove surface type helpers These were remnants of a time before the surface type was explicitly stored, so they can be removed per the TODO note.
Frank Praznik c2b0c41c 2022-10-04T12:59:26 wayland: Set/unset the opaque regions on surfaces when transparency is toggled Caches the SDL_HINT_VIDEO_EGL_ALLOW_TRANSPARENCY hint at init time and registers a callback, which is fired when the hint is changed during runtime and toggles the opaque region for existing surfaces.
Frank Praznik ea595800 2022-10-03T18:31:15 wayland: Set the damage buffer size when supported The preferred method for setting the damage region on compositor protocol versions 4 and above is to use wl_surface.damage_buffer. Use this when available and only fall back to wl_surface.damage on older versions. Bumps the highest supported version of wl_compositor to version 4.
Frank Praznik a8cb7bbe 2022-10-01T11:31:26 wayland: Add dedupe logic to window geometry configuration Adds deduplication logic to ConfigureWindowGeometry() to avoid setting redundant backbuffer, viewport and surface opaque region dimensions. State is now only set when the window and/or backbuffer dimensions change. This repurposes the viewport rect to always hold the actual size of the window, which can differ from the SDL size if things are being scaled. The SDL_Rect was removed in favor of two ints, as the x/y members of the struct were never used, so they just wasted space. Since the internal variables always have the true window size, the width/height getter functions are no longer required and can be removed.
Frank Praznik e17f0c28 2022-09-27T10:59:28 wayland: Call the Wayland hide/show functions directly when changing decoration modes Calling SDL_HideWindow() to destroy the window is a NOP if the SDL_WINDOW_SHOWN flag was never set. Bypass it and call the Wayland-specific function directly to ensure that the window is always destroyed before switching from server-side to client-side decorations, even if it hasn't been shown yet. Likewise, call Wayland_ShowWindow() directly when the window isn't explicitly hidden to ensure that it is always recreated since the SDL_WINDOW_SHOWN flag won't be cleared, which, when set, renders SDL_ShowWindow() a NOP.
Frank Praznik 929d5b80 2022-09-12T22:39:44 wayland: Use the backbuffer size for determining if a resize event is required In some cases, a backbuffer size update may not be accompanied by a resize event if the window size and/or scale were updated before the new backbuffer size was recomputed. Instead of the scale, use the old/new backbuffer sizes to determine if a resize event is required so that a backbuffer size change will always be followed by a resize event.
Frank Praznik edfb00c2 2022-09-09T14:26:44 wayland: Only commit on move if the display was changed Only commit on a move event if the display was changed for a fullscreen window and the compositor has returned bad dimensions.
Frank Praznik 97a5e744 2022-09-06T17:08:27 wayland: Remove duplicate code Wayland_SetWindowSize() can be simplified with the common CommitWindowGeometry() function.
Frank Praznik 78f843f7 2022-09-06T13:19:23 wayland: Remove unnecessary function parameter SetFullscreen() is never called in a case where the commit parameter is false anymore, so the parameter is unnecessary.
Frank Praznik 768b6728 2022-09-04T23:39:05 wayland: Compare against the old scale when resizing Compare against the old scale instead of the new or the conditional will always be true.
Frank Praznik 07aea476 2022-09-03T13:30:49 wayland: Ignore content sizes from libdecor when hiding a window When hiding a window, libdecor can report bogus content region sizes that are +/- the height of the title bar. Ignore any size values from libdecor when hiding a window, or the size may be incorrect when restored.
Frank Praznik 6de12b4a 2022-09-06T13:30:19 wayland: Update the internal state when the compositor moves a fullscreen window The compositor can arbitrarily move windows between displays, including fullscreen windows. Update the internal state when a fullscreen window is moved so the internal SDL state accurately reflects the window location, and resize the window to fit the new display. This also fixes an edge case where the compositor can make a window fullscreen on a different display than SDL thinks it will be on (usually when a window is made fullscreen by the compositor while straddling multiple displays), which can result in the window being incorrectly sized.
Frank Praznik a7d34595 2022-09-03T13:11:29 wayland: Trigger a commit on fullscreen update If additional fullscreen requests are received when the window is already fullscreen, it is typically due to the fullscreen flags or emulated video mode being changed. A commit must be explicitly triggered or the requested changes won't take effect until some other event, such as a resize or focus change, causes the changes to be committed.
Frank Praznik 707b561f 2022-09-03T12:37:02 wayland: Enable compositor fullscreen toggling The compositor can toggle the fullscreen state (via a hotkey or otherwise), so the internal SDL state must be updated accordingly when it does. When toggling fullscreen via the compositor, SDL will attempt to use the last fullscreen flag explicitly set. If no flag was previously set, SDL_WINDOW_FULLSCREEN will be used if a window video mode was set, otherwise SDL_WINDOW_FULLSCREEN_DESKTOP will be used. If the previous flag was SDL_WINDOW_FULLSCREEN and the window video mode was cleared, it will revert to SDL_WINDOW_FULLSCREEN_DESKTOP.
Frank Praznik 31979e2d 2022-09-02T18:41:21 wayland: Add missing static qualifiers
Noel Berry 00452e47 2022-08-24T11:25:13 Adding SDL_GetWindowSizeInPixels for window size in pixels (#6112)
Frank Praznik 3bae2d57 2022-08-18T12:39:47 wayland: Set the libdecor app ID after visibility calls Set the frame app ID after toggling visibility or the name displayed in window manager task switchers may not display correctly.
Frank Praznik 7da74eb5 2022-08-17T14:59:23 wayland: Never commit with an undefined window title If libdecor performs a commit with the frame title being undefined, a crash can occur within the library or its plugins. Always ensure that the title is set to a valid string to avoid this.
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 74bdb211 2022-08-12T22:01:12 wayland: Don't roundtrip in ShowWindow unless restoring a hidden window Don't call the roundtrip in ShowWindow unless restoring a previously hidden window. This fixes a regression in GNOME when creating a window with the fullscreen flag set, as the fullscreen window will be positioned down the screen by the height of the top bar if the window is made fullscreen on the primary display and the roundtrip is called when initially displaying the window.
Cameron Gutman 1b08cd20 2022-08-12T18:55:05 wayland: Add roundtrip in SetWindowFullscreen() to get new size The video core assumes that window->w/h will be updated before returning from SetWindowFullscreen(). This is needed to generate a resize event with the correct window size when exiting fullscreen. The roundtrip allows us to receive the configure callback that informs us of the new window size before returning. Fixes #6043
Cameron Gutman 780b031b 2022-08-12T16:39:39 wayland: Avoid duplicate resize events when entering fullscreen
Frank Praznik dd2e3182 2022-08-06T12:31:06 wayland: Use libdecor visibility toggle for hiding/showing the window The current method of toggling the libdecor window visibility by destroying and recreating the frame results in a race where a use-after-free bug can manifest itself within libdecor when window visibility is toggled quickly. Instead, use the libdecor function for toggling visibility instead of destroying and recreating the frame every time.
Frank Praznik 3685c64e 2022-08-05T16:16:31 wayland: Round trip after window show/hide operations. Perform a round trip after showing/hiding the window to avoid protocol errors when ShowWindow() is called immediately after HideWindow().
Sebastian Krzyszkowiak 041666e6 2022-07-24T05:45:59 video: wayland: Don't switch to libdecor path for borderless windows We actually request CSD mode with xdg-decoration for borderless windows, so we get what we wanted there and there's no point in going into fallback paths.
Sebastian Krzyszkowiak 405d1f65 2022-07-24T10:16:20 video: wayland: Roundtrip after falling back to libdecor in xdg-decoration handler Otherwise libdecor doesn't have a chance to acquire xdg-toplevel after libdecor_new before we attempt to use it in Wayland_ShowWindow. Fixes #5952
David Gow 78bad667 2022-07-16T22:12:08 video: wayland: Resize the window before sending the SDL_RESIZE event Currently, the SDL_WINDOWEVENT_RESIZED event is sent before the actual window is resized (and various internal state, such as the desired GL/Vulkan backbuffer size, are updated). This makes sense, as SDL will discard a no-op resize, which would be the case if we had resized before sending the event (indeed, there are existing hacks to prevent this). However, this means that SDL_{GL,Vulkan}_GetDrawableSize() will still use the old size in the SDL_WINDOWEVENT_RESIZED handler. In the case of SDL_Renderer, this means the drawable size it uses will be wrong, and the viewport will get "updated" to the old value. This then results in bug #5899.
Frank Praznik c11bdeeb 2022-06-21T13:28:14 wayland: Round fractional backbuffer sizes halfway away from zero Use SDL_lroundf() to round fractional backbuffer sizes halfway away from zero, as this is the rounding method recommended by the forthcoming Wayland fractional scaling protocol.
Frank Praznik 4a3277b0 2022-05-19T15:13:02 wayland: Always commit window constraints before entering fullscreen XDG-toplevel min/max size values are double-buffered data and must be committed before entering the fullscreen state, or a max window size value smaller than the display dimensions may cause the compositor to incorrectly configure the fullscreen window size. This fixes windowed->fullscreen transitions on GNOME, where, previously, certain combinations of window flags and min/max size values could cause entering fullscreen mode to fail with odd window sizes and/or offsets due to the new max size values not being committed before entering fullscreen, causing the compositor to clamp to the old values. In the case of libdecor, it has its own layer of buffering on top of the xdg-toplevel surface for the min/max window dimensions, so both a frame commit and surface commit are required to set the state properly.
Frank Praznik 78698a0b 2022-05-17T12:37:16 wayland: Use a separate frame callback for setting the surface damage region Previously, the surface damage region was being set in the same callback used for preventing render hangs in the GL backend when the surface was not visible. This was not ideal, as the callback was never fired in the case of using a different render backend or having a swap interval of 0. Use a separate frame callback for setting the surface damage region to ensure that it fires reliably, regardless of the backend being used or swap interval.
Frank Praznik 146ea9b0 2022-05-16T18:18:55 wayland: Only set the surface opaque region if EGL transparency is disabled Check if the "SDL_VIDEO_EGL_ALLOW_TRANSPARENCY" hint is enabled and don't mark surfaces as opqaue if it is.
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.
Frank Praznik 4fde7dd8 2022-05-14T14:42:52 wayland: Refactor the Wayland mode emulation and viewport logic Compartmentalize the fullscreen mode emulation code blocks, unify the windowed/fullscreen viewport logic, consolidate all window geometry code into a central function to eliminate blocks of duplicate code and rename related variables and functions to more explicitly reflect their purpose.
Ethan Lee e4bb3c86 2022-05-11T18:13:44 wayland: Fix build for configs without libdecor
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.
Frank Praznik c8c59a21 2022-04-20T08:58:58 Fix a -Wshadow warning
Ethan Lee c37090f9 2022-04-18T12:30:08 wayland: Add support for TOOLTIP/POPUP_MENU
Frank Praznik 13393a1c 2022-04-15T14:28:07 video: Wayland: Clamp fullscreen window dimensions to desktop A scaled fullscreen window may exceed the bounds of the desktop. Clamp the window size to the desktop dimensions in fullscreen mode.
Frank Praznik c2093fab 2022-04-08T13:58:45 video: wayland: Set the surface damage region when using fullscreen viewports When using emulated display modes, the output size is often larger than the drawable buffer. As the surface damage region is automatically calculated from the smaller drawable buffer size, the damage region needs to be manually set to cover the entire viewport region or visual repaint artifacts can result.
Ethan Lee d1f7f9e3 2022-04-06T11:18:46 wayland: Pin the fake window position at (0, 0). I kind of thought it'd be nice to have it in the center, but this is an issue for applications that still assume global mouse and window positions are accessible. For example, this fixes cursor offset issues in UE5.
Ethan Lee 279aeb59 2022-04-06T01:32:57 wayland: Add a bug link for the detach FIXME
Ethan Lee 3ada694e 2022-04-06T01:18:03 wayland: Try to detach at the beginning of ShowWindow, just in case. It's possible that an external component (probably a GL/VK context) committed, so we need to cover our bases and detach in both HideWindow and ShowWindow. Fixes a crash in UE5 editor's pop-ups.
Ethan Lee dcfb7fff 2022-04-06T00:55:32 wayland: Evaluate WINDOWPOS_CENTERED_DISPLAY for move events Partially fixes the mouse cursor in UE5 editor. Imperfect because UE5 uses window position and global mouse state to get position, but of course we don't have global mouse and this is just to get the right display index so this still fails overall. We really need to make global mouse support a feature query...
Frank Praznik 4d1905c9 2022-03-29T13:34:14 video: wayland: Use viewports for non-fullscreen windows with fractional scaling Use viewports for non-fullscreen windows when the desktop uses fractional scaling and the window is flagged as DPI-aware to provide a backbuffer mapped as close to 1:1 output as possible. In the cases of odd window sizes the backbuffer may be a pixel off of scaling perfectly into the window size due to its scaled size being rounded off, but a minute amount of scaling during output is likely preferable to the large amounts of overdraw needed with integer scaled buffers.
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.
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.
Simon McVittie b4d28085 2022-03-24T18:30:32 wayland: Don't overwrite error message from SDL_EGL_CreateSurface SDL_EGL_CreateSurface sets a more specific error message, so overwriting it would lose information. Signed-off-by: Simon McVittie <smcv@collabora.com>
Cameron Gutman 77a9ca6b 2022-01-26T18:26:07 wayland: Fix SDL_SetWindowSize() being dropped right after exiting fullscreen If we get a SDL_SetWindowSize() call right after SDL_SetWindowFullscreen() but before we've gotten a new configure event from the compositor, the attempt to set our window size will silently fail (when libdecor is enabled). Fix this by remembering that we need to commit a new size, so we can do that in decoration_frame_configure().
Ethan Lee 68a71f91 2022-01-25T11:18:04 wayland: Try to avoid committing before the window is shown
Ethan Lee f0e768da 2022-01-25T13:07:00 wayland: Call SetFullscreen directly in ShowWindow. This cuts out an extra flush when getting the first configure event.
Ethan Lee e2d74bcb 2022-01-25T11:16:09 wayland: Detach hidden surfaces in HideWindow, not ShowWindow
Ethan Lee e1b4761c 2022-01-20T14:10:56 wayland: Avoid calling SetFullscreen in libdecor ShowWindow. This caused some weird stuff to happen in the libdecor path, probably because the window hasn't actually been mapped yet. It ends up calling stuff that should not yet apply, and so fullscreen in particular would have a really messed up titlebar. The good news is, libdecor is good about tracking fullscreen state, so we can let the callback do this for us. Keep this for xdg_shell because we actually map the window ourselves, so we know this call is valid for that path.
Ethan Lee ed3442d7 2022-01-19T15:47:52 wayland: Fix building with SDL_OPENGL=OFF
Cameron Gutman d3952a8a 2022-01-16T15:14:33 wayland: Avoid spurious resize events
Sam Lantinga 120c76c8 2022-01-03T09:40:00 Updated copyright for 2022
Ethan Lee 4c9966ee 2021-12-16T10:22:27 wayland: Add a note for why we check 0,0 for fullscreen configurations
David Gow a709b5b6 2021-12-04T14:14:47 video: wayland: Handle 0x0 xdg_toplevel_configure in fullscreen The xdg_shell spec seems to state[1] that xdg_toplevel_configure events can always provide a 0×0 width/height to signal that the compositor doesn't care. SDL previously assumed the provided width/height was always valid for fullscreen windows, and so applied it as-is. This broke SDL applications on KDE/KWin 5.23, which now sends 0×0 configure events (and, in 5.23.3, 1×1 events for some reason), breaking all SDL applications in fullscreen[2]. [1]: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/issues/6 [2]: https://bugs.kde.org/show_bug.cgi?id=444962#c6
Ethan Lee 63ae103c 2021-11-11T13:16:34 wayland: QTWAYLAND_CONTENT_ORIENTATION can support multiple values as bitmasks
Ethan Lee ae67c7d2 2021-11-09T01:30:00 Implemented SDL_SetWindowMouseRect() on Wayland
Väinö Mäkelä ad520573 2021-10-06T09:52:06 wayland: Only dispatch frame events in Wayland_GLES_SwapWindow Dispatching all events in Wayland_GLES_SwapWindow leads to resizes being acked before the program has a chance to handle the resize. This change reduces jumping on fullscreen transition with apps that call SDL_PollEvent before issuing any render calls.
Sam Lantinga 9672d581 2021-09-26T14:22:11 Need to check structure version before setting xdg_toplevel to NULL
Cacodemon345 b592e78f 2021-09-25T12:55:41 wayland: Expose xdg_toplevel to SysWM
Ethan Lee ae7ee2a5 2021-08-11T09:59:43 wayland: Ignore stateless/sizeless configs when starting in fullscreen mode
Ethan Lee 7be970db 2021-08-06T19:51:27 wayland: Avoid setting floating width/height when re-entering fullscreen
Ethan Lee 10979d37 2021-08-05T12:42:03 wayland: Always assume configure is wrong for non-resizable windows. Configure events from compositors have an extremely annoying habit of giving us completely bogus sizes, from all sorts of places. Thankfully, the protocol gives us the ability to completely ignore the width/height and just stick with what we know, so for all windows that are not meant to be resized, pretend we never even got the width/height at all, the compositor is required to respect our dimensions whether they match configure's suggestion or not.
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 7082fb04 2021-08-02T22:42:28 wayland: Only dispatch on fullscreen set when the window is visible. Fixes hang-on-startup described in #4572.
Ethan Lee 0f5b8a99 2021-08-02T19:48:31 wayland: For libdecor, dispatch immediately after setting fullscreen Reference: #4578
Ethan Lee 4562da62 2021-08-02T16:40:56 wayland: Make libdecor configure match xdg_toplevel
Ethan Lee 1fb1aa19 2021-08-02T12:57:28 wayland: Keep the fullscreen check for maximize/restore events
Ethan Lee 584673a5 2021-08-02T12:51:23 wayland: Don't ignore configs for non-fullscreen, non-resizable windows. This was causing configure events to not inform SDL of window size changes, even when they were based on resizes that we fully expected. The result was fullscreen->windowed not working at all, because it would retain the desktop resolution instead of reverting to the floating size that it had before moving to fullscreen mode. Fixes Super Hexagon fullscreen toggling.
Sebastian Krzyszkowiak 25067298 2021-08-02T08:15:10 wayland: Flush in SetWindowFullscreen The flush has been removed in e5f9fae034df8ca305241c5a666e7702fcf9958f. Unfortunately, even though ideally the flush shouldn't be necessary, our resize sequence isn't... well, perfect, and removing that flush causes tons of troubles. We're also still flushing in other paths where the window size can be changed by the compositor and where we may potentially have to obey that change, like in Wayland_MaximizeWindow. This also removes the hack introduced in 7f261d3b7667978ced93a4fdc6aec2380df3d87f, which introduces problems with protocol violations and seems to not be necessary when flushing.
Sebastian Krzyszkowiak ea28187c 2021-08-02T08:07:23 wayland: Hack surface resize into compliance with set_window_geometry We have issues with correct resize sequence and happen to commit old-sized buffers even after configure event for the new size has been already acknowledged. While the reason for that stays unknown, let's at least workaround the problem by faking window geometry into expected size. This does not fix visual glitch on e.g. fullscreen toggling, but having a split-second glitch is still a much better outcome than being terminated by the compositor for protocol violation.
Sebastian Krzyszkowiak b5210cac 2021-08-02T13:47:32 wayland: Initialize floating size at window creation This allows the windowed size to be restored for windows initially created already in non-floating state.
Ethan Lee dab33844 2021-08-02T11:58:47 wayland: Fix a warning in handle_configure_xdg_toplevel
Ethan Lee 754aa2d3 2021-08-02T11:55:02 Mostly revert cfcdfb7be9f5c97a51ddef9ad3677a604856266b. This was causing window changes to completely break, resulting in broken decorations and bizarre frame timing, I don't know what exactly it's doing but it's not good. Kept the libdecor_frame_is_floating logic, at least.
Ethan Lee 8803589f 2021-08-02T12:05:06 wayland: Avoid redundant SetWindowBordered for libdecor
Sebastian Krzyszkowiak b4c4060a 2021-08-02T04:52:25 wayland: Clean up Wayland_HandlePendingResize Commit 871c11191bfc7214061a3da37c112522a102ddf5 removed delayed resize handling, but it left the whole structure untouched that now became unnecessary. To help with code clarity, get rid of the structure where pending resize state used to be stored and pass all the data directly to Wayland_HandlePendingResize (now renamed to Wayland_HandleResize, since it's not "pending" anymore but applied immediately)
Sebastian Krzyszkowiak 9bb24ad0 2021-08-02T05:49:35 wayland: Always call Wayland_SetWindowBordered when showing the window Otherwise our windows have no window decoration on compositors that support xdg-decoration-unstable-v1, but default to client-side mode. Contrary to what the comment was stating, there is nothing in the protocol that would make redundant calls to zxdg_toplevel_decoration_v1::set_mode problematic.
Christian Rauch cfcdfb7b 2021-08-01T18:14:53 libdecor: use same fullscreen/maximised restore logic as for xdg-toplevel
Christian Rauch 42452f8c 2021-08-01T13:51:30 wayland: store and restore floating states Some Wayland compositors send (0,0) as "suggested" configure event sizes to indicate that the client has to decide on its own which sizes to used. This is commonly done when restoring from maximised, fullscreen or tiles states to fullscreen. We now store the last known floating states in a new set of variables and restore them when we receive such a (0,0) configure event.
Ethan Lee 71897cc1 2021-07-30T15:51:43 wayland: Always trigger a resize when handling a configure event. When we removed the OpenGL resize workaround it introduced a problem for fullscreen windows in particular: When leaving fullscreen we tried to send a resize event, but UpdateFullscreenMode would send a SIZE_CHANGED immediately after, deleting our resize event and causing the following configure event's resize to be ignored. This timing issue resulted in fullscreen windows not being resized at all when becoming a floating window. By always forcing resize events from configure events, we ensure that RESIZED always makes it through. SetWindowSize-type changes should be unaffected as they do not fire configure events.
Ethan Lee c20ab7da 2021-07-30T00:22:50 wayland: Fix GetWindowWMInfo for <2.0.15
Christian Rauch f20a8581 2021-07-29T00:13:17 commit after setting/unsetting limits
Ethan Lee ad310d39 2021-07-28T12:31:25 wayland: libdecor support for SetWindowModalFor
Ethan Lee 93976ade 2021-07-28T12:22:09 wayland: libdecor support for GetWindowWMInfo
David Gow 21cba924 2021-07-28T16:54:23 wayland: Don't create zxdg toplevel decoration twice Each window can have at most one zxdg toplevel decoration, but as of [1], we accidentally create two. (If libdecor is not in use). This causes wayland windows with server-side decorations (e.g. on KDE/KWin) to crash with the message: zxdg_decoration_manager_v1@7: error 1: decoration has been already constructed This extra zxdg_decoration_manager_v1.get_toplevel_decoration() call was introduced while deprecating wl-shell and xdg-shell-stable[1] support, and possibly was a bad interaction with [2], which moved the decoration creation around. Fixes: 6aae5b44f8 ("Remove wl-shell and xdg-shell-unstable-v6 support (#4323)") [1]: https://github.com/libsdl-org/SDL/pull/4323 [2]: https://github.com/libsdl-org/SDL/pull/4374
Ethan Lee 7b239edb 2021-07-28T01:00:00 wayland: Assign frame_callback on window creation. Fixes a crash when creating and destroying a window without calling SwapWindow.
Ethan Lee 03185e74 2021-07-27T18:35:00 wayland: Tag/Check wl_output objects as well, fixes crashes when libdecor is in use
Ryan C. Gordon 871c1119 2021-07-27T18:24:09 wayland: handle pending resizes immediately, not on SwapWindow. This was originally a workaround for an old Mesa bug, since fixed, apparently, and causes other problems. Fixes #4326.