wayland: Fix handling of output scales more

It turns out that the workaround in 7b380b2ffc was insufficient.
During initialization, we end up calling apply_monitor_changes()
while xdg_output is set, but xdg_output_geometry isn't. Be more
careful and prevent that from wreaking havoc with negative scales.

Fixes: #6472
This commit is contained in:
Matthias Clasen
2024-02-24 20:40:06 -05:00
parent 05acb70d1c
commit 854e40c60c

View File

@@ -2437,12 +2437,13 @@ apply_monitor_change (GdkWaylandMonitor *monitor)
gboolean needs_scaling = FALSE;
double scale;
if (!should_expect_xdg_output_done (monitor) || monitor->xdg_output_done)
if (monitor_has_xdg_output (monitor) &&
monitor->xdg_output_geometry.width != 0 &&
monitor->xdg_output_geometry.height != 0)
{
logical_geometry = monitor->xdg_output_geometry;
needs_scaling =
logical_geometry.width == monitor->output_geometry.width ||
logical_geometry.height == monitor->output_geometry.height;
needs_scaling = logical_geometry.width == monitor->output_geometry.width &&
logical_geometry.height == monitor->output_geometry.height;
}
else
{
@@ -2453,6 +2454,7 @@ apply_monitor_change (GdkWaylandMonitor *monitor)
if (needs_scaling)
{
int scale_factor = gdk_monitor_get_scale_factor (GDK_MONITOR (monitor));
logical_geometry.y /= scale_factor;
logical_geometry.x /= scale_factor;
logical_geometry.width /= scale_factor;