display: Keep pointer to the context

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
This commit is contained in:
Jonas Ådahl 2021-03-03 16:05:09 +01:00
parent 4be9bc9db4
commit e8af5fd398
4 changed files with 32 additions and 4 deletions

View File

@ -256,7 +256,8 @@ struct _MetaDisplayClass
(time2) != 0) \
)
MetaDisplay * meta_display_new (GError **error);
MetaDisplay * meta_display_new (MetaContext *context,
GError **error);
void meta_display_manage_all_xwindows (MetaDisplay *display);
void meta_display_unmanage_windows (MetaDisplay *display,

View File

@ -122,7 +122,12 @@ typedef struct
guint ping_timeout_id;
} MetaPingData;
G_DEFINE_TYPE(MetaDisplay, meta_display, G_TYPE_OBJECT);
typedef struct _MetaDisplayPrivate
{
MetaContext *context;
} MetaDisplayPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (MetaDisplay, meta_display, G_TYPE_OBJECT)
/* Signals */
enum
@ -789,9 +794,11 @@ meta_display_shutdown_x11 (MetaDisplay *display)
}
MetaDisplay *
meta_display_new (GError **error)
meta_display_new (MetaContext *context,
GError **error)
{
MetaDisplay *display;
MetaDisplayPrivate *priv;
int i;
guint32 timestamp;
Window old_active_xwindow = None;
@ -802,6 +809,9 @@ meta_display_new (GError **error)
g_assert (the_display == NULL);
display = the_display = g_object_new (META_TYPE_DISPLAY, NULL);
priv = meta_display_get_instance_private (display);
priv->context = context;
display->closing = 0;
display->display_opening = TRUE;
@ -2772,6 +2782,20 @@ meta_display_supports_extended_barriers (MetaDisplay *display)
return FALSE;
}
/**
* meta_display_get_context:
* @display: a #MetaDisplay
*
* Returns: (transfer none): the #MetaContext
*/
MetaContext *
meta_display_get_context (MetaDisplay *display)
{
MetaDisplayPrivate *priv = meta_display_get_instance_private (display);
return priv->context;
}
/**
* meta_display_get_compositor: (skip)
* @display: a #MetaDisplay

View File

@ -321,7 +321,7 @@ meta_context_start (MetaContext *context,
meta_backend_init_wayland (meta_get_backend ());
#endif
priv->display = meta_display_new (error);
priv->display = meta_display_new (context, error);
if (!priv->display)
return FALSE;

View File

@ -84,6 +84,9 @@ META_EXPORT
void meta_display_close (MetaDisplay *display,
guint32 timestamp);
META_EXPORT
MetaContext * meta_display_get_context (MetaDisplay *display);
META_EXPORT
MetaCompositor *meta_display_get_compositor (MetaDisplay *display);