[gnome-flashback] backends: find active monitor when deriving global scale



commit 3b4c90d464212362f691d1ccb4b319388d94a127
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Tue Jul 16 20:17:37 2019 +0300

    backends: find active monitor when deriving global scale
    
    Based on mutter commit:
    https://gitlab.gnome.org/GNOME/mutter/commit/0b3a1c9c314a88c57668

 backends/gf-monitor-manager.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/backends/gf-monitor-manager.c b/backends/gf-monitor-manager.c
index ec8db69..7ef0ae6 100644
--- a/backends/gf-monitor-manager.c
+++ b/backends/gf-monitor-manager.c
@@ -206,6 +206,12 @@ find_monitor (GfMonitorManager *monitor_manager,
   return NULL;
 }
 
+static GfMonitor *
+get_active_monitor (GfMonitorManager *manager)
+{
+  return find_monitor (manager, gf_monitor_is_active);
+}
+
 static gboolean
 gf_monitor_manager_is_config_applicable (GfMonitorManager  *manager,
                                          GfMonitorsConfig  *config,
@@ -322,13 +328,17 @@ calculate_monitor_scale (GfMonitorManager *manager,
 static gfloat
 derive_calculated_global_scale (GfMonitorManager *manager)
 {
-  GfMonitor *primary_monitor;
+  GfMonitor *monitor;
+
+  monitor = gf_monitor_manager_get_primary_monitor (manager);
 
-  primary_monitor = gf_monitor_manager_get_primary_monitor (manager);
-  if (!primary_monitor)
+  if (!monitor || !gf_monitor_is_active (monitor))
+    monitor = get_active_monitor (manager);
+
+  if (!monitor)
     return 1.0;
 
-  return calculate_monitor_scale (manager, primary_monitor);
+  return calculate_monitor_scale (manager, monitor);
 }
 
 static GfLogicalMonitor *


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