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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1863>
This commit is contained in:
Jonas Ådahl 2021-05-06 20:58:06 +02:00 committed by Marge Bot
parent dc97163bcd
commit 301d2c55c6
3 changed files with 21 additions and 7 deletions

View File

@ -308,19 +308,27 @@ meta_finalize (void)
{ {
MetaDisplay *display = meta_get_display (); MetaDisplay *display = meta_get_display ();
MetaBackend *backend = meta_get_backend (); MetaBackend *backend = meta_get_backend ();
#ifdef HAVE_WAYLAND
MetaWaylandCompositor *compositor = meta_wayland_compositor_get_default ();
#endif
if (backend) if (backend)
meta_backend_prepare_shutdown (backend); meta_backend_prepare_shutdown (backend);
#ifdef HAVE_WAYLAND #ifdef HAVE_WAYLAND
if (meta_is_wayland_compositor ()) if (compositor)
meta_wayland_finalize (); meta_wayland_compositor_prepare_shutdown (compositor);
#endif #endif
if (display) if (display)
meta_display_close (display, meta_display_close (display,
META_CURRENT_TIME); /* I doubt correct timestamps matter here */ 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 #ifdef HAVE_NATIVE_BACKEND
release_virtual_monitors (); release_virtual_monitors ();
#endif #endif

View File

@ -613,6 +613,15 @@ meta_wayland_get_private_xwayland_display_name (MetaWaylandCompositor *composito
return compositor->xwayland_manager.private_connection.name; 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 void
meta_wayland_finalize (void) meta_wayland_finalize (void)
{ {
@ -620,11 +629,6 @@ meta_wayland_finalize (void)
compositor = meta_wayland_compositor_get_default (); 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->seat, meta_wayland_seat_free);
g_clear_pointer (&compositor->display_name, g_free); g_clear_pointer (&compositor->display_name, g_free);

View File

@ -41,6 +41,8 @@ MetaWaylandCompositor * meta_wayland_compositor_new (MetaBackend *ba
void meta_wayland_compositor_setup (MetaWaylandCompositor *compositor); void meta_wayland_compositor_setup (MetaWaylandCompositor *compositor);
void meta_wayland_compositor_prepare_shutdown (MetaWaylandCompositor *compositor);
META_EXPORT_TEST META_EXPORT_TEST
MetaWaylandCompositor *meta_wayland_compositor_get_default (void); MetaWaylandCompositor *meta_wayland_compositor_get_default (void);