From b31a639378b8c284096fc194d76b1847e665aa3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Wed, 3 Feb 2021 10:59:06 +0100 Subject: [PATCH] backend: Add 'prepare-shutdown' signal This will be used to avoid doing various work when we're shutting down, e.g. react to changes triggering monitor reconfigurations. Part-of: --- src/backends/meta-backend-private.h | 2 ++ src/backends/meta-backend.c | 14 ++++++++++++++ src/core/main.c | 4 ++++ 3 files changed, 20 insertions(+) diff --git a/src/backends/meta-backend-private.h b/src/backends/meta-backend-private.h index 3926a3c63..0c328ffcc 100644 --- a/src/backends/meta-backend-private.h +++ b/src/backends/meta-backend-private.h @@ -110,6 +110,8 @@ void meta_init_backend (GType backend_gtype, const GValue *values); void meta_release_backend (void); +void meta_backend_prepare_shutdown (MetaBackend *backend); + #ifdef HAVE_WAYLAND MetaWaylandCompositor * meta_backend_get_wayland_compositor (MetaBackend *backend); diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c index 6b2780eeb..e0249160d 100644 --- a/src/backends/meta-backend.c +++ b/src/backends/meta-backend.c @@ -94,6 +94,7 @@ enum LAST_DEVICE_CHANGED, LID_IS_CLOSED_CHANGED, GPU_ADDED, + PREPARE_SHUTDOWN, N_SIGNALS }; @@ -869,6 +870,13 @@ meta_backend_class_init (MetaBackendClass *klass) 0, NULL, NULL, NULL, G_TYPE_NONE, 1, META_TYPE_GPU); + signals[PREPARE_SHUTDOWN] = + g_signal_new ("prepare-shutdown", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, NULL, + G_TYPE_NONE, 0); mutter_stage_views = g_getenv ("MUTTER_STAGE_VIEWS"); stage_views_disabled = g_strcmp0 (mutter_stage_views, "0") == 0; @@ -1485,6 +1493,12 @@ meta_release_backend (void) g_clear_object (&_backend); } +void +meta_backend_prepare_shutdown (MetaBackend *backend) +{ + g_signal_emit (backend, signals[PREPARE_SHUTDOWN], 0); +} + /** * meta_is_stage_views_enabled: * diff --git a/src/core/main.c b/src/core/main.c index a6c6fc856..e204b68ff 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -344,6 +344,10 @@ static void meta_finalize (void) { MetaDisplay *display = meta_get_display (); + MetaBackend *backend = meta_get_backend (); + + if (backend) + meta_backend_prepare_shutdown (backend); if (display) meta_display_close (display,