[mutter] display: Keep pointer to the context



commit e8af5fd398985fa9d17b9ce523c394a15404dee7
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Wed Mar 3 16:05:09 2021 +0100

    display: Keep pointer to the context
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>

 src/core/display-private.h |  3 ++-
 src/core/display.c         | 28 ++++++++++++++++++++++++++--
 src/core/meta-context.c    |  2 +-
 src/meta/display.h         |  3 +++
 4 files changed, 32 insertions(+), 4 deletions(-)
---
diff --git a/src/core/display-private.h b/src/core/display-private.h
index fc18d6861a..8efac0b492 100644
--- a/src/core/display-private.h
+++ b/src/core/display-private.h
@@ -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,
diff --git a/src/core/display.c b/src/core/display.c
index 96be2bb007..12dacc20d1 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -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
diff --git a/src/core/meta-context.c b/src/core/meta-context.c
index 35bb042be9..4d299bdafd 100644
--- a/src/core/meta-context.c
+++ b/src/core/meta-context.c
@@ -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;
 
diff --git a/src/meta/display.h b/src/meta/display.h
index cddd8c656d..23bcbd0f5a 100644
--- a/src/meta/display.h
+++ b/src/meta/display.h
@@ -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);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]