Blame SOURCES/0004-wayland-Avoid-calling-SetFullscreen-in-libdecor-Show.patch

e54a86
From e1b4761c621e9883c3f02971ea74cef14b1d6b87 Mon Sep 17 00:00:00 2001
e54a86
From: Ethan Lee <flibitijibibo@gmail.com>
e54a86
Date: Thu, 20 Jan 2022 14:10:56 -0500
e54a86
Subject: [PATCH 04/11] wayland: Avoid calling SetFullscreen in libdecor
e54a86
 ShowWindow.
e54a86
e54a86
This caused some weird stuff to happen in the libdecor path, probably because
e54a86
the window hasn't actually been mapped yet. It ends up calling stuff that
e54a86
should not yet apply, and so fullscreen in particular would have a really
e54a86
messed up titlebar.
e54a86
e54a86
The good news is, libdecor is good about tracking fullscreen state, so we can
e54a86
let the callback do this for us. Keep this for xdg_shell because we actually
e54a86
map the window ourselves, so we know this call is valid for that path.
e54a86
---
e54a86
 src/video/wayland/SDL_waylandwindow.c | 8 ++++++--
e54a86
 1 file changed, 6 insertions(+), 2 deletions(-)
e54a86
e54a86
diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c
e54a86
index 80bb66878..3b21af7be 100644
e54a86
--- a/src/video/wayland/SDL_waylandwindow.c
e54a86
+++ b/src/video/wayland/SDL_waylandwindow.c
e54a86
@@ -724,7 +724,6 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window)
e54a86
 {
e54a86
     SDL_VideoData *c = _this->driverdata;
e54a86
     SDL_WindowData *data = window->driverdata;
e54a86
-    SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
e54a86
 
e54a86
     /* Detach any previous buffers before resetting everything, otherwise when
e54a86
      * calling this a second time you'll get an annoying protocol error
e54a86
@@ -766,7 +765,6 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window)
e54a86
     if (window->flags & SDL_WINDOW_MINIMIZED) {
e54a86
         Wayland_MinimizeWindow(_this, window);
e54a86
     }
e54a86
-    Wayland_SetWindowFullscreen(_this, window, display, (window->flags & SDL_WINDOW_FULLSCREEN) != 0);
e54a86
 
e54a86
     /* We have to wait until the surface gets a "configure" event, or use of
e54a86
      * this surface will fail. This is a new rule for xdg_shell.
e54a86
@@ -782,6 +780,12 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window)
e54a86
     } else
e54a86
 #endif
e54a86
     if (c->shell.xdg) {
e54a86
+        /* Unlike libdecor we need to call this explicitly to prevent a deadlock.
e54a86
+         * libdecor will call this as part of their configure event!
e54a86
+         * -flibit
e54a86
+         */
e54a86
+        Wayland_SetWindowFullscreen(_this, window, SDL_GetDisplayForWindow(window),
e54a86
+                                    (window->flags & SDL_WINDOW_FULLSCREEN) != 0);
e54a86
         if (data->shell_surface.xdg.surface) {
e54a86
             while (!data->shell_surface.xdg.initial_configure_seen) {
e54a86
                 WAYLAND_wl_display_flush(c->display);
e54a86
-- 
e54a86
2.34.1
e54a86