Commit dfd7efaf13a72825179903646384033d136794ee

Frank Praznik 2022-12-05T15:33:01

wayland: Set xdg surface geometry It was previously thought that these function calls were unnecessary as the initial bug and reproduction case that necessitated their addition seemed to be fixed, but apparently there are still cases where this needs to be set explicitly. Set the xdg surface geometry at creation time and when the window size changes. Partially reverts #6361. This is not needed in the libdecor path, as libdecor calls this for the content surface internally. (cherry picked from commit 90a964f132c63b07cf85e5687041d214fdea60f6)

diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c
index 8c76abb..a6050e2 100644
--- a/src/video/wayland/SDL_waylandwindow.c
+++ b/src/video/wayland/SDL_waylandwindow.c
@@ -279,10 +279,16 @@ static void ConfigureWindowGeometry(SDL_Window *window)
     }
 
     /*
-     * The opaque and pointer confinement regions only need to be recalculated
-     * if the output size has changed.
+     * The surface geometry, opaque region and pointer confinement region only
+     * need to be recalculated if the output size has changed.
      */
     if (window_size_changed) {
+        /* libdecor does this internally on frame commits, so it's only needed for xdg surfaces. */
+        if (data->shell_surface_type != WAYLAND_SURFACE_LIBDECOR &&
+            viddata->shell.xdg && data->shell_surface.xdg.surface != NULL) {
+            xdg_surface_set_window_geometry(data->shell_surface.xdg.surface, 0, 0, data->window_width, data->window_height);
+        }
+
         if (!viddata->egl_transparency_enabled) {
             region = wl_compositor_create_region(viddata->compositor);
             wl_region_add(region, 0, 0,
@@ -1378,6 +1384,9 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window)
                                                      &decoration_listener,
                                                      window);
         }
+
+        /* Set the geometry */
+        xdg_surface_set_window_geometry(data->shell_surface.xdg.surface, 0, 0, data->window_width, data->window_height);
     } else {
         /* Nothing to see here, just commit. */
         wl_surface_commit(data->surface);