context: Make context owner of MetaDisplay

It may still be closed from elsewhere, e.g. when being replaced, but the
reference is owned by MetaContext instead of itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
This commit is contained in:
Jonas Ådahl
2021-03-03 15:12:19 +01:00
parent b1c643eeaa
commit 68b376a944
4 changed files with 32 additions and 23 deletions

View File

@ -788,18 +788,8 @@ meta_display_shutdown_x11 (MetaDisplay *display)
g_clear_object (&display->x11_display);
}
/**
* meta_display_open:
*
* Opens a new display, sets it up, initialises all the X extensions
* we will need, and adds it to the list of displays.
*
* Returns: %TRUE if the display was opened successfully, and %FALSE
* otherwise-- that is, if the display doesn't exist or it already
* has a window manager.
*/
gboolean
meta_display_open (GError **error)
MetaDisplay *
meta_display_new (GError **error)
{
MetaDisplay *display;
int i;
@ -905,7 +895,7 @@ meta_display_open (GError **error)
if (!meta_display_init_x11_display (display, error))
{
g_object_unref (display);
return FALSE;
return NULL;
}
timestamp = display->x11_display->timestamp;
@ -923,7 +913,7 @@ meta_display_open (GError **error)
if (!meta_compositor_do_manage (display->compositor, error))
{
g_object_unref (display);
return FALSE;
return NULL;
}
if (display->x11_display)
@ -964,7 +954,7 @@ meta_display_open (GError **error)
/* Done opening new display */
display->display_opening = FALSE;
return TRUE;
return display;
}
static gint
@ -1077,7 +1067,6 @@ meta_display_close (MetaDisplay *display,
guint32 timestamp)
{
g_assert (display != NULL);
g_assert (display == the_display);
if (display->closing != 0)
{
@ -1085,6 +1074,8 @@ meta_display_close (MetaDisplay *display,
return;
}
g_assert (display == the_display);
display->closing += 1;
g_signal_emit (display, display_signals[CLOSING], 0);
@ -1135,7 +1126,6 @@ meta_display_close (MetaDisplay *display,
g_clear_object (&display->selection);
g_clear_object (&display->pad_action_mapper);
g_object_unref (display);
the_display = NULL;
}