Commit a7d345958d06567f34d11b6c8ddf504157b22ba4

Frank Praznik 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.

diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c
index 7abdcc4..9b8547c 100644
--- a/src/video/wayland/SDL_waylandwindow.c
+++ b/src/video/wayland/SDL_waylandwindow.c
@@ -1680,6 +1680,28 @@ Wayland_SetWindowFullscreen(_THIS, SDL_Window * window,
 
         /* Roundtrip required to receive the updated window dimensions */
         WAYLAND_wl_display_roundtrip(viddata->display);
+    } else if (wind->is_fullscreen) {
+        /*
+         * If the window is already fullscreen, this is likely a request to switch between
+         * fullscreen and fullscreen desktop, or to change the video mode. Update the
+         * geometry and trigger a commit.
+         */
+        ConfigureWindowGeometry(window);
+
+#ifdef HAVE_LIBDECOR_H
+        if (WINDOW_IS_LIBDECOR(data, window) && wind->shell_surface.libdecor.frame) {
+            struct libdecor_state *state = libdecor_state_new(GetWindowWidth(window), GetWindowHeight(window));
+            libdecor_frame_commit(wind->shell_surface.libdecor.frame, state, NULL);
+            libdecor_state_free(state);
+        } else
+#endif
+        if(viddata->shell.xdg && wind->shell_surface.xdg.surface) {
+            xdg_surface_set_window_geometry(wind->shell_surface.xdg.surface, 0, 0,
+                                            GetWindowWidth(window), GetWindowHeight(window));
+        }
+
+        /* Roundtrip required to receive the updated window dimensions */
+        WAYLAND_wl_display_roundtrip(viddata->display);
     }
 }