SDL: wayland: Refactor internal variable names for better readability

From b97cda226fb531484b22c3ef10ae543b7bb52667 Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Wed, 24 Jan 2024 10:45:19 -0500
Subject: [PATCH] wayland: Refactor internal variable names for better
 readability

Add descriptions in the internal window struct as well.
---
 src/video/wayland/SDL_waylandevents.c |  36 ++--
 src/video/wayland/SDL_waylandwindow.c | 242 +++++++++++++-------------
 src/video/wayland/SDL_waylandwindow.h |  60 +++++--
 3 files changed, 189 insertions(+), 149 deletions(-)

diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c
index 5028bc1116b4..e0b44084da7d 100644
--- a/src/video/wayland/SDL_waylandevents.c
+++ b/src/video/wayland/SDL_waylandevents.c
@@ -501,14 +501,14 @@ static void pointer_handle_motion(void *data, struct wl_pointer *pointer,
     input->sx_w = sx_w;
     input->sy_w = sy_w;
     if (input->pointer_focus) {
-        float sx = (float)(wl_fixed_to_double(sx_w) * window_data->pointer_scale_x);
-        float sy = (float)(wl_fixed_to_double(sy_w) * window_data->pointer_scale_y);
+        float sx = (float)(wl_fixed_to_double(sx_w) * window_data->pointer_scale.x);
+        float sy = (float)(wl_fixed_to_double(sy_w) * window_data->pointer_scale.y);
         SDL_SendMouseMotion(Wayland_GetPointerTimestamp(input, time), window_data->sdlwindow, 0, 0, sx, sy);
     }
 
     if (window && window->hit_test) {
-        const SDL_Point point = { (int)SDL_floor(wl_fixed_to_double(sx_w) * window_data->pointer_scale_x),
-                                  (int)SDL_floor(wl_fixed_to_double(sy_w) * window_data->pointer_scale_y) };
+        const SDL_Point point = { (int)SDL_floor(wl_fixed_to_double(sx_w) * window_data->pointer_scale.x),
+                                  (int)SDL_floor(wl_fixed_to_double(sy_w) * window_data->pointer_scale.y) };
         SDL_HitTestResult rc = window->hit_test(window, &point, window->hit_test_data);
         if (rc == window_data->hit_test_result) {
             return;
@@ -978,15 +978,15 @@ static void touch_handler_down(void *data, struct wl_touch *touch, uint32_t seri
     if (window_data) {
         float x, y;
 
-        if (window_data->wl_window_width <= 1) {
+        if (window_data->current.logical_width <= 1) {
             x = 0.5f;
         } else {
-            x = wl_fixed_to_double(fx) / (window_data->wl_window_width - 1);
+            x = wl_fixed_to_double(fx) / (window_data->current.logical_width - 1);
         }
-        if (window_data->wl_window_height <= 1) {
+        if (window_data->current.logical_height <= 1) {
             y = 0.5f;
         } else {
-            y = wl_fixed_to_double(fy) / (window_data->wl_window_height - 1);
+            y = wl_fixed_to_double(fy) / (window_data->current.logical_height - 1);
         }
 
         SDL_SetMouseFocus(window_data->sdlwindow);
@@ -1009,8 +1009,8 @@ static void touch_handler_up(void *data, struct wl_touch *touch, uint32_t serial
         SDL_WindowData *window_data = (SDL_WindowData *)wl_surface_get_user_data(surface);
 
         if (window_data) {
-            const float x = wl_fixed_to_double(fx) / window_data->wl_window_width;
-            const float y = wl_fixed_to_double(fy) / window_data->wl_window_height;
+            const float x = wl_fixed_to_double(fx) / window_data->current.logical_width;
+            const float y = wl_fixed_to_double(fy) / window_data->current.logical_height;
 
             SDL_SendTouch(Wayland_GetTouchTimestamp(input, timestamp), (SDL_TouchID)(uintptr_t)touch,
                           (SDL_FingerID)(id + 1), window_data->sdlwindow, SDL_FALSE, x, y, 0.0f);
@@ -1038,8 +1038,8 @@ static void touch_handler_motion(void *data, struct wl_touch *touch, uint32_t ti
         SDL_WindowData *window_data = (SDL_WindowData *)wl_surface_get_user_data(surface);
 
         if (window_data) {
-            const float x = wl_fixed_to_double(fx) / window_data->wl_window_width;
-            const float y = wl_fixed_to_double(fy) / window_data->wl_window_height;
+            const float x = wl_fixed_to_double(fx) / window_data->current.logical_width;
+            const float y = wl_fixed_to_double(fy) / window_data->current.logical_height;
 
             SDL_SendTouchMotion(Wayland_GetPointerTimestamp(input, timestamp), (SDL_TouchID)(uintptr_t)touch,
                                 (SDL_FingerID)(id + 1), window_data->sdlwindow, x, y, 1.0f);
@@ -2642,8 +2642,8 @@ static void tablet_tool_handle_motion(void *data, struct zwp_tablet_tool_v2 *too
     if (input->tool_focus) {
         const float sx_f = (float)wl_fixed_to_double(sx_w);
         const float sy_f = (float)wl_fixed_to_double(sy_w);
-        const float sx = sx_f * window->pointer_scale_x;
-        const float sy = sy_f * window->pointer_scale_y;
+        const float sx = sx_f * window->pointer_scale.x;
+        const float sy = sy_f * window->pointer_scale.y;
 
         if (penid != SDL_PEN_INVALID) {
             input->current_pen.update_status.x = sx;
@@ -3304,10 +3304,10 @@ int Wayland_input_confine_pointer(struct SDL_WaylandInput *input, SDL_Window *wi
     } else {
         SDL_Rect scaled_mouse_rect;
 
-        scaled_mouse_rect.x = (int)SDL_floorf((float)window->mouse_rect.x / w->pointer_scale_x);
-        scaled_mouse_rect.y = (int)SDL_floorf((float)window->mouse_rect.y / w->pointer_scale_y);
-        scaled_mouse_rect.w = (int)SDL_ceilf((float)window->mouse_rect.w / w->pointer_scale_x);
-        scaled_mouse_rect.h = (int)SDL_ceilf((float)window->mouse_rect.h / w->pointer_scale_y);
+        scaled_mouse_rect.x = (int)SDL_floorf((float)window->mouse_rect.x / w->pointer_scale.x);
+        scaled_mouse_rect.y = (int)SDL_floorf((float)window->mouse_rect.y / w->pointer_scale.y);
+        scaled_mouse_rect.w = (int)SDL_ceilf((float)window->mouse_rect.w / w->pointer_scale.x);
+        scaled_mouse_rect.h = (int)SDL_ceilf((float)window->mouse_rect.h / w->pointer_scale.y);
 
         confine_rect = wl_compositor_create_region(d->compositor);
         wl_region_add(confine_rect,
diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c
index ba7b0bb73f20..fb69334223d9 100644
--- a/src/video/wayland/SDL_waylandwindow.c
+++ b/src/video/wayland/SDL_waylandwindow.c
@@ -129,7 +129,7 @@ static SDL_bool WindowNeedsViewport(SDL_Window *window)
         if (SurfaceScaleIsFractional(window) || wind->scale_to_display) {
             return SDL_TRUE;
         } else if (window->fullscreen_exclusive) {
-            if (window->current_fullscreen_mode.w != wind->requested_window_width || window->current_fullscreen_mode.h != wind->requested_window_height) {
+            if (window->current_fullscreen_mode.w != wind->requested.width || window->current_fullscreen_mode.h != wind->requested.height) {
                 return SDL_TRUE;
             }
         }
@@ -150,11 +150,11 @@ static void GetBufferSize(SDL_Window *window, int *width, int *height)
         buf_height = window->current_fullscreen_mode.h;
     } else if (!data->scale_to_display) {
         /* Round fractional backbuffer sizes halfway away from zero. */
-        buf_width = PointToPixel(window, data->requested_window_width);
-        buf_height = PointToPixel(window, data->requested_window_height);
+        buf_width = PointToPixel(window, data->requested.width);
+        buf_height = PointToPixel(window, data->requested.height);
     } else {
-        buf_width = data->requested_window_width;
-        buf_height = data->requested_window_height;
+        buf_width = data->requested.width;
+        buf_height = data->requested.height;
     }
 
     if (width) {
@@ -201,8 +201,8 @@ static void SetMinMaxDimensions(SDL_Window *window)
         max_width = 0;
         max_height = 0;
     } else if (window->flags & SDL_WINDOW_RESIZABLE) {
-        int adj_w = SDL_max(window->min_w, wind->system_min_required_width);
-        int adj_h = SDL_max(window->min_h, wind->system_min_required_height);
+        int adj_w = SDL_max(window->min_w, wind->system_limits.min_width);
+        int adj_h = SDL_max(window->min_h, wind->system_limits.min_height);
         if (wind->scale_to_display) {
             adj_w = PixelToPoint(window, adj_w);
             adj_h = PixelToPoint(window, adj_h);
@@ -210,8 +210,8 @@ static void SetMinMaxDimensions(SDL_Window *window)
         min_width = adj_w;
         min_height = adj_h;
 
-        adj_w = window->max_w ? SDL_max(window->max_w, wind->system_min_required_width) : 0;
-        adj_h = window->max_h ? SDL_max(window->max_h, wind->system_min_required_height) : 0;
+        adj_w = window->max_w ? SDL_max(window->max_w, wind->system_limits.min_width) : 0;
+        adj_h = window->max_h ? SDL_max(window->max_h, wind->system_limits.min_height) : 0;
         if (wind->scale_to_display) {
             adj_w = PixelToPoint(window, adj_w);
             adj_h = PixelToPoint(window, adj_h);
@@ -219,10 +219,10 @@ static void SetMinMaxDimensions(SDL_Window *window)
         max_width = adj_w;
         max_height = adj_h;
     } else {
-        min_width = wind->wl_window_width;
-        min_height = wind->wl_window_height;
-        max_width = wind->wl_window_width;
-        max_height = wind->wl_window_height;
+        min_width = wind->current.logical_width;
+        min_height = wind->current.logical_height;
+        max_width = wind->current.logical_width;
+        max_height = wind->current.logical_height;
     }
 
 #ifdef HAVE_LIBDECOR_H
@@ -323,8 +323,8 @@ static void RepositionPopup(SDL_Window *window, SDL_bool use_current_position)
             y = PixelToPoint(window->parent, y);
         }
         AdjustPopupOffset(window, &x, &y);
-        xdg_positioner_set_anchor_rect(wind->shell_surface.xdg.roleobj.popup.positioner, 0, 0, window->parent->driverdata->wl_window_width, window->parent->driverdata->wl_window_height);
-        xdg_positioner_set_size(wind->shell_surface.xdg.roleobj.popup.positioner, wind->wl_window_width, wind->wl_window_height);
+        xdg_positioner_set_anchor_rect(wind->shell_surface.xdg.roleobj.popup.positioner, 0, 0, window->parent->driverdata->current.logical_width, window->parent->driverdata->current.logical_height);
+        xdg_positioner_set_size(wind->shell_surface.xdg.roleobj.popup.positioner, wind->current.logical_width, wind->current.logical_height);
         xdg_positioner_set_offset(wind->shell_surface.xdg.roleobj.popup.positioner, x, y);
         xdg_popup_reposition(wind->shell_surface.xdg.roleobj.popup.popup,
                              wind->shell_surface.xdg.roleobj.popup.positioner,
@@ -336,20 +336,20 @@ static void ConfigureWindowGeometry(SDL_Window *window)
 {
     SDL_WindowData *data = window->driverdata;
     SDL_VideoData *viddata = data->waylandData;
-    const int old_dw = data->drawable_width;
-    const int old_dh = data->drawable_height;
+    const int old_dw = data->current.drawable_width;
+    const int old_dh = data->current.drawable_height;
     int window_width, window_height;
     SDL_bool window_size_changed;
     SDL_bool drawable_size_changed;
 
     /* Set the drawable backbuffer size. */
-    GetBufferSize(window, &data->drawable_width, &data->drawable_height);
-    drawable_size_changed = data->drawable_width != old_dw || data->drawable_height != old_dh;
+    GetBufferSize(window, &data->current.drawable_width, &data->current.drawable_height);
+    drawable_size_changed = data->current.drawable_width != old_dw || data->current.drawable_height != old_dh;
 
     if (data->egl_window && drawable_size_changed) {
         WAYLAND_wl_egl_window_resize(data->egl_window,
-                                     data->drawable_width,
-                                     data->drawable_height,
+                                     data->current.drawable_width,
+                                     data->current.drawable_height,
                                      0, 0);
     }
 
@@ -360,11 +360,11 @@ static void ConfigureWindowGeometry(SDL_Window *window)
         window_height = window->current_fullscreen_mode.h;
 
         if (!data->scale_to_display) {
-            output_width = data->requested_window_width;
-            output_height = data->requested_window_height;
+            output_width = data->requested.width;
+            output_height = data->requested.height;
         } else {
-            output_width = data->requested_logical_width;
-            output_height = data->requested_logical_height;
+            output_width = data->requested.logical_width;
+            output_height = data->requested.logical_height;
         }
 
         switch (GetModeScaleMethod()) {
@@ -396,17 +396,17 @@ static void ConfigureWindowGeometry(SDL_Window *window)
         }
 
         window_size_changed = window_width != window->w || window_height != window->h ||
-            data->wl_window_width != output_width || data->wl_window_height != output_height;
+            data->current.logical_width != output_width || data->current.logical_height != output_height;
 
         if (window_size_changed || drawable_size_changed) {
             if (WindowNeedsViewport(window)) {
                 /* Set the buffer scale to 1 since a viewport will be used. */
                 wl_surface_set_buffer_scale(data->surface, 1);
-                SetDrawSurfaceViewport(window, data->drawable_width, data->drawable_height,
+                SetDrawSurfaceViewport(window, data->current.drawable_width, data->current.drawable_height,
                                        output_width, output_height);
 
-                data->wl_window_width = output_width;
-                data->wl_window_height = output_height;
+                data->current.logical_width = output_width;
+                data->current.logical_height = output_height;
             } else {
                 /* Calculate the integer scale from the mode and output. */
                 const int32_t int_scale = SDL_max(window->current_fullscreen_mode.w / output_width, 1);
@@ -414,28 +414,28 @@ static void ConfigureWindowGeometry(SDL_Window *window)
                 UnsetDrawSurfaceViewport(window);
                 wl_surface_set_buffer_scale(data->surface, int_scale);
 
-                data->wl_window_width = window->current_fullscreen_mode.w;
-                data->wl_window_height = window->current_fullscreen_mode.h;
+                data->current.logical_width = window->current_fullscreen_mode.w;
+                data->current.logical_height = window->current_fullscreen_mode.h;
             }
 
-            data->pointer_scale_x = (float)window_width / (float)data->wl_window_width;
-            data->pointer_scale_y = (float)window_height / (float)data->wl_window_height;
+            data->pointer_scale.x = (float)window_width / (float)data->current.logical_width;
+            data->pointer_scale.y = (float)window_height / (float)data->current.logical_height;
         }
     } else {
         if (!data->scale_to_display) {
-            window_width = data->requested_window_width;
-            window_height = data->requested_window_height;
+            window_width = data->requested.width;
+            window_height = data->requested.height;
         } else {
-            window_width = data->requested_logical_width;
-            window_height = data->requested_logical_height;
+            window_width = data->requested.logical_width;
+            window_height = data->requested.logical_height;
         }
 
-        window_size_changed = window_width != data->wl_window_width || window_height != data->wl_window_height;
+        window_size_changed = window_width != data->current.logical_width || window_height != data->current.logical_height;
 
         if (window_size_changed || drawable_size_changed) {
             if (WindowNeedsViewport(window)) {
                 wl_surface_set_buffer_scale(data->surface, 1);
-                SetDrawSurfaceViewport(window, data->drawable_width, data->drawable_height,
+                SetDrawSurfaceViewport(window, data->current.drawable_width, data->current.drawable_height,
                                        window_width, window_height);
             } else if ((window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) || data->scale_to_display) {
                 UnsetDrawSurfaceViewport(window);
@@ -445,15 +445,15 @@ static void ConfigureWindowGeometry(SDL_Window *window)
             }
 
             /* Clamp the physical window size to the system minimum required size. */
-            data->wl_window_width = SDL_max(window_width, data->system_min_required_width);
-            data->wl_window_height = SDL_max(window_height, data->system_min_required_height);
+            data->current.logical_width = SDL_max(window_width, data->system_limits.min_width);
+            data->current.logical_height = SDL_max(window_height, data->system_limits.min_height);
 
             if (!data->scale_to_display) {
-                data->pointer_scale_x = 1.0f;
-                data->pointer_scale_y = 1.0f;
+                data->pointer_scale.x = 1.0f;
+                data->pointer_scale.y = 1.0f;
             } else {
-                data->pointer_scale_x = data->windowed_scale_factor;
-                data->pointer_scale_y = data->windowed_scale_factor;
+                data->pointer_scale.x = data->windowed_scale_factor;
+                data->pointer_scale.y = data->windowed_scale_factor;
             }
         }
     }
@@ -467,13 +467,13 @@ static void ConfigureWindowGeometry(SDL_Window *window)
 
         /* libdecor does this internally on frame commits, so it's only needed for xdg surfaces. */
         if (data->shell_surface_type != WAYLAND_SURFACE_LIBDECOR && data->shell_surface.xdg.surface) {
-            xdg_surface_set_window_geometry(data->shell_surface.xdg.surface, 0, 0, data->wl_window_width, data->wl_window_height);
+            xdg_surface_set_window_geometry(data->shell_surface.xdg.surface, 0, 0, data->current.logical_width, data->current.logical_height);
         }
 
         if (!(window->flags & SDL_WINDOW_TRANSPARENT)) {
             region = wl_compositor_create_region(viddata->compositor);
             wl_region_add(region, 0, 0,
-                          data->wl_window_width, data->wl_window_height);
+                          data->current.logical_width, data->current.logical_height);
             wl_surface_set_opaque_region(data->surface, region);
             wl_region_destroy(region);
         }
@@ -497,9 +497,9 @@ static void ConfigureWindowGeometry(SDL_Window *window)
     if (!data->scale_to_display) {
         SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, window_width, window_height);
     } else {
-        SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, data->drawable_width, data->drawable_height);
+        SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, data->current.drawable_width, data->current.drawable_height);
     }
-    SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED, data->drawable_width, data->drawable_height);
+    SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED, data->current.drawable_width, data->current.drawable_height);
 
     /* Send an exposure event if the window is in the shown state and the size has changed,
      * even if the window is occluded, as the client needs to commit a new frame for the
@@ -525,7 +525,7 @@ static void CommitLibdecorFrame(SDL_Window *window)
     SDL_WindowData *wind = window->driverdata;
 
     if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR && wind->shell_surface.libdecor.frame) {
-        struct libdecor_state *state = libdecor_state_new(wind->wl_window_width, wind->wl_window_height);
+        struct libdecor_state *state = libdecor_state_new(wind->current.logical_width, wind->current.logical_height);
         libdecor_frame_commit(wind->shell_surface.libdecor.frame, state, NULL);
         libdecor_state_free(state);
     }
@@ -646,10 +646,10 @@ static void surface_frame_done(void *data, struct wl_callback *cb, uint32_t time
      */
     if (wl_compositor_get_version(wind->waylandData->compositor) >= WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION) {
         wl_surface_damage_buffer(wind->surface, 0, 0,
-                                 wind->drawable_width, wind->drawable_height);
+                                 wind->current.drawable_width, wind->current.drawable_height);
     } else {
         wl_surface_damage(wind->surface, 0, 0,
-                          wind->wl_window_width, wind->wl_window_height);
+                          wind->current.logical_width, wind->current.logical_height);
     }
 
     if (wind->surface_status == WAYLAND_SURFACE_STATUS_WAITING_FOR_FRAME) {
@@ -787,19 +787,19 @@ static void handle_configure_xdg_toplevel(void *data,
                  */
                 width = window->floating.w;
                 height = window->floating.h;
-                wind->requested_logical_width = PixelToPoint(window, width);
-                wind->requested_logical_height = PixelToPoint(window, height);
+                wind->requested.logical_width = PixelToPoint(window, width);
+                wind->requested.logical_height = PixelToPoint(window, height);
             } else if (wind->scale_to_display) {
                 /* Don't convert if the size hasn't changed to avoid rounding errors. */
-                if (width != wind->wl_window_width || height != wind->wl_window_height) {
+                if (width != wind->current.logical_width || height != wind->current.logical_height) {
                     /* Initially assume that the compositor is telling us exactly what size the logical window size must be. */
-                    wind->requested_logical_width = width;
-                    wind->requested_logical_height = height;
+                    wind->requested.logical_width = width;
+                    wind->requested.logical_height = height;
                     width = PointToPixel(window, width);
                     height = PointToPixel(window, height);
                 } else {
-                    width = wind->requested_window_width;
-                    height = wind->requested_window_height;
+                    width = wind->requested.width;
+                    height = wind->requested.height;
                 }
             }
         } else {
@@ -808,8 +808,8 @@ static void handle_configure_xdg_toplevel(void *data,
              */
             width = window->floating.w;
             height = window->floating.h;
-            wind->requested_logical_width = PixelToPoint(window, width);
-            wind->requested_logical_height = PixelToPoint(window, height);
+            wind->requested.logical_width = PixelToPoint(window, width);
+            wind->requested.logical_height = PixelToPoint(window, height);
         }
 
         /* The content limits are only a hint, which the compositor is free to ignore,
@@ -829,17 +829,17 @@ static void handle_configure_xdg_toplevel(void *data,
             }
             height = SDL_max(height, window->min_h);
 
-            wind->requested_logical_width = PixelToPoint(window, width);
-            wind->requested_logical_height = PixelToPoint(window, height);
+            wind->requested.logical_width = PixelToPoint(window, width);
+            wind->requested.logical_height = PixelToPoint(window, height);
         }
     } else {
         /* Fullscreen windows know their exact size. */
         if (width == 0 || height == 0) {
-            width = wind->requested_window_width;
-            height = wind->requested_window_height;
+            width = wind->requested.width;
+            height = wind->requested.height;
         } else if (wind->scale_to_display) {
-            wind->requested_logical_width = width;
-            wind->requested_logical_height = height;
+            wind->requested.logical_width = width;
+            wind->requested.logical_height = height;
             width = PointToPixel(window, width);
             height = PointToPixel(window, height);
         }
@@ -848,13 +848,13 @@ static void handle_configure_xdg_toplevel(void *data,
     /* Don't update the dimensions if they haven't changed, or they could overwrite
      * a new size set programmatically with old dimensions.
      */
-    if (width != wind->last_configure_width || height != wind->last_configure_height) {
-        wind->requested_window_width = width;
-        wind->requested_window_height = height;
+    if (width != wind->last_configure.width || height != wind->last_configure.height) {
+        wind->requested.width = width;
+        wind->requested.height = height;
     }
 
-    wind->last_configure_width = width;
-    wind->last_configure_height = height;
+    wind->last_configure.width = width;
+    wind->last_configure.height = height;
     wind->floating = floating;
     wind->suspended = suspended;
     wind->active = active;
@@ -914,8 +914,8 @@ static void handle_configure_xdg_popup(void *data,
         height = PointToPixel(wind->sdlwindow, height);
     }
 
-    wind->requested_window_width = width;
-    wind->requested_window_height = height;
+    wind->requested.width = width;
+    wind->requested.height = height;
 
     SDL_SendWindowEvent(wind->sdlwindow, SDL_EVENT_WINDOW_MOVED, x, y);
 
@@ -1085,12 +1085,12 @@ static void decoration_frame_configure(struct libdecor_frame *frame,
          * told to do this.
          */
         if (!libdecor_configuration_get_content_size(configuration, frame, &width, &height)) {
-            width = wind->requested_window_width;
-            height = wind->requested_window_height;
+            width = wind->requested.width;
+            height = wind->requested.height;
         } else if (wind->scale_to_display) {
             /* Fullscreen windows know their exact size. */
-            wind->requested_logical_width = width;
-            wind->requested_logical_height = height;
+            wind->requested.logical_width = width;
+            wind->requested.logical_height = height;
             width = PointToPixel(window, width);
             height = PointToPixel(window, height);
         }
@@ -1100,8 +1100,8 @@ static void decoration_frame_configure(struct libdecor_frame *frame,
             width = window->floating.w;
             height = window->floating.h;
 
-            wind->requested_logical_width = PixelToPoint(window, width);
-            wind->requested_logical_height = PixelToPoint(window, height);
+            wind->requested.logical_width = PixelToPoint(window, width);
+            wind->requested.logical_height = PixelToPoint(window, height);
 
             OverrideLibdecorLimits(window);
         } else {
@@ -1132,18 +1132,18 @@ static void decoration_frame_configure(struct libdecor_frame *frame,
                     height = window->windowed.h;
                 }
 
-                wind->requested_logical_width = PixelToPoint(window, width);
-                wind->requested_logical_height = PixelToPoint(window, height);
+                wind->requested.logical_width = PixelToPoint(window, width);
+                wind->requested.logical_height = PixelToPoint(window, height);
             } else if (wind->scale_to_display) {
                 /* Don't convert if the size hasn't changed to avoid rounding errors. */
-                if (width != wind->wl_window_width || height != wind->wl_window_height) {
-                    wind->requested_logical_width = width;
-                    wind->requested_logical_height = height;
+                if (width != wind->current.logical_width || height != wind->current.logical_height) {
+                    wind->requested.logical_width = width;
+                    wind->requested.logical_height = height;
                     width = PointToPixel(window, width);
                     height = PointToPixel(window, height);
                 } else {
-                    width = wind->requested_window_width;
-                    height = wind->requested_window_height;
+                    width = wind->requested.width;
+                    height = wind->requested.height;
                 }
             }
         }
@@ -1165,22 +1165,22 @@ static void decoration_frame_configure(struct libdecor_frame *frame,
             }
             height = SDL_max(height, window->min_h);
 
-            wind->requested_logical_width = PixelToPoint(window, width);
-            wind->requested_logical_height = PixelToPoint(window, height);
+            wind->requested.logical_width = PixelToPoint(window, width);
+            wind->requested.logical_height = PixelToPoint(window, height);
         }
     }
 
     /* Don't update the dimensions if they haven't changed, or they could overwrite
      * a new size set programmatically with old dimensions.
      */
-    if (width != wind->last_configure_width || height != wind->last_configure_height) {
-        wind->requested_window_width = width;
-        wind->requested_window_height = height;
+    if (width != wind->last_configure.width || height != wind->last_configure.height) {
+        wind->requested.width = width;
+        wind->requested.height = height;
     }
 
     /* Store the new state. */
-    wind->last_configure_width = width;
-    wind->last_configure_height = height;
+    wind->last_configure.width = width;
+    wind->last_configure.height = height;
     wind->floating = floating;
     wind->suspended = suspended;
     wind->active = active;
@@ -1190,12 +1190,12 @@ static void decoration_frame_configure(struct libdecor_frame *frame,
     ConfigureWindowGeometry(window);
 
     /* ... then commit the changes on the libdecor side. */
-    state = libdecor_state_new(wind->wl_window_width, wind->wl_window_height);
+    state = libdecor_state_new(wind->current.logical_width, wind->current.logical_height);
     libdecor_frame_commit(frame, state, configuration);
     libdecor_state_free(state);
 
     if (!wind->shell_surface.libdecor.initial_configure_seen) {
-        LibdecorGetMinContentSize(frame, &wind->system_min_required_width, &wind->system_min_required_height);
+        LibdecorGetMinContentSize(frame, &wind->system_limits.min_width, &wind->system_limits.min_height);
         wind->shell_surface.libdecor.initial_configure_seen = SDL_TRUE;
     }
     if (wind->surface_status == WAYLAND_SURFACE_STATUS_WAITING_FOR_CONFIGURE) {
@@ -1255,11 +1255,11 @@ static void Wayland_HandlePreferredScaleChanged(SDL_WindowData *window_data, flo
              * the new backbuffer dimensions.
              */
             if (window_data->floating) {
-                window_data->requested_logical_width = PixelToPoint(window_data->sdlwindow, window_data->requested_window_width);
-                window_data->requested_logical_height = PixelToPoint(window_data->sdlwindow, window_data->requested_window_height);
+                window_data->requested.logical_width = PixelToPoint(window_data->sdlwindow, window_data->requested.width);
+                window_data->requested.logical_height = PixelToPoint(window_data->sdlwindow, window_data->requested.height);
             } else {
-                window_data->requested_window_width = PointToPixel(window_data->sdlwindow, window_data->requested_logical_width);
-                window_data->requested_window_height = PointToPixel(window_data->sdlwindow, window_data->requested_logical_height);
+                window_data->requested.width = PointToPixel(window_data->sdlwindow, window_data->requested.logical_width);
+                window_data->requested.height = PointToPixel(window_data->sdlwindow, window_data->requested.logical_height);
             }
         }
 
@@ -1623,11 +1623,11 @@ void Wayland_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window)
          

(Patch may be truncated, please check the link at the top of this post.)