From 798fc63755db4ff68e8fb3be530ea7e14a0c54e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 21 Jan 2021 18:59:50 +0100 Subject: [PATCH] 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: --- 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 dc8de3175..ca332a0b9 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; }