From 301d2c55c61f8d61bb8391c2edfa8ca1ec6f60b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 6 May 2021 20:58:06 +0200 Subject: [PATCH] wayland: Make init and shutdown symmetric We first initialized the Wayland infrastructure, then the display, but on shutdown, we first teared down the Wayland infrastructure, then the display. Make things a bit more symmetric and tear down the display before Wayland. This however means we need to tear down some things Wayland a bit earlier than the rest. For now this is a separate function, but eventually, it can be replaced with a signal shared by the backend's 'prepare-shutdown' signal. Part-of: --- src/core/main.c | 12 ++++++++++-- src/wayland/meta-wayland.c | 14 +++++++++----- src/wayland/meta-wayland.h | 2 ++ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/core/main.c b/src/core/main.c index 9b5a3acb5..b7b5d1449 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -308,19 +308,27 @@ meta_finalize (void) { MetaDisplay *display = meta_get_display (); MetaBackend *backend = meta_get_backend (); +#ifdef HAVE_WAYLAND + MetaWaylandCompositor *compositor = meta_wayland_compositor_get_default (); +#endif if (backend) meta_backend_prepare_shutdown (backend); #ifdef HAVE_WAYLAND - if (meta_is_wayland_compositor ()) - meta_wayland_finalize (); + if (compositor) + meta_wayland_compositor_prepare_shutdown (compositor); #endif if (display) meta_display_close (display, META_CURRENT_TIME); /* I doubt correct timestamps matter here */ +#ifdef HAVE_WAYLAND + if (meta_is_wayland_compositor ()) + meta_wayland_finalize (); +#endif + #ifdef HAVE_NATIVE_BACKEND release_virtual_monitors (); #endif diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c index 4145e65c8..4febb7d06 100644 --- a/src/wayland/meta-wayland.c +++ b/src/wayland/meta-wayland.c @@ -613,6 +613,15 @@ meta_wayland_get_private_xwayland_display_name (MetaWaylandCompositor *composito return compositor->xwayland_manager.private_connection.name; } +void +meta_wayland_compositor_prepare_shutdown (MetaWaylandCompositor *compositor) +{ + meta_xwayland_shutdown (&compositor->xwayland_manager); + + if (compositor->wayland_display) + wl_display_destroy_clients (compositor->wayland_display); +} + void meta_wayland_finalize (void) { @@ -620,11 +629,6 @@ meta_wayland_finalize (void) compositor = meta_wayland_compositor_get_default (); - meta_xwayland_shutdown (&compositor->xwayland_manager); - - if (compositor->wayland_display) - wl_display_destroy_clients (compositor->wayland_display); - g_clear_pointer (&compositor->seat, meta_wayland_seat_free); g_clear_pointer (&compositor->display_name, g_free); diff --git a/src/wayland/meta-wayland.h b/src/wayland/meta-wayland.h index 6c655e427..38700cedd 100644 --- a/src/wayland/meta-wayland.h +++ b/src/wayland/meta-wayland.h @@ -41,6 +41,8 @@ MetaWaylandCompositor * meta_wayland_compositor_new (MetaBackend *ba void meta_wayland_compositor_setup (MetaWaylandCompositor *compositor); +void meta_wayland_compositor_prepare_shutdown (MetaWaylandCompositor *compositor); + META_EXPORT_TEST MetaWaylandCompositor *meta_wayland_compositor_get_default (void);