mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 09:30:45 -05:00
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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
This commit is contained in:
parent
2e784e23a2
commit
6732e3e585
@ -83,7 +83,7 @@
|
|||||||
#include "core/util-private.h"
|
#include "core/util-private.h"
|
||||||
#include "meta/compositor.h"
|
#include "meta/compositor.h"
|
||||||
#include "meta/meta-backend.h"
|
#include "meta/meta-backend.h"
|
||||||
#include "meta/meta-enums.h"
|
#include "meta/meta-context.h"
|
||||||
#include "meta/meta-x11-errors.h"
|
#include "meta/meta-x11-errors.h"
|
||||||
#include "ui/ui.h"
|
#include "ui/ui.h"
|
||||||
#include "x11/session.h"
|
#include "x11/session.h"
|
||||||
@ -888,6 +888,9 @@ meta_run (void)
|
|||||||
return meta_exit_code;
|
return meta_exit_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MetaContext *
|
||||||
|
meta_get_context_temporary (void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* meta_quit:
|
* meta_quit:
|
||||||
* @code: The success or failure code to return to the calling process.
|
* @code: The success or failure code to return to the calling process.
|
||||||
@ -901,11 +904,30 @@ meta_run (void)
|
|||||||
void
|
void
|
||||||
meta_quit (MetaExitCode code)
|
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;
|
meta_exit_code = code;
|
||||||
g_main_loop_quit (meta_main_loop);
|
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
|
MetaExitCode
|
||||||
|
@ -354,6 +354,24 @@ meta_context_finalize (GObject *object)
|
|||||||
G_OBJECT_CLASS (meta_context_parent_class)->finalize (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
|
static void
|
||||||
meta_context_class_init (MetaContextClass *klass)
|
meta_context_class_init (MetaContextClass *klass)
|
||||||
{
|
{
|
||||||
@ -379,6 +397,9 @@ meta_context_class_init (MetaContextClass *klass)
|
|||||||
static void
|
static void
|
||||||
meta_context_init (MetaContext *context)
|
meta_context_init (MetaContext *context)
|
||||||
{
|
{
|
||||||
|
g_assert (!_context_temporary);
|
||||||
|
_context_temporary = context;
|
||||||
|
|
||||||
if (!setlocale (LC_ALL, ""))
|
if (!setlocale (LC_ALL, ""))
|
||||||
g_warning ("Locale not understood by C library");
|
g_warning ("Locale not understood by C library");
|
||||||
bindtextdomain (GETTEXT_PACKAGE, MUTTER_LOCALEDIR);
|
bindtextdomain (GETTEXT_PACKAGE, MUTTER_LOCALEDIR);
|
||||||
|
Loading…
Reference in New Issue
Block a user