1
0
Fork 0

core: Make MetaContext manage the MetaSessionManager singleton

Make this core object own the MetaSessionManager, for the window management
code to access.

At this level, we will be able to integrate with systemd notification
system, and use systemd fdstore to keep the mapped memory warm for
us for the case of soft reboot. This is at the moment not implemented
here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3825>
This commit is contained in:
Carlos Garnacho 2024-07-26 14:03:31 +02:00 committed by Marge Bot
parent fa9c70a1d4
commit 920de400f5
3 changed files with 38 additions and 2 deletions

View file

@ -32,6 +32,7 @@
#include "backends/meta-monitor.h"
#include "backends/meta-monitor-manager-private.h"
#include "backends/meta-virtual-monitor.h"
#include "core/meta-session-manager.h"
#include "meta/meta-backend.h"
#ifdef HAVE_X11
@ -88,6 +89,8 @@ struct _MetaContextMain
MetaContextMainOptions options;
MetaSessionManager *session_manager;
MetaCompositorType compositor_type;
GList *persistent_virtual_monitors;
@ -524,12 +527,13 @@ meta_context_main_create_backend (MetaContext *context,
g_assert_not_reached ();
}
#ifdef HAVE_X11
static void
meta_context_main_notify_ready (MetaContext *context)
{
MetaContextMain *context_main = META_CONTEXT_MAIN (context);
g_autoptr (GError) error = NULL;
#ifdef HAVE_X11
if (!context_main->options.sm.disable)
{
meta_session_init (context,
@ -538,8 +542,16 @@ meta_context_main_notify_ready (MetaContext *context)
}
g_clear_pointer (&context_main->options.sm.client_id, g_free);
g_clear_pointer (&context_main->options.sm.save_file, g_free);
#endif
context_main->session_manager =
meta_session_manager_new (meta_context_get_nick (context), &error);
if (!context_main->session_manager)
g_critical ("Could not create session manager: %s", error->message);
}
#ifdef HAVE_X11
static gboolean
meta_context_main_is_x11_sync (MetaContext *context)
{
@ -549,6 +561,14 @@ meta_context_main_is_x11_sync (MetaContext *context)
}
#endif
static MetaSessionManager *
meta_context_main_get_session_manager (MetaContext *context)
{
MetaContextMain *context_main = META_CONTEXT_MAIN (context);
return context_main->session_manager;
}
#ifdef HAVE_NATIVE_BACKEND
static gboolean
add_virtual_monitor_cb (const char *option_name,
@ -730,6 +750,10 @@ meta_context_main_finalize (GObject *object)
g_list_free_full (context_main->persistent_virtual_monitors, g_object_unref);
context_main->persistent_virtual_monitors = NULL;
if (context_main->session_manager)
meta_session_manager_save_sync (context_main->session_manager, NULL);
g_clear_object (&context_main->session_manager);
#endif
G_OBJECT_CLASS (meta_context_main_parent_class)->finalize (object);
@ -761,10 +785,11 @@ meta_context_main_class_init (MetaContextMainClass *klass)
context_class->is_replacing = meta_context_main_is_replacing;
context_class->setup = meta_context_main_setup;
context_class->create_backend = meta_context_main_create_backend;
#ifdef HAVE_X11
context_class->notify_ready = meta_context_main_notify_ready;
#ifdef HAVE_X11
context_class->is_x11_sync = meta_context_main_is_x11_sync;
#endif
context_class->get_session_manager = meta_context_main_get_session_manager;
}
static void

View file

@ -20,6 +20,7 @@
#include "core/meta-private-enums.h"
#include "core/meta-service-channel.h"
#include "core/meta-session-manager.h"
#include "core/util-private.h"
#include "meta/meta-backend.h"
#include "meta/meta-context.h"
@ -56,6 +57,8 @@ struct _MetaContextClass
#ifdef HAVE_X11
gboolean (* is_x11_sync) (MetaContext *context);
#endif
MetaSessionManager * (* get_session_manager) (MetaContext *context);
};
const char * meta_context_get_name (MetaContext *context);
@ -86,3 +89,5 @@ meta_context_get_profiler (MetaContext *context);
void meta_context_set_trace_file (MetaContext *context,
const char *trace_file);
#endif
MetaSessionManager * meta_context_get_session_manager (MetaContext *context);

View file

@ -979,3 +979,9 @@ meta_context_get_debug_control (MetaContext *context)
return priv->debug_control;
}
MetaSessionManager *
meta_context_get_session_manager (MetaContext *context)
{
return META_CONTEXT_GET_CLASS (context)->get_session_manager (context);
}