[gnome-flashback] monitor-config-manager: put logical monitor size scaling into helper



commit 01efff9f2b8332898917cca27bbfc403f90e97e5
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Fri Aug 19 20:24:44 2022 +0300

    monitor-config-manager: put logical monitor size scaling into helper
    
    Based on mutter commit:
    https://gitlab.gnome.org/GNOME/mutter/-/commit/b2ba653dd9d3d08eb1c8906e31ee512f83177569

 backends/gf-monitor-config-manager.c | 44 +++++++++++++++++++++++++++---------
 1 file changed, 33 insertions(+), 11 deletions(-)
---
diff --git a/backends/gf-monitor-config-manager.c b/backends/gf-monitor-config-manager.c
index 395cd37..814b37c 100644
--- a/backends/gf-monitor-config-manager.c
+++ b/backends/gf-monitor-config-manager.c
@@ -262,6 +262,33 @@ get_monitor_transform (GfMonitorManager *monitor_manager,
   return gf_monitor_transform_from_orientation (orientation);
 }
 
+static void
+scale_logical_monitor_width (GfLogicalMonitorLayoutMode  layout_mode,
+                             float                       scale,
+                             int                         mode_width,
+                             int                         mode_height,
+                             int                        *width,
+                             int                        *height)
+{
+  switch (layout_mode)
+    {
+      case GF_LOGICAL_MONITOR_LAYOUT_MODE_LOGICAL:
+        *width = (int) roundf (mode_width / scale);
+        *height = (int) roundf (mode_height / scale);
+        return;
+
+      case GF_LOGICAL_MONITOR_LAYOUT_MODE_PHYSICAL:
+        *width = mode_width;
+        *height = mode_height;
+        return;
+
+      default:
+        break;
+    }
+
+  g_assert_not_reached ();
+}
+
 static GfLogicalMonitorConfig *
 create_preferred_logical_monitor_config (GfMonitorManager           *monitor_manager,
                                          GfMonitor                  *monitor,
@@ -279,17 +306,12 @@ create_preferred_logical_monitor_config (GfMonitorManager           *monitor_man
   mode = gf_monitor_get_preferred_mode (monitor);
   gf_monitor_mode_get_resolution (mode, &width, &height);
 
-  switch (layout_mode)
-    {
-      case GF_LOGICAL_MONITOR_LAYOUT_MODE_LOGICAL:
-        width = (int) roundf (width / scale);
-        height = (int) roundf (height / scale);
-        break;
-
-      case GF_LOGICAL_MONITOR_LAYOUT_MODE_PHYSICAL:
-      default:
-        break;
-    }
+  scale_logical_monitor_width (layout_mode,
+                               scale,
+                               width,
+                               height,
+                               &width,
+                               &height);
 
   monitor_config = gf_monitor_config_new (monitor, mode);
   transform = get_monitor_transform (monitor_manager, monitor);


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