From 82325cbcfd95a8529f2f523fa2fe7970184a78c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 11 May 2017 17:24:53 +0800 Subject: [PATCH] monitor: Don't get the monitor manager from the backend We will both create and destroy monitors during initialization (when using the X11 backend), so don't try to access the monitor manager from the backend, but store a pointer to it instead. It's stored in MetaMonitor even though only MetaMonitorTiled uses it, mostly because it makes more sense to store such a pointer there. https://bugzilla.gnome.org/show_bug.cgi?id=781723 --- src/backends/meta-monitor-manager.c | 2 +- src/backends/meta-monitor.c | 20 +++++++++++++------- src/backends/meta-monitor.h | 3 ++- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c index fa2840c7e..682a14bfd 100644 --- a/src/backends/meta-monitor-manager.c +++ b/src/backends/meta-monitor-manager.c @@ -2658,7 +2658,7 @@ rebuild_monitors (MetaMonitorManager *manager) { MetaMonitorNormal *monitor_normal; - monitor_normal = meta_monitor_normal_new (output); + monitor_normal = meta_monitor_normal_new (manager, output); manager->monitors = g_list_append (manager->monitors, monitor_normal); } diff --git a/src/backends/meta-monitor.c b/src/backends/meta-monitor.c index 84a696377..03612e564 100644 --- a/src/backends/meta-monitor.c +++ b/src/backends/meta-monitor.c @@ -42,6 +42,8 @@ typedef struct _MetaMonitorModeTiled typedef struct _MetaMonitorPrivate { + MetaMonitorManager *monitor_manager; + GList *outputs; GList *modes; @@ -382,7 +384,8 @@ meta_monitor_normal_generate_modes (MetaMonitorNormal *monitor_normal) } MetaMonitorNormal * -meta_monitor_normal_new (MetaOutput *output) +meta_monitor_normal_new (MetaMonitorManager *monitor_manager, + MetaOutput *output) { MetaMonitorNormal *monitor_normal; MetaMonitor *monitor; @@ -392,6 +395,8 @@ meta_monitor_normal_new (MetaOutput *output) monitor = META_MONITOR (monitor_normal); monitor_priv = meta_monitor_get_instance_private (monitor); + monitor_priv->monitor_manager = monitor_manager; + monitor_priv->outputs = g_list_append (NULL, output); monitor_priv->winsys_id = output->winsys_id; meta_monitor_generate_spec (monitor); @@ -999,6 +1004,8 @@ meta_monitor_tiled_new (MetaMonitorManager *monitor_manager, monitor = META_MONITOR (monitor_tiled); monitor_priv = meta_monitor_get_instance_private (monitor); + monitor_priv->monitor_manager = monitor_manager; + monitor_tiled->tile_group_id = output->tile_info.group_id; monitor_priv->winsys_id = output->winsys_id; @@ -1089,13 +1096,12 @@ meta_monitor_tiled_calculate_crtc_pos (MetaMonitor *monitor, static void meta_monitor_tiled_finalize (GObject *object) { - MetaMonitorTiled *monitor_tiled = META_MONITOR_TILED (object); - MetaBackend *backend = meta_get_backend (); - MetaMonitorManager *monitor_manager = - meta_backend_get_monitor_manager (backend); + MetaMonitor *monitor = META_MONITOR (object); + MetaMonitorPrivate *monitor_priv = + meta_monitor_get_instance_private (monitor); - meta_monitor_manager_tiled_monitor_removed (monitor_manager, - META_MONITOR (monitor_tiled)); + meta_monitor_manager_tiled_monitor_removed (monitor_priv->monitor_manager, + monitor); } static void diff --git a/src/backends/meta-monitor.h b/src/backends/meta-monitor.h index e1358e373..c4402e36e 100644 --- a/src/backends/meta-monitor.h +++ b/src/backends/meta-monitor.h @@ -88,7 +88,8 @@ G_DECLARE_FINAL_TYPE (MetaMonitorTiled, meta_monitor_tiled, MetaMonitorTiled * meta_monitor_tiled_new (MetaMonitorManager *monitor_manager, MetaOutput *main_output); -MetaMonitorNormal * meta_monitor_normal_new (MetaOutput *output); +MetaMonitorNormal * meta_monitor_normal_new (MetaMonitorManager *monitor_manager, + MetaOutput *output); MetaMonitorSpec * meta_monitor_get_spec (MetaMonitor *monitor);