From 4008ed2f55d4621a4ed2230799c1ab2d012b3545 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Wed, 27 Sep 2023 22:59:13 +0800 Subject: [PATCH] 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 --- src/backends/meta-monitor-config-store.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/backends/meta-monitor-config-store.c b/src/backends/meta-monitor-config-store.c index fe9406fd3f7..53a32cd2aaf 100644 --- a/src/backends/meta-monitor-config-store.c +++ b/src/backends/meta-monitor-config-store.c @@ -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; } -- GitLab