monitor-config-store: Discard config with fractional scale when unusable

When a configuration has a fractional scale, but we're using a physical
monitor layout, we can't use the scale, but if we do, we end up with
wierd issues down the line. Just discard the config if we run into this.

Eventually we probably want to store the layout mode in the
configuration so we can handle more seamless switching between physical
and logical layout mode, but first do this.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3057
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3299>
This commit is contained in:
Jonas Ådahl 2023-09-27 22:59:13 +08:00 committed by Marge Bot
parent 2ffd1b1663
commit 1802065953

View File

@ -653,6 +653,7 @@ derive_logical_monitor_layout (MetaLogicalMonitorConfig *logical_monitor_conf
MetaMonitorConfig *monitor_config;
int mode_width, mode_height;
int width = 0, height = 0;
float scale;
GList *l;
monitor_config = logical_monitor_config->monitor_configs->data;
@ -683,13 +684,21 @@ derive_logical_monitor_layout (MetaLogicalMonitorConfig *logical_monitor_conf
height = mode_height;
}
scale = logical_monitor_config->scale;
switch (layout_mode)
{
case META_LOGICAL_MONITOR_LAYOUT_MODE_LOGICAL:
width = roundf (width / logical_monitor_config->scale);
height = roundf (height / logical_monitor_config->scale);
width = roundf (width / scale);
height = roundf (height / scale);
break;
case META_LOGICAL_MONITOR_LAYOUT_MODE_PHYSICAL:
if (!G_APPROX_VALUE (scale, roundf (scale), FLT_EPSILON))
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"A fractional scale with physical layout mode not allowed");
return FALSE;
}
break;
}