From 6732e3e585505e157da7d0884ff40d1fdb2a415b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Tue, 2 Mar 2021 15:27:45 +0100 Subject: [PATCH] main: Temporarily tie meta_quit() to meta_context_terminate*() Makes it possible for mutter internally to use meta_quit() both if we're running using a MetaContext or the scattered functions. Part-of: --- src/core/main.c | 26 ++++++++++++++++++++++++-- src/core/meta-context.c | 21 +++++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/src/core/main.c b/src/core/main.c index 302a2a86a..3c47b5aa2 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -83,7 +83,7 @@ #include "core/util-private.h" #include "meta/compositor.h" #include "meta/meta-backend.h" -#include "meta/meta-enums.h" +#include "meta/meta-context.h" #include "meta/meta-x11-errors.h" #include "ui/ui.h" #include "x11/session.h" @@ -888,6 +888,9 @@ meta_run (void) return meta_exit_code; } +MetaContext * +meta_get_context_temporary (void); + /** * meta_quit: * @code: The success or failure code to return to the calling process. @@ -901,11 +904,30 @@ meta_run (void) void meta_quit (MetaExitCode code) { - if (g_main_loop_is_running (meta_main_loop)) + MetaContext *context; + + if (meta_main_loop && g_main_loop_is_running (meta_main_loop)) { meta_exit_code = code; g_main_loop_quit (meta_main_loop); } + + context = meta_get_context_temporary (); + if (context) + { + if (code == META_EXIT_SUCCESS) + { + meta_context_terminate (context); + } + else + { + GError *error; + + error = g_error_new (G_IO_ERROR, G_IO_ERROR_FAILED, + "Exited with failure status"); + meta_context_terminate_with_error (context, error); + } + } } MetaExitCode diff --git a/src/core/meta-context.c b/src/core/meta-context.c index 9cd12fe21..491cfe938 100644 --- a/src/core/meta-context.c +++ b/src/core/meta-context.c @@ -354,6 +354,24 @@ meta_context_finalize (GObject *object) G_OBJECT_CLASS (meta_context_parent_class)->finalize (object); } +/* + * NOTE! + * + * This global singletone is a temporary stop-gap solution + * to allow migrating to MetaContext in smaller steps. It will + * be removed later in this series of changes. + */ +static MetaContext *_context_temporary; + +MetaContext * +meta_get_context_temporary (void); + +MetaContext * +meta_get_context_temporary (void) +{ + return _context_temporary; +} + static void meta_context_class_init (MetaContextClass *klass) { @@ -379,6 +397,9 @@ meta_context_class_init (MetaContextClass *klass) static void meta_context_init (MetaContext *context) { + g_assert (!_context_temporary); + _context_temporary = context; + if (!setlocale (LC_ALL, "")) g_warning ("Locale not understood by C library"); bindtextdomain (GETTEXT_PACKAGE, MUTTER_LOCALEDIR);