[gnome-flashback] monitor-manager: check if all monitor scales are matching in global mode



commit 0e157e5641877b16b505d662ff00c043ceeb4e46
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Sun Sep 12 22:36:29 2021 +0300

    monitor-manager: check if all monitor scales are matching in global mode
    
    Based on mutter commit:
    https://gitlab.gnome.org/GNOME/mutter/-/commit/7c87c1c24f3f

 backends/gf-monitor-manager.c | 49 +++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 47 insertions(+), 2 deletions(-)
---
diff --git a/backends/gf-monitor-manager.c b/backends/gf-monitor-manager.c
index e209603..b6310c9 100644
--- a/backends/gf-monitor-manager.c
+++ b/backends/gf-monitor-manager.c
@@ -214,6 +214,48 @@ get_active_monitor (GfMonitorManager *manager)
   return find_monitor (manager, gf_monitor_is_active);
 }
 
+static gboolean
+is_global_scale_matching_in_config (GfMonitorsConfig *config,
+                                    float             scale)
+{
+  GList *l;
+
+  for (l = config->logical_monitor_configs; l; l = l->next)
+    {
+      GfLogicalMonitorConfig *logical_monitor_config = l->data;
+
+      if (!G_APPROX_VALUE (logical_monitor_config->scale, scale, FLT_EPSILON))
+        return FALSE;
+    }
+
+  return TRUE;
+}
+
+static gboolean
+is_scale_supported_for_config (GfMonitorManager *self,
+                               GfMonitorsConfig *config,
+                               GfMonitor        *monitor,
+                               GfMonitorMode    *monitor_mode,
+                               float             scale)
+
+{
+  if (gf_monitor_manager_is_scale_supported (self,
+                                             config->layout_mode,
+                                             monitor,
+                                             monitor_mode,
+                                             scale))
+    {
+      if (gf_monitor_manager_get_capabilities (self) &
+          GF_MONITOR_MANAGER_CAPABILITY_GLOBAL_SCALE_REQUIRED)
+        return is_global_scale_matching_in_config (config, scale);
+
+      return TRUE;
+    }
+
+  return FALSE;
+
+}
+
 static gboolean
 gf_monitor_manager_is_config_applicable (GfMonitorManager  *manager,
                                          GfMonitorsConfig  *config,
@@ -256,8 +298,11 @@ gf_monitor_manager_is_config_applicable (GfMonitorManager  *manager,
               return FALSE;
             }
 
-          if (!gf_monitor_manager_is_scale_supported (manager, config->layout_mode,
-                                                      monitor, monitor_mode, scale))
+          if (!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]