[mutter] backends/output: Keep a pointer to the monitor manager



commit e0d839aea2836386823eac3c7b8c9a9af56507f2
Author: Jonas Ådahl <jadahl gmail com>
Date:   Tue Jul 4 11:56:18 2017 +0800

    backends/output: Keep a pointer to the monitor manager
    
    Instead of passing it around or fetching the singleton, keep a pointer
    to the monitor manager that owns the output. This will eventually be
    replaced with a per GPU/graphics card object.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=785381

 src/backends/meta-monitor-manager-dummy.c      |   25 ++++++++++++++---------
 src/backends/meta-output.c                     |    6 +++++
 src/backends/meta-output.h                     |    4 +++
 src/backends/native/meta-monitor-manager-kms.c |    1 +
 src/backends/x11/meta-monitor-manager-xrandr.c |    1 +
 src/tests/meta-monitor-manager-test.c          |    4 +++
 6 files changed, 31 insertions(+), 10 deletions(-)
---
diff --git a/src/backends/meta-monitor-manager-dummy.c b/src/backends/meta-monitor-manager-dummy.c
index 1638f1d..14cdb3b 100644
--- a/src/backends/meta-monitor-manager-dummy.c
+++ b/src/backends/meta-monitor-manager-dummy.c
@@ -89,10 +89,11 @@ create_mode (CrtcModeSpec *spec,
 }
 
 static void
-append_monitor (GList **modes,
-                GList **crtcs,
-                GList **outputs,
-                float   scale)
+append_monitor (MetaMonitorManager *manager,
+                GList             **modes,
+                GList             **crtcs,
+                GList             **outputs,
+                float               scale)
 {
   CrtcModeSpec mode_specs[] = {
     {
@@ -140,6 +141,7 @@ append_monitor (GList **modes,
 
   number = g_list_length (*outputs) + 1;
 
+  output->monitor_manager = manager;
   output->winsys_id = number;
   output->name = g_strdup_printf ("LVDS%d", number);
   output->vendor = g_strdup ("MetaProducts Inc.");
@@ -174,10 +176,11 @@ append_monitor (GList **modes,
 }
 
 static void
-append_tiled_monitor (GList **modes,
-                      GList **crtcs,
-                      GList **outputs,
-                      int     scale)
+append_tiled_monitor (MetaMonitorManager *manager,
+                      GList             **modes,
+                      GList             **crtcs,
+                      GList             **outputs,
+                      int                 scale)
 {
   CrtcModeSpec mode_specs[] = {
     {
@@ -242,6 +245,7 @@ append_tiled_monitor (GList **modes,
 
       output = g_object_new (META_TYPE_OUTPUT, NULL);
 
+      output->monitor_manager = manager;
       output->winsys_id = number;
       output->name = g_strdup_printf ("LVDS%d", number);
       output->vendor = g_strdup ("MetaProducts Inc.");
@@ -385,9 +389,10 @@ meta_monitor_manager_dummy_read_current (MetaMonitorManager *manager)
   for (i = 0; i < num_monitors; i++)
     {
       if (tiled_monitors)
-        append_tiled_monitor (&modes, &crtcs, &outputs, monitor_scales[i]);
+        append_tiled_monitor (manager,
+                              &modes, &crtcs, &outputs, monitor_scales[i]);
       else
-        append_monitor (&modes, &crtcs, &outputs, monitor_scales[i]);
+        append_monitor (manager, &modes, &crtcs, &outputs, monitor_scales[i]);
     }
 
   manager->modes = modes;
diff --git a/src/backends/meta-output.c b/src/backends/meta-output.c
index 1dd0ffa..c3a7bd9 100644
--- a/src/backends/meta-output.c
+++ b/src/backends/meta-output.c
@@ -23,6 +23,12 @@
 
 G_DEFINE_TYPE (MetaOutput, meta_output, G_TYPE_OBJECT)
 
+MetaMonitorManager *
+meta_output_get_monitor_manager (MetaOutput *output)
+{
+  return output->monitor_manager;
+}
+
 static void
 meta_output_finalize (GObject *object)
 {
diff --git a/src/backends/meta-output.h b/src/backends/meta-output.h
index 5f51d52..922b0e7 100644
--- a/src/backends/meta-output.h
+++ b/src/backends/meta-output.h
@@ -62,6 +62,8 @@ struct _MetaOutput
 {
   GObject parent;
 
+  MetaMonitorManager *monitor_manager;
+
   /* The CRTC driving this output, NULL if the output is not enabled */
   MetaCrtc *crtc;
 
@@ -117,4 +119,6 @@ struct _MetaOutput
 #define META_TYPE_OUTPUT (meta_output_get_type ())
 G_DECLARE_FINAL_TYPE (MetaOutput, meta_output, META, OUTPUT, GObject)
 
+MetaMonitorManager * meta_output_get_monitor_manager (MetaOutput *output);
+
 #endif /* META_OUTPUT_H */
diff --git a/src/backends/native/meta-monitor-manager-kms.c b/src/backends/native/meta-monitor-manager-kms.c
index 20751f6..bc4df6a 100644
--- a/src/backends/native/meta-monitor-manager-kms.c
+++ b/src/backends/native/meta-monitor-manager-kms.c
@@ -730,6 +730,7 @@ create_output (MetaMonitorManager *manager,
   output->driver_private = output_kms;
   output->driver_notify = (GDestroyNotify)meta_output_destroy_notify;
 
+  output->monitor_manager = manager;
   output->winsys_id = connector->connector_id;
   output->name = make_output_name (connector);
   output->width_mm = connector->mmWidth;
diff --git a/src/backends/x11/meta-monitor-manager-xrandr.c b/src/backends/x11/meta-monitor-manager-xrandr.c
index 558bede..1d9701e 100644
--- a/src/backends/x11/meta-monitor-manager-xrandr.c
+++ b/src/backends/x11/meta-monitor-manager-xrandr.c
@@ -872,6 +872,7 @@ meta_monitor_manager_xrandr_read_current (MetaMonitorManager *manager)
         continue;
 
       output = g_object_new (META_TYPE_OUTPUT, NULL);
+      output->monitor_manager = manager;
 
       if (xrandr_output->connection != RR_Disconnected)
        {
diff --git a/src/tests/meta-monitor-manager-test.c b/src/tests/meta-monitor-manager-test.c
index 5227999..942b5e1 100644
--- a/src/tests/meta-monitor-manager-test.c
+++ b/src/tests/meta-monitor-manager-test.c
@@ -91,9 +91,13 @@ static void
 meta_monitor_manager_test_read_current (MetaMonitorManager *manager)
 {
   MetaMonitorManagerTest *manager_test = META_MONITOR_MANAGER_TEST (manager);
+  GList *l;
 
   g_assert (manager_test->test_setup);
 
+  for (l = manager_test->test_setup->outputs; l; l = l->next)
+    META_OUTPUT (l->data)->monitor_manager = manager;
+
   manager->modes = manager_test->test_setup->modes;
 
   manager->crtcs = manager_test->test_setup->crtcs;


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