xwayland: Make setup/teardown a bit more symmetrical

We setup Xwayland in an early phase of the X11 display, before we had a
MetaX11Display, and teared down in a couple of places happening when
tearing down the Xwayland integration if the X server died or
terminated. It was a bit hard to follow what happened and when it
happened. Attempt to clean this up a bit, with things being structured
as follows:

 * Early during X11 display connection setup, only setup the rudimentary
   X11 hooks, being the libX11 error callbacks, and adding the local
   user to XHost.

 * Move "initialize Xwayland component" code to a new
   'x11-display-setup' signal handler. Things setup here are cleaned up
   in the 'x11-display-closing' handler.

 * Connect to 'x11-display-setup' and 'x11-display-closing' up front,
   and stay connected to these two.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1796>
This commit is contained in:
Jonas Ådahl
2021-03-23 16:47:45 +01:00
parent 69f9b36643
commit b4fe1fdd95
6 changed files with 62 additions and 25 deletions

View File

@ -889,8 +889,12 @@ meta_display_new (MetaContext *context,
#ifdef HAVE_WAYLAND
if (meta_is_wayland_compositor ())
{
MetaWaylandCompositor *wayland_compositor =
meta_wayland_compositor_get_default ();
MetaX11DisplayPolicy x11_display_policy;
meta_wayland_compositor_init_display (wayland_compositor, display);
x11_display_policy = meta_context_get_x11_display_policy (context);
if (x11_display_policy == META_X11_DISPLAY_POLICY_MANDATORY)
{