wayland: Only set the explicit logical window size when using display scaling

Otherwise, the standard width/height is already in points/screen units.
This commit is contained in:
Frank Praznik
2024-01-26 11:12:06 -05:00
parent 879ba46ade
commit fbebbab90d
+14
View File
@@ -787,8 +787,10 @@ static void handle_configure_xdg_toplevel(void *data,
*/ */
width = window->floating.w; width = window->floating.w;
height = window->floating.h; height = window->floating.h;
if (wind->scale_to_display) {
wind->requested.logical_width = PixelToPoint(window, width); wind->requested.logical_width = PixelToPoint(window, width);
wind->requested.logical_height = PixelToPoint(window, height); wind->requested.logical_height = PixelToPoint(window, height);
}
} else if (wind->scale_to_display) { } else if (wind->scale_to_display) {
/* Don't convert if the size hasn't changed to avoid rounding errors. */ /* Don't convert if the size hasn't changed to avoid rounding errors. */
if (width != wind->current.logical_width || height != wind->current.logical_height) { if (width != wind->current.logical_width || height != wind->current.logical_height) {
@@ -808,9 +810,11 @@ static void handle_configure_xdg_toplevel(void *data,
*/ */
width = window->floating.w; width = window->floating.w;
height = window->floating.h; height = window->floating.h;
if (wind->scale_to_display) {
wind->requested.logical_width = PixelToPoint(window, width); wind->requested.logical_width = PixelToPoint(window, width);
wind->requested.logical_height = PixelToPoint(window, height); wind->requested.logical_height = PixelToPoint(window, height);
} }
}
/* The content limits are only a hint, which the compositor is free to ignore, /* The content limits are only a hint, which the compositor is free to ignore,
* so apply them manually when appropriate. * so apply them manually when appropriate.
@@ -829,9 +833,11 @@ static void handle_configure_xdg_toplevel(void *data,
} }
height = SDL_max(height, window->min_h); height = SDL_max(height, window->min_h);
if (wind->scale_to_display) {
wind->requested.logical_width = PixelToPoint(window, width); wind->requested.logical_width = PixelToPoint(window, width);
wind->requested.logical_height = PixelToPoint(window, height); wind->requested.logical_height = PixelToPoint(window, height);
} }
}
} else { } else {
/* Fullscreen windows know their exact size. */ /* Fullscreen windows know their exact size. */
if (width == 0 || height == 0) { if (width == 0 || height == 0) {
@@ -1100,8 +1106,10 @@ static void decoration_frame_configure(struct libdecor_frame *frame,
width = window->floating.w; width = window->floating.w;
height = window->floating.h; height = window->floating.h;
if (wind->scale_to_display) {
wind->requested.logical_width = PixelToPoint(window, width); wind->requested.logical_width = PixelToPoint(window, width);
wind->requested.logical_height = PixelToPoint(window, height); wind->requested.logical_height = PixelToPoint(window, height);
}
OverrideLibdecorLimits(window); OverrideLibdecorLimits(window);
} else { } else {
@@ -1132,8 +1140,10 @@ static void decoration_frame_configure(struct libdecor_frame *frame,
height = window->windowed.h; height = window->windowed.h;
} }
if (wind->scale_to_display) {
wind->requested.logical_width = PixelToPoint(window, width); wind->requested.logical_width = PixelToPoint(window, width);
wind->requested.logical_height = PixelToPoint(window, height); wind->requested.logical_height = PixelToPoint(window, height);
}
} else if (wind->scale_to_display) { } else if (wind->scale_to_display) {
/* Don't convert if the size hasn't changed to avoid rounding errors. */ /* Don't convert if the size hasn't changed to avoid rounding errors. */
if (width != wind->current.logical_width || height != wind->current.logical_height) { if (width != wind->current.logical_width || height != wind->current.logical_height) {
@@ -1165,10 +1175,12 @@ static void decoration_frame_configure(struct libdecor_frame *frame,
} }
height = SDL_max(height, window->min_h); height = SDL_max(height, window->min_h);
if (wind->scale_to_display) {
wind->requested.logical_width = PixelToPoint(window, width); wind->requested.logical_width = PixelToPoint(window, width);
wind->requested.logical_height = PixelToPoint(window, height); wind->requested.logical_height = PixelToPoint(window, height);
} }
} }
}
/* Don't update the dimensions if they haven't changed, or they could overwrite /* Don't update the dimensions if they haven't changed, or they could overwrite
* a new size set programmatically with old dimensions. * a new size set programmatically with old dimensions.
@@ -2242,8 +2254,10 @@ int Wayland_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propert
data->requested.width = window->w; data->requested.width = window->w;
data->requested.height = window->h; data->requested.height = window->h;
if (data->scale_to_display) {
data->requested.logical_width = PixelToPoint(window, window->w); data->requested.logical_width = PixelToPoint(window, window->w);
data->requested.logical_height = PixelToPoint(window, window->h); data->requested.logical_height = PixelToPoint(window, window->h);
}
if (!external_surface) { if (!external_surface) {
data->surface = wl_compositor_create_surface(c->compositor); data->surface = wl_compositor_create_surface(c->compositor);