tests/wayland-test-client-utils: Add helper to wait for event

Useful for synchronization.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2770>
This commit is contained in:
Jonas Ådahl 2022-11-15 10:47:50 +01:00 committed by Marge Bot
parent aa0b1fbc88
commit d97c160122
2 changed files with 27 additions and 0 deletions

View File

@ -446,3 +446,27 @@ wait_for_view_verified (WaylandDisplay *display,
g_error ("%s: Failed to dispatch Wayland display", __func__);
}
}
static void
on_sync_event (WaylandDisplay *display,
uint32_t serial,
uint32_t *expected_serial)
{
g_assert_cmpuint (serial, ==, *expected_serial);
*expected_serial = serial + 1;
}
void
wait_for_sync_event (WaylandDisplay *display,
uint32_t serial)
{
uint32_t expected_serial = serial;
g_signal_connect (display, "sync-event", G_CALLBACK (on_sync_event),
&expected_serial);
while (expected_serial != serial + 1)
{
if (wl_display_dispatch (display->display) == -1)
g_error ("%s: Failed to dispatch Wayland display", __func__);
}
}

View File

@ -66,4 +66,7 @@ void wait_for_effects_completed (WaylandDisplay *display,
void wait_for_view_verified (WaylandDisplay *display,
int sequence);
void wait_for_sync_event (WaylandDisplay *display,
uint32_t serial);
#endif /* WAYLAND_TEST_CLIENT_UTILS_H */