[mutter/wip/carlosg/xwayland-startup-side-channel] xwayland: Do not block on Xwayland initialization



commit 31a40de07d506f172bd234610cb7a8da4ff987f9
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Nov 18 14:04:24 2019 +0100

    xwayland: Do not block on Xwayland initialization
    
    We artificially make Xwayland initialization synchronous, as we used
    to rely on MetaX11Display and other bits during meta_display_open().
    With support for Xwayland on demand and --no-x11, this is certainly
    not the case.
    
    So drop the main loop surrounding Xwayland initialization, the only
    required change is to defer the call to meta_display_init_x11() until
    Xwayland initialization is complete in the mandatory Xwayland case.
    
    If the backend is X11 and we don't run as a wayland compositor, we
    do want the X11 display right away, so explicitly do that in
    meta_display_open().

 src/core/display.c          |  3 ++-
 src/wayland/meta-xwayland.c | 23 +----------------------
 2 files changed, 3 insertions(+), 23 deletions(-)
---
diff --git a/src/core/display.c b/src/core/display.c
index fb797ab05..2a081f5d8 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -800,7 +800,8 @@ meta_display_open (void)
   display->selection = meta_selection_new (display);
   meta_clipboard_manager_init (display);
 
-  if (meta_get_x11_display_policy () == META_DISPLAY_POLICY_MANDATORY)
+  if (!meta_is_wayland_compositor () &&
+      META_IS_BACKEND_X11 (meta_get_backend ()))
     {
       if (!meta_display_init_x11 (display, &error))
         g_error ("Failed to start Xwayland: %s", error->message);
diff --git a/src/wayland/meta-xwayland.c b/src/wayland/meta-xwayland.c
index 85fa18a19..6647e6fd6 100644
--- a/src/wayland/meta-xwayland.c
+++ b/src/wayland/meta-xwayland.c
@@ -597,17 +597,6 @@ add_local_user_to_xhost (Display *xdisplay)
   XAddHost (xdisplay, &host_entry);
 }
 
-static void
-xserver_finished_init (MetaXWaylandManager *manager)
-{
-  /* At this point xwayland is all setup to start accepting
-   * connections so we can quit the transient initialization mainloop
-   * and unblock meta_wayland_init() to continue initializing mutter.
-   * */
-  g_main_loop_quit (manager->init_loop);
-  g_clear_pointer (&manager->init_loop, g_main_loop_unref);
-}
-
 static void
 init_xserver_cb (MetaDisplay  *display,
                  GTask        *task,
@@ -617,8 +606,7 @@ init_xserver_cb (MetaDisplay  *display,
     g_warning ("Could not initialize Xwayland services");
 
   /* Create the X11 display despite the Xwayland services' state */
-  if (meta_get_x11_display_policy () == META_DISPLAY_POLICY_ON_DEMAND)
-    meta_display_init_x11 (display, NULL);
+  meta_display_init_x11 (display, NULL);
 }
 
 static gboolean
@@ -626,7 +614,6 @@ on_displayfd_ready (int          fd,
                     GIOCondition condition,
                     gpointer     user_data)
 {
-  MetaXWaylandManager *manager = user_data;
   MetaDisplay *display = meta_get_display ();
   GTask *task;
   gboolean retval;
@@ -635,8 +622,6 @@ on_displayfd_ready (int          fd,
    * socket when it's ready. We don't care about the data
    * in the socket, just that it wrote something, since
    * that means it's ready. */
-  xserver_finished_init (manager);
-
   task = g_task_new (display, NULL,
                      (GAsyncReadyCallback) init_xserver_cb,
                      display);
@@ -731,12 +716,6 @@ meta_xwayland_start_xserver (MetaXWaylandManager *manager)
   manager->client = wl_client_create (manager->wayland_display,
                                       xwayland_client_fd[0]);
 
-  /* We need to run a mainloop until we know xwayland has a binding
-   * for our xserver interface at which point we can assume it's
-   * ready to start accepting connections. */
-  manager->init_loop = g_main_loop_new (NULL, FALSE);
-  g_main_loop_run (manager->init_loop);
-
   return TRUE;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]