[mutter] tests/utils: Spawn Xwayland before X11 test client



commit 798fc63755db4ff68e8fb3be530ea7e14a0c54e8
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Thu Jan 21 18:59:50 2021 +0100

    tests/utils: Spawn Xwayland before X11 test client
    
    This is so we can add our async waiter up front. Using
    XOpenDisplay(NULL) didn't work; for some reason it dead locked when
    XInitThreads() had been called prior.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1681>

 src/tests/test-utils.c | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)
---
diff --git a/src/tests/test-utils.c b/src/tests/test-utils.c
index dc8de3175c..ca332a0b91 100644
--- a/src/tests/test-utils.c
+++ b/src/tests/test-utils.c
@@ -422,6 +422,18 @@ test_client_alarm_filter (MetaX11Display        *x11_display,
     return FALSE;
 }
 
+static gpointer
+spawn_xwayland (gpointer user_data)
+{
+  xcb_connection_t *connection;
+
+  connection = xcb_connect (NULL, NULL);
+  g_assert_nonnull (connection);
+  xcb_disconnect (connection);
+
+  return NULL;
+}
+
 TestClient *
 test_client_new (const char          *id,
                  MetaWindowClientType type,
@@ -474,7 +486,22 @@ test_client_new (const char          *id,
   client->loop = g_main_loop_new (NULL, FALSE);
 
   if (client->type == META_WINDOW_CLIENT_TYPE_X11)
-    client->waiter = async_waiter_new ();
+    {
+      MetaDisplay *display = meta_get_display ();
+
+      if (!display->x11_display)
+        {
+          GThread *thread;
+
+          thread = g_thread_new ("Mutter Spawn Xwayland Thread",
+                                 spawn_xwayland,
+                                 NULL);
+          test_wait_for_x11_display ();
+          g_thread_join (thread);
+        }
+
+      client->waiter = async_waiter_new ();
+    }
 
   return client;
 }


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