backends: Add logical monitor -> monitor -> output -> crtc ref chain

Make it so that each logical monitor has a reference to all the
monitors that are assigned to it.

All monitors has a reference to each output that belongs to it.

Each output has a reference to any CRTC it has been assigned.

https://bugzilla.gnome.org/show_bug.cgi?id=786929
This commit is contained in:
Jonas Ådahl 2017-11-03 11:27:57 +01:00 committed by Marco Trevisan (Treviño)
parent 1200182d70
commit 768ec15ea0
3 changed files with 42 additions and 10 deletions

View File

@ -146,7 +146,7 @@ meta_logical_monitor_add_monitor (MetaLogicalMonitor *logical_monitor,
is_presentation = logical_monitor->is_presentation;
logical_monitor->monitors = g_list_append (logical_monitor->monitors,
monitor);
g_object_ref (monitor));
for (l = logical_monitor->monitors; l; l = l->next)
{
@ -257,13 +257,17 @@ meta_logical_monitor_init (MetaLogicalMonitor *logical_monitor)
}
static void
meta_logical_monitor_finalize (GObject *object)
meta_logical_monitor_dispose (GObject *object)
{
MetaLogicalMonitor *logical_monitor = META_LOGICAL_MONITOR (object);
g_list_free (logical_monitor->monitors);
if (logical_monitor->monitors)
{
g_list_free_full (logical_monitor->monitors, g_object_unref);
logical_monitor->monitors = NULL;
}
G_OBJECT_CLASS (meta_logical_monitor_parent_class)->finalize (object);
G_OBJECT_CLASS (meta_logical_monitor_parent_class)->dispose (object);
}
static void
@ -271,7 +275,7 @@ meta_logical_monitor_class_init (MetaLogicalMonitorClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = meta_logical_monitor_finalize;
object_class->dispose = meta_logical_monitor_dispose;
}
gboolean

View File

@ -387,6 +387,21 @@ meta_monitor_crtc_to_logical_transform (MetaMonitor *monitor,
return new_transform;
}
static void
meta_monitor_dispose (GObject *object)
{
MetaMonitor *monitor = META_MONITOR (object);
MetaMonitorPrivate *priv = meta_monitor_get_instance_private (monitor);
if (priv->outputs)
{
g_list_free_full (priv->outputs, g_object_unref);
priv->outputs = NULL;
}
G_OBJECT_CLASS (meta_monitor_parent_class)->dispose (object);
}
static void
meta_monitor_finalize (GObject *object)
{
@ -395,7 +410,6 @@ meta_monitor_finalize (GObject *object)
g_hash_table_destroy (priv->mode_ids);
g_list_free_full (priv->modes, (GDestroyNotify) meta_monitor_mode_free);
g_clear_pointer (&priv->outputs, g_list_free);
meta_monitor_spec_free (priv->spec);
G_OBJECT_CLASS (meta_monitor_parent_class)->finalize (object);
@ -414,6 +428,7 @@ meta_monitor_class_init (MetaMonitorClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->dispose = meta_monitor_dispose;
object_class->finalize = meta_monitor_finalize;
}
@ -550,7 +565,7 @@ meta_monitor_normal_new (MetaGpu *gpu,
monitor_priv->gpu = gpu;
monitor_priv->outputs = g_list_append (NULL, output);
monitor_priv->outputs = g_list_append (NULL, g_object_ref (output));
monitor_priv->winsys_id = output->winsys_id;
meta_monitor_generate_spec (monitor);
@ -665,7 +680,8 @@ add_tiled_monitor_outputs (MetaGpu *gpu,
g_warn_if_fail (output->subpixel_order ==
monitor_tiled->origin_output->subpixel_order);
monitor_priv->outputs = g_list_append (monitor_priv->outputs, output);
monitor_priv->outputs = g_list_append (monitor_priv->outputs,
g_object_ref (output));
}
}

View File

@ -43,7 +43,7 @@ meta_output_assign_crtc (MetaOutput *output,
g_assert (crtc);
priv->crtc = crtc;
g_set_object (&priv->crtc, crtc);
}
void
@ -51,7 +51,7 @@ meta_output_unassign_crtc (MetaOutput *output)
{
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
priv->crtc = NULL;
g_clear_object (&priv->crtc);
}
MetaCrtc *
@ -62,6 +62,17 @@ meta_output_get_assigned_crtc (MetaOutput *output)
return priv->crtc;
}
static void
meta_output_dispose (GObject *object)
{
MetaOutput *output = META_OUTPUT (object);
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
g_clear_object (&priv->crtc);
G_OBJECT_CLASS (meta_output_parent_class)->dispose (object);
}
static void
meta_output_finalize (GObject *object)
{
@ -91,5 +102,6 @@ meta_output_class_init (MetaOutputClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->dispose = meta_output_dispose;
object_class->finalize = meta_output_finalize;
}