monitor: Unset output monitor when disposing

When rebuilding the monitors (e.g. during hotplug), make sure to detach
the disposed monitors from any outputs before creating the new monitors.
While this isn't currently needed, as outputs are too being recreated,
with the to be introduced virtual outputs that are created for virtual
monitors, this is not always the case anymore, as these virtual outputs
are not regenerated each time anything changes.

Prepare for this by making sure that cleaning up disposed monitors
detach themself properly from the outputs, so new ones can attach
themself to outputs without running into conflicts.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
This commit is contained in:
Jonas Ådahl 2021-01-27 23:16:05 +01:00 committed by Marge Bot
parent b91740df0e
commit 47a6725207
4 changed files with 21 additions and 1 deletions

View File

@ -2843,6 +2843,13 @@ meta_monitor_manager_get_power_save_mode (MetaMonitorManager *manager)
return priv->power_save_mode;
}
static void
destroy_monitor (MetaMonitor *monitor)
{
g_object_run_dispose (G_OBJECT (monitor));
g_object_unref (monitor);
}
static void
rebuild_monitors (MetaMonitorManager *manager)
{
@ -2851,7 +2858,7 @@ rebuild_monitors (MetaMonitorManager *manager)
if (manager->monitors)
{
g_list_free_full (manager->monitors, g_object_unref);
g_list_free_full (manager->monitors, (GDestroyNotify) destroy_monitor);
manager->monitors = NULL;
}

View File

@ -486,6 +486,7 @@ meta_monitor_dispose (GObject *object)
if (priv->outputs)
{
g_list_foreach (priv->outputs, (GFunc) meta_output_unset_monitor, NULL);
g_list_free_full (priv->outputs, g_object_unref);
priv->outputs = NULL;
}

View File

@ -135,6 +135,16 @@ meta_output_set_monitor (MetaOutput *output,
priv->monitor = monitor;
}
void
meta_output_unset_monitor (MetaOutput *output)
{
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
g_warn_if_fail (priv->monitor);
priv->monitor = NULL;
}
const char *
meta_output_get_name (MetaOutput *output)
{

View File

@ -145,6 +145,8 @@ MetaMonitor * meta_output_get_monitor (MetaOutput *output);
void meta_output_set_monitor (MetaOutput *output,
MetaMonitor *monitor);
void meta_output_unset_monitor (MetaOutput *output);
const char * meta_output_get_name (MetaOutput *output);
META_EXPORT_TEST