[mutter] monitor-manager: Check if all monitor scales are matching in global mode



commit 7c87c1c24f3fdf1e640aca2725072effb281ae84
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Thu Nov 29 23:04:17 2018 -0500

    monitor-manager: Check if all monitor scales are matching in global mode
    
    When global scaling is set we need to ensure that all the requested scale
    configurations are matching, otherwise we'd end up in a mixed setup that
    we don't support in this scenario.
    
    Fixes https://gitlab.gnome.org/GNOME/mutter/issues/407
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/336>

 src/backends/meta-monitor-manager.c | 51 +++++++++++++++++++++++++++++++++----
 1 file changed, 46 insertions(+), 5 deletions(-)
---
diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c
index 1e08f3a824..71ff8a2a3a 100644
--- a/src/backends/meta-monitor-manager.c
+++ b/src/backends/meta-monitor-manager.c
@@ -125,6 +125,10 @@ meta_monitor_manager_get_active_monitor (MetaMonitorManager *manager);
 static void
 meta_monitor_manager_real_read_current_state (MetaMonitorManager *manager);
 
+static gboolean
+is_global_scale_matching_in_config (MetaMonitorsConfig *config,
+                                    float               scale);
+
 MetaBackend *
 meta_monitor_manager_get_backend (MetaMonitorManager *manager)
 {
@@ -1761,6 +1765,43 @@ meta_monitor_manager_is_scale_supported (MetaMonitorManager          *manager,
   return FALSE;
 }
 
+static gboolean
+is_global_scale_matching_in_config (MetaMonitorsConfig *config,
+                                    float               scale)
+{
+  GList *l;
+
+  for (l = config->logical_monitor_configs; l; l = l->next)
+    {
+      MetaLogicalMonitorConfig *logical_monitor_config = l->data;
+
+      if (!G_APPROX_VALUE (logical_monitor_config->scale, scale, FLT_EPSILON))
+        return FALSE;
+    }
+
+  return TRUE;
+}
+
+static gboolean
+meta_monitor_manager_is_scale_supported_for_config (MetaMonitorManager *manager,
+                                                    MetaMonitorsConfig *config,
+                                                    MetaMonitor        *monitor,
+                                                    MetaMonitorMode    *monitor_mode,
+                                                    float               scale)
+{
+  if (meta_monitor_manager_is_scale_supported (manager, config->layout_mode,
+                                               monitor, monitor_mode, scale))
+    {
+      if (meta_monitor_manager_get_capabilities (manager) &
+          META_MONITOR_MANAGER_CAPABILITY_GLOBAL_SCALE_REQUIRED)
+        return is_global_scale_matching_in_config (config, scale);
+
+      return TRUE;
+    }
+
+  return FALSE;
+}
+
 static gboolean
 meta_monitor_manager_is_config_applicable (MetaMonitorManager *manager,
                                            MetaMonitorsConfig *config,
@@ -1799,11 +1840,11 @@ meta_monitor_manager_is_config_applicable (MetaMonitorManager *manager,
               return FALSE;
             }
 
-          if (!meta_monitor_manager_is_scale_supported (manager,
-                                                        config->layout_mode,
-                                                        monitor,
-                                                        monitor_mode,
-                                                        scale))
+          if (!meta_monitor_manager_is_scale_supported_for_config (manager,
+                                                                   config,
+                                                                   monitor,
+                                                                   monitor_mode,
+                                                                   scale))
             {
               g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
                            "Scale not supported by backend");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]