From c9b993f7b69d439f43cf82e08f3c2b78791e3bc7 Mon Sep 17 00:00:00 2001 From: Frank Praznik Date: Wed, 11 Mar 2026 20:38:26 -0400 Subject: [PATCH] wayland: Prevent the window from errantly growing when scale to display is used Some compositors will send a configure event immediately after a scale event, however, this event can contain the old logical size, and should be ignored, or the window will incorrectly change size when moved between displays with differing scale factors. Store the last requested logical size as the last configure size when resizing a floating window due to a scale change, so a configure event immediately following with the old size will be ignored. (cherry picked from commit 18219d5b53a7103152a961b135129a93f6dc4cc8) (cherry picked from commit 58c9c0ba7b79ad08484ec4ab40e411098ca6e1d1) --- src/video/wayland/SDL_waylandwindow.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c index 978e292c5a..0c88058456 100644 --- a/src/video/wayland/SDL_waylandwindow.c +++ b/src/video/wayland/SDL_waylandwindow.c @@ -1471,6 +1471,16 @@ static void Wayland_HandlePreferredScaleChanged(SDL_WindowData *window_data, dou * the new backbuffer dimensions. */ if (window_data->floating) { + /* Some compositors will send a configure event immediately after a scale event, however, + * this event can contain the old logical size, and should be ignored, or the window can + * incorrectly change size when moved between displays with differing scale factors. + * + * Store the last requested logical size as the last configure size, so a configure event + * with the old size will be ignored. + */ + window_data->last_configure.width = window_data->requested.logical_width; + window_data->last_configure.height = window_data->requested.logical_height; + window_data->requested.logical_width = PixelToPoint(window_data->sdlwindow, window_data->requested.pixel_width); window_data->requested.logical_height = PixelToPoint(window_data->sdlwindow, window_data->requested.pixel_height); } else {