[mutter] mutter: Port to MetaContext



commit 725510ea2919beec0a2c4a8f4b34b66e470e6345
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Wed Mar 3 11:40:55 2021 +0100

    mutter: Port to MetaContext
    
    Uses the new MetaContextMain, replacing piece by piece "real display
    server" setup done using mostly main.c functions.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>

 src/core/mutter.c | 45 +++++++++++++++++++++++++++++++--------------
 1 file changed, 31 insertions(+), 14 deletions(-)
---
diff --git a/src/core/mutter.c b/src/core/mutter.c
index 811e1f92be..9d716014a2 100644
--- a/src/core/mutter.c
+++ b/src/core/mutter.c
@@ -25,7 +25,7 @@
 
 #include "compositor/meta-plugin-manager.h"
 #include "meta/main.h"
-#include "meta/meta-enums.h"
+#include "meta/meta-context.h"
 #include "meta/util.h"
 
 static gboolean
@@ -59,22 +59,39 @@ GOptionEntry mutter_options[] = {
 int
 main (int argc, char **argv)
 {
-  GOptionContext *ctx;
-  GError *error = NULL;
+  g_autoptr (MetaContext) context = NULL;
+  g_autoptr (GError) error = NULL;
 
-  ctx = meta_get_option_context ();
-  g_option_context_add_main_entries (ctx, mutter_options, GETTEXT_PACKAGE);
-  if (!g_option_context_parse (ctx, &argc, &argv, &error))
+  context = meta_create_context ("Mutter");
+
+  meta_context_add_option_entries (context, mutter_options, GETTEXT_PACKAGE);
+  if (!meta_context_configure (context, &argc, &argv, &error))
+    {
+      g_printerr ("Failed to configure: %s", error->message);
+      return EXIT_FAILURE;
+    }
+
+  meta_context_set_plugin_name (context, plugin);
+
+  if (!meta_context_setup (context, &error))
     {
-      g_printerr ("mutter: %s\n", error->message);
-      exit (1);
+      g_printerr ("Failed to setup: %s", error->message);
+      return EXIT_FAILURE;
     }
-  g_option_context_free (ctx);
 
-  if (plugin)
-    meta_plugin_manager_load (plugin);
+  if (!meta_context_start (context, &error))
+    {
+      g_printerr ("Failed to start: %s", error->message);
+      return EXIT_FAILURE;
+    }
+
+  meta_context_notify_ready (context);
+
+  if (!meta_context_run_main_loop (context, &error))
+    {
+      g_printerr ("Mutter terminated with a failure: %s", error->message);
+      return EXIT_FAILURE;
+    }
 
-  meta_init ();
-  meta_register_with_session ();
-  return meta_run ();
+  return EXIT_SUCCESS;
 }


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