[mutter] context: Load plugin during setup phase



commit fe652518afb858cc1c7356cfc06a37332c229440
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Tue Mar 2 11:48:22 2021 +0100

    context: Load plugin during setup phase
    
    The plugin must be configured by the context implementation during the
    configure phase.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>

 src/core/meta-context.c       | 22 ++++++++++++++++++++++
 src/meta/meta-context.h       |  4 ++++
 src/tests/meta-context-test.c |  7 +++++++
 3 files changed, 33 insertions(+)
---
diff --git a/src/core/meta-context.c b/src/core/meta-context.c
index 4bd7b78471..a941d50f8a 100644
--- a/src/core/meta-context.c
+++ b/src/core/meta-context.c
@@ -25,6 +25,7 @@
 #include <locale.h>
 
 #include "backends/meta-backend-private.h"
+#include "compositor/meta-plugin-manager.h"
 #include "core/util-private.h"
 
 enum
@@ -41,10 +42,20 @@ static GParamSpec *obj_props[N_PROPS];
 typedef struct _MetaContextPrivate
 {
   char *name;
+  char *plugin_name;
 } MetaContextPrivate;
 
 G_DEFINE_TYPE_WITH_PRIVATE (MetaContext, meta_context, G_TYPE_OBJECT)
 
+void
+meta_context_set_plugin_name (MetaContext *context,
+                              const char  *plugin_name)
+{
+  MetaContextPrivate *priv = meta_context_get_instance_private (context);
+
+  priv->plugin_name = g_strdup (plugin_name);
+}
+
 static MetaCompositorType
 meta_context_get_compositor_type (MetaContext *context)
 {
@@ -104,10 +115,20 @@ meta_context_setup (MetaContext  *context,
   MetaContextPrivate *priv = meta_context_get_instance_private (context);
   MetaCompositorType compositor_type;
 
+  if (!priv->plugin_name)
+    {
+      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+                   "No compositor plugin set");
+      return FALSE;
+    }
+
   compositor_type = meta_context_get_compositor_type (context);
   g_message ("Running %s (using mutter %s) as a %s",
              priv->name, VERSION,
              compositor_type_to_description (compositor_type));
+
+  meta_plugin_manager_load (priv->plugin_name);
+
   return META_CONTEXT_GET_CLASS (context)->setup (context, error);
 }
 
@@ -164,6 +185,7 @@ meta_context_finalize (GObject *object)
 
   meta_release_backend ();
 
+  g_clear_pointer (&priv->plugin_name, g_free);
   g_clear_pointer (&priv->name, g_free);
 
   G_OBJECT_CLASS (meta_context_parent_class)->finalize (object);
diff --git a/src/meta/meta-context.h b/src/meta/meta-context.h
index ffaf8e7183..dbe35c825f 100644
--- a/src/meta/meta-context.h
+++ b/src/meta/meta-context.h
@@ -29,6 +29,10 @@
 META_EXPORT
 G_DECLARE_DERIVABLE_TYPE (MetaContext, meta_context, META, CONTEXT, GObject)
 
+META_EXPORT
+void meta_context_set_plugin_name (MetaContext *context,
+                                   const char  *plugin_name);
+
 META_EXPORT
 gboolean meta_context_configure (MetaContext   *context,
                                  int           *argc,
diff --git a/src/tests/meta-context-test.c b/src/tests/meta-context-test.c
index 2a25bdb447..a3c3915338 100644
--- a/src/tests/meta-context-test.c
+++ b/src/tests/meta-context-test.c
@@ -49,6 +49,8 @@ meta_context_test_configure (MetaContext   *context,
                              char        ***argv,
                              GError       **error)
 {
+  const char *plugin_name;
+
   g_test_init (argc, argv, NULL);
   g_test_bug_base ("https://gitlab.gnome.org/GNOME/mutter/issues/";);
 
@@ -57,6 +59,11 @@ meta_context_test_configure (MetaContext   *context,
   meta_wayland_override_display_name ("mutter-test-display");
   meta_xwayland_override_display_number (512);
 
+  plugin_name = g_getenv ("MUTTER_TEST_PLUGIN_PATH");
+  if (!plugin_name)
+    plugin_name = "libdefault";
+  meta_context_set_plugin_name (context, plugin_name);
+
   return TRUE;
 }
 


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