[mutter/gnome-3-24] monitor-manager: Let the MetaMonitor derive the whole layout



commit eb6f74987e66525d8a2f2cfabc5def43d7816318
Author: Jonas Ådahl <jadahl gmail com>
Date:   Wed Jul 12 15:42:20 2017 +0800

    monitor-manager: Let the MetaMonitor derive the whole layout
    
    Instead of letting MetaMonitor derive the logical monitor size, then
    using the main monitor for the position, just let MetaMonitor derive
    the whole layout including the position. This means it can deal with
    tiled monitors better, for example when the main output (the output
    always active when the monitor is active) is not the origin output (the
    output with tile position (0, 0)).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=781723

 src/backends/meta-monitor-manager.c |   15 +-------------
 src/backends/meta-monitor.c         |   37 +++++++++++++++++++---------------
 src/backends/meta-monitor.h         |   10 +++-----
 3 files changed, 26 insertions(+), 36 deletions(-)
---
diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c
index eecef77..b3d9743 100644
--- a/src/backends/meta-monitor-manager.c
+++ b/src/backends/meta-monitor-manager.c
@@ -148,19 +148,6 @@ meta_monitor_manager_rebuild_logical_monitors (MetaMonitorManager *manager,
 }
 
 static void
-derive_monitor_layout (MetaMonitor   *monitor,
-                       MetaRectangle *layout)
-{
-  MetaOutput *main_output;
-
-  main_output = meta_monitor_get_main_output (monitor);
-  layout->x = main_output->crtc->rect.x;
-  layout->y = main_output->crtc->rect.y;
-
-  meta_monitor_derive_dimensions (monitor, &layout->width, &layout->height);
-}
-
-static void
 meta_monitor_manager_rebuild_logical_monitors_derived (MetaMonitorManager *manager)
 {
   GList *logical_monitors = NULL;
@@ -179,7 +166,7 @@ meta_monitor_manager_rebuild_logical_monitors_derived (MetaMonitorManager *manag
       if (!meta_monitor_is_active (monitor))
         continue;
 
-      derive_monitor_layout (monitor, &layout);
+      meta_monitor_derive_layout (monitor, &layout);
       logical_monitor = logical_monitor_from_layout (manager, logical_monitors,
                                                      &layout);
       if (logical_monitor)
diff --git a/src/backends/meta-monitor.c b/src/backends/meta-monitor.c
index 30c2197..b2519c0 100644
--- a/src/backends/meta-monitor.c
+++ b/src/backends/meta-monitor.c
@@ -232,11 +232,10 @@ meta_monitor_get_current_resolution (MetaMonitor *monitor,
 }
 
 void
-meta_monitor_derive_dimensions (MetaMonitor   *monitor,
-                                int           *width,
-                                int           *height)
+meta_monitor_derive_layout (MetaMonitor   *monitor,
+                            MetaRectangle *layout)
 {
-  META_MONITOR_GET_CLASS (monitor)->derive_dimensions (monitor, width, height);
+  META_MONITOR_GET_CLASS (monitor)->derive_layout (monitor, layout);
 }
 
 void
@@ -382,15 +381,18 @@ meta_monitor_normal_get_main_output (MetaMonitor *monitor)
 }
 
 static void
-meta_monitor_normal_derive_dimensions (MetaMonitor   *monitor,
-                                       int           *width,
-                                       int           *height)
+meta_monitor_normal_derive_layout (MetaMonitor   *monitor,
+                                   MetaRectangle *layout)
 {
   MetaOutput *output;
 
   output = meta_monitor_get_main_output (monitor);
-  *width = output->crtc->rect.width;
-  *height = output->crtc->rect.height;
+  *layout = (MetaRectangle) {
+    .x = output->crtc->rect.x,
+    .y = output->crtc->rect.y,
+    .width = output->crtc->rect.width,
+    .height = output->crtc->rect.height
+  };
 }
 
 static gboolean
@@ -421,7 +423,7 @@ meta_monitor_normal_class_init (MetaMonitorNormalClass *klass)
   MetaMonitorClass *monitor_class = META_MONITOR_CLASS (klass);
 
   monitor_class->get_main_output = meta_monitor_normal_get_main_output;
-  monitor_class->derive_dimensions = meta_monitor_normal_derive_dimensions;
+  monitor_class->derive_layout = meta_monitor_normal_derive_layout;
   monitor_class->get_suggested_position = meta_monitor_normal_get_suggested_position;
 }
 
@@ -958,9 +960,8 @@ meta_monitor_tiled_get_main_output (MetaMonitor *monitor)
 }
 
 static void
-meta_monitor_tiled_derive_dimensions (MetaMonitor   *monitor,
-                                      int           *out_width,
-                                      int           *out_height)
+meta_monitor_derived_derive_layout (MetaMonitor   *monitor,
+                                    MetaRectangle *layout)
 {
   MetaMonitorPrivate *monitor_priv =
     meta_monitor_get_instance_private (monitor);
@@ -984,8 +985,12 @@ meta_monitor_tiled_derive_dimensions (MetaMonitor   *monitor,
       max_y = MAX (output->crtc->rect.y + output->crtc->rect.height, max_y);
     }
 
-  *out_width = max_x - min_x;
-  *out_height = max_y - min_y;
+  *layout = (MetaRectangle) {
+    .x = min_x,
+    .y = min_y,
+    .width = max_x - min_x,
+    .height = max_y - min_y
+  };
 }
 
 static gboolean
@@ -1021,7 +1026,7 @@ meta_monitor_tiled_class_init (MetaMonitorTiledClass *klass)
   object_class->finalize = meta_monitor_tiled_finalize;
 
   monitor_class->get_main_output = meta_monitor_tiled_get_main_output;
-  monitor_class->derive_dimensions = meta_monitor_tiled_derive_dimensions;
+  monitor_class->derive_layout = meta_monitor_derived_derive_layout;
   monitor_class->get_suggested_position = meta_monitor_tiled_get_suggested_position;
 }
 
diff --git a/src/backends/meta-monitor.h b/src/backends/meta-monitor.h
index aa03889..63df004 100644
--- a/src/backends/meta-monitor.h
+++ b/src/backends/meta-monitor.h
@@ -65,9 +65,8 @@ struct _MetaMonitorClass
   GObjectClass parent_class;
 
   MetaOutput * (* get_main_output) (MetaMonitor *monitor);
-  void (* derive_dimensions) (MetaMonitor   *monitor,
-                              int           *width,
-                              int           *height);
+  void (* derive_layout) (MetaMonitor   *monitor,
+                          MetaRectangle *layout);
   gboolean (* get_suggested_position) (MetaMonitor *monitor,
                                        int         *width,
                                        int         *height);
@@ -107,9 +106,8 @@ void meta_monitor_get_current_resolution (MetaMonitor *monitor,
                                           int           *width,
                                           int           *height);
 
-void meta_monitor_derive_dimensions (MetaMonitor   *monitor,
-                                     int           *width,
-                                     int           *height);
+void meta_monitor_derive_layout (MetaMonitor   *monitor,
+                                 MetaRectangle *layout);
 
 void meta_monitor_get_physical_dimensions (MetaMonitor *monitor,
                                            int         *width_mm,


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