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
This commit is contained in:
Jonas Ådahl 2017-05-11 17:24:53 +08:00
parent fb5ebffb8d
commit 82325cbcfd
3 changed files with 16 additions and 9 deletions

View File

@ -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);
}

View File

@ -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

View File

@ -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);