[mutter] context: Add entry points for context configuration



commit 6c6b5b9a486d242e1c2d0b2de2cbc579abd9ec78
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Tue Mar 2 10:35:38 2021 +0100

    context: Add entry points for context configuration
    
    Configuration is the first step of the lifetime of a context, after
    creation; it's here where argc/argv is processed, and it's determined
    what kind of compositor, etc, it is going to be.
    
    The tests always run as Wayand compositors, so the configuration is
    quite simple, but will involve more steps later on.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>

 src/core/meta-context-private.h |  8 ++++++++
 src/core/meta-context.c         | 33 +++++++++++++++++++++++++++++++++
 src/meta/meta-context.h         |  6 ++++++
 src/tests/meta-context-test.c   | 19 +++++++++++++++++++
 4 files changed, 66 insertions(+)
---
diff --git a/src/core/meta-context-private.h b/src/core/meta-context-private.h
index 89675d2644..76f0675e1e 100644
--- a/src/core/meta-context-private.h
+++ b/src/core/meta-context-private.h
@@ -22,10 +22,18 @@
 #define META_CONTEXT_PRIVATE_H
 
 #include "meta/meta-context.h"
+#include "meta/meta-enums.h"
 
 struct _MetaContextClass
 {
   GObjectClass parent_class;
+
+  gboolean (* configure) (MetaContext   *context,
+                          int           *argc,
+                          char        ***argv,
+                          GError       **error);
+
+  MetaCompositorType (* get_compositor_type) (MetaContext *context);
 };
 
 #endif /* META_CONTEXT_PRIVATE_H */
diff --git a/src/core/meta-context.c b/src/core/meta-context.c
index e80b5f3438..a816f561eb 100644
--- a/src/core/meta-context.c
+++ b/src/core/meta-context.c
@@ -22,6 +22,8 @@
 
 #include "core/meta-context-private.h"
 
+#include "core/util-private.h"
+
 enum
 {
   PROP_0,
@@ -40,6 +42,37 @@ typedef struct _MetaContextPrivate
 
 G_DEFINE_TYPE_WITH_PRIVATE (MetaContext, meta_context, G_TYPE_OBJECT)
 
+static MetaCompositorType
+meta_context_get_compositor_type (MetaContext *context)
+{
+  return META_CONTEXT_GET_CLASS (context)->get_compositor_type (context);
+}
+
+gboolean
+meta_context_configure (MetaContext   *context,
+                        int           *argc,
+                        char        ***argv,
+                        GError       **error)
+{
+  MetaCompositorType compositor_type;
+
+  if (!META_CONTEXT_GET_CLASS (context)->configure (context, argc, argv, error))
+    return FALSE;
+
+  compositor_type = meta_context_get_compositor_type (context);
+  switch (compositor_type)
+    {
+    case META_COMPOSITOR_TYPE_WAYLAND:
+      meta_set_is_wayland_compositor (TRUE);
+      break;
+    case META_COMPOSITOR_TYPE_X11:
+      meta_set_is_wayland_compositor (FALSE);
+      break;
+    }
+
+  return TRUE;
+}
+
 static void
 meta_context_get_property (GObject    *object,
                            guint       prop_id,
diff --git a/src/meta/meta-context.h b/src/meta/meta-context.h
index 288eb13871..feda6ec901 100644
--- a/src/meta/meta-context.h
+++ b/src/meta/meta-context.h
@@ -29,4 +29,10 @@
 META_EXPORT
 G_DECLARE_DERIVABLE_TYPE (MetaContext, meta_context, META, CONTEXT, GObject)
 
+META_EXPORT
+gboolean meta_context_configure (MetaContext   *context,
+                                 int           *argc,
+                                 char        ***argv,
+                                 GError       **error);
+
 #endif /* META_CONTEXT_H */
diff --git a/src/tests/meta-context-test.c b/src/tests/meta-context-test.c
index 2f35c652e7..4adce2a7cb 100644
--- a/src/tests/meta-context-test.c
+++ b/src/tests/meta-context-test.c
@@ -29,6 +29,21 @@ struct _MetaContextTest
 
 G_DEFINE_TYPE (MetaContextTest, meta_context_test, META_TYPE_CONTEXT)
 
+static gboolean
+meta_context_test_configure (MetaContext   *context,
+                             int           *argc,
+                             char        ***argv,
+                             GError       **error)
+{
+  return TRUE;
+}
+
+static MetaCompositorType
+meta_context_test_get_compositor_type (MetaContext *context)
+{
+  return META_COMPOSITOR_TYPE_WAYLAND;
+}
+
 MetaContext *
 meta_create_test_context (void)
 {
@@ -44,6 +59,10 @@ meta_create_test_context (void)
 static void
 meta_context_test_class_init (MetaContextTestClass *klass)
 {
+  MetaContextClass *context_class = META_CONTEXT_CLASS (klass);
+
+  context_class->configure = meta_context_test_configure;
+  context_class->get_compositor_type = meta_context_test_get_compositor_type;
 }
 
 static void


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