mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 15:40:41 -05:00
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:
parent
b1c643eeaa
commit
68b376a944
@ -256,7 +256,7 @@ struct _MetaDisplayClass
|
||||
(time2) != 0) \
|
||||
)
|
||||
|
||||
gboolean meta_display_open (GError **error);
|
||||
MetaDisplay * meta_display_new (GError **error);
|
||||
|
||||
void meta_display_manage_all_xwindows (MetaDisplay *display);
|
||||
void meta_display_unmanage_windows (MetaDisplay *display,
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,7 @@ typedef struct _MetaContextPrivate
|
||||
GOptionContext *option_context;
|
||||
|
||||
MetaBackend *backend;
|
||||
MetaDisplay *display;
|
||||
|
||||
GMainLoop *main_loop;
|
||||
GError *termination_error;
|
||||
@ -127,6 +128,20 @@ meta_context_get_backend (MetaContext *context)
|
||||
return priv->backend;
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_context_get_display:
|
||||
* @context: The #MetaContext
|
||||
*
|
||||
* Returns: (transfer none): the #MetaDisplay
|
||||
*/
|
||||
MetaDisplay *
|
||||
meta_context_get_display (MetaContext *context)
|
||||
{
|
||||
MetaContextPrivate *priv = meta_context_get_instance_private (context);
|
||||
|
||||
return priv->display;
|
||||
}
|
||||
|
||||
MetaCompositorType
|
||||
meta_context_get_compositor_type (MetaContext *context)
|
||||
{
|
||||
@ -306,7 +321,8 @@ meta_context_start (MetaContext *context,
|
||||
meta_backend_init_wayland (meta_get_backend ());
|
||||
#endif
|
||||
|
||||
if (!meta_display_open (error))
|
||||
priv->display = meta_display_new (error);
|
||||
if (!priv->display)
|
||||
return FALSE;
|
||||
|
||||
priv->main_loop = g_main_loop_new (NULL, FALSE);
|
||||
@ -404,7 +420,6 @@ meta_context_finalize (GObject *object)
|
||||
{
|
||||
MetaContext *context = META_CONTEXT (object);
|
||||
MetaContextPrivate *priv = meta_context_get_instance_private (context);
|
||||
MetaDisplay *display;
|
||||
#ifdef HAVE_WAYLAND
|
||||
MetaWaylandCompositor *compositor;
|
||||
MetaCompositorType compositor_type;
|
||||
@ -419,9 +434,9 @@ meta_context_finalize (GObject *object)
|
||||
meta_wayland_compositor_prepare_shutdown (compositor);
|
||||
#endif
|
||||
|
||||
display = meta_get_display ();
|
||||
if (display)
|
||||
meta_display_close (display, META_CURRENT_TIME);
|
||||
if (priv->display)
|
||||
meta_display_close (priv->display, META_CURRENT_TIME);
|
||||
g_clear_object (&priv->display);
|
||||
|
||||
#ifdef HAVE_WAYLAND
|
||||
compositor_type = meta_context_get_compositor_type (context);
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include "meta/common.h"
|
||||
#include "meta/meta-enums.h"
|
||||
#include "meta/types.h"
|
||||
|
||||
#define META_TYPE_CONTEXT (meta_context_get_type ())
|
||||
META_EXPORT
|
||||
@ -84,4 +85,7 @@ MetaCompositorType meta_context_get_compositor_type (MetaContext *context);
|
||||
META_EXPORT
|
||||
MetaBackend * meta_context_get_backend (MetaContext *context);
|
||||
|
||||
META_EXPORT
|
||||
MetaDisplay * meta_context_get_display (MetaContext *context);
|
||||
|
||||
#endif /* META_CONTEXT_H */
|
||||
|
Loading…
Reference in New Issue
Block a user