diff --git a/src/tests/wayland-test-clients/wayland-test-client-utils.c b/src/tests/wayland-test-clients/wayland-test-client-utils.c index 065af8fd3..918fda0f6 100644 --- a/src/tests/wayland-test-clients/wayland-test-client-utils.c +++ b/src/tests/wayland-test-clients/wayland-test-client-utils.c @@ -506,9 +506,10 @@ handle_xdg_toplevel_configure (void *data, struct xdg_toplevel *xdg_toplevel, int32_t width, int32_t height, - struct wl_array *state) + struct wl_array *states) { WaylandSurface *surface = data; + uint32_t *p; if (width == 0) surface->width = surface->default_width; @@ -519,6 +520,16 @@ handle_xdg_toplevel_configure (void *data, surface->height = surface->default_height; else surface->height = height; + + g_assert_null (surface->pending_state); + surface->pending_state = g_hash_table_new (NULL, NULL); + + wl_array_for_each (p, states) + { + uint32_t state = *p; + + g_hash_table_add (surface->pending_state, GUINT_TO_POINTER (state)); + } } static void @@ -548,6 +559,9 @@ handle_xdg_surface_configure (void *data, xdg_surface_ack_configure (xdg_surface, serial); wl_surface_commit (surface->wl_surface); + g_clear_pointer (&surface->current_state, g_hash_table_unref); + surface->current_state = g_steal_pointer (&surface->pending_state); + g_signal_emit (surface->display, signals[SURFACE_PAINTED], 0, surface); } @@ -563,6 +577,8 @@ wayland_surface_dispose (GObject *object) g_clear_pointer (&surface->xdg_toplevel, xdg_toplevel_destroy); g_clear_pointer (&surface->xdg_surface, xdg_surface_destroy); g_clear_pointer (&surface->wl_surface, wl_surface_destroy); + g_clear_pointer (&surface->pending_state, g_hash_table_unref); + g_clear_pointer (&surface->current_state, g_hash_table_unref); G_OBJECT_CLASS (wayland_surface_parent_class)->dispose (object); } @@ -608,6 +624,13 @@ wayland_surface_new (WaylandDisplay *display, return surface; } +gboolean +wayland_surface_has_state (WaylandSurface *surface, + enum xdg_toplevel_state state) +{ + return g_hash_table_contains (surface->current_state, GUINT_TO_POINTER (state)); +} + const char * lookup_property_value (WaylandDisplay *display, const char *name) diff --git a/src/tests/wayland-test-clients/wayland-test-client-utils.h b/src/tests/wayland-test-clients/wayland-test-client-utils.h index a6f091f26..31779c4ac 100644 --- a/src/tests/wayland-test-clients/wayland-test-client-utils.h +++ b/src/tests/wayland-test-clients/wayland-test-client-utils.h @@ -70,6 +70,9 @@ typedef struct _WaylandSurface struct xdg_surface *xdg_surface; struct xdg_toplevel *xdg_toplevel; + GHashTable *pending_state; + GHashTable *current_state; + int default_width; int default_height; int width; @@ -103,6 +106,9 @@ WaylandSurface * wayland_surface_new (WaylandDisplay *display, int default_height, uint32_t color); +gboolean wayland_surface_has_state (WaylandSurface *surface, + enum xdg_toplevel_state state); + void draw_surface (WaylandDisplay *display, struct wl_surface *surface, int width,