tests/wayland/client-utils: Track xdg_toplevel state
This allows tests to check whether a state is set or not at any given time. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3475>
This commit is contained in:
parent
69c7ca02f4
commit
594cdc5b49
@ -506,9 +506,10 @@ handle_xdg_toplevel_configure (void *data,
|
|||||||
struct xdg_toplevel *xdg_toplevel,
|
struct xdg_toplevel *xdg_toplevel,
|
||||||
int32_t width,
|
int32_t width,
|
||||||
int32_t height,
|
int32_t height,
|
||||||
struct wl_array *state)
|
struct wl_array *states)
|
||||||
{
|
{
|
||||||
WaylandSurface *surface = data;
|
WaylandSurface *surface = data;
|
||||||
|
uint32_t *p;
|
||||||
|
|
||||||
if (width == 0)
|
if (width == 0)
|
||||||
surface->width = surface->default_width;
|
surface->width = surface->default_width;
|
||||||
@ -519,6 +520,16 @@ handle_xdg_toplevel_configure (void *data,
|
|||||||
surface->height = surface->default_height;
|
surface->height = surface->default_height;
|
||||||
else
|
else
|
||||||
surface->height = height;
|
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
|
static void
|
||||||
@ -548,6 +559,9 @@ handle_xdg_surface_configure (void *data,
|
|||||||
xdg_surface_ack_configure (xdg_surface, serial);
|
xdg_surface_ack_configure (xdg_surface, serial);
|
||||||
wl_surface_commit (surface->wl_surface);
|
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);
|
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_toplevel, xdg_toplevel_destroy);
|
||||||
g_clear_pointer (&surface->xdg_surface, xdg_surface_destroy);
|
g_clear_pointer (&surface->xdg_surface, xdg_surface_destroy);
|
||||||
g_clear_pointer (&surface->wl_surface, wl_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);
|
G_OBJECT_CLASS (wayland_surface_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
@ -608,6 +624,13 @@ wayland_surface_new (WaylandDisplay *display,
|
|||||||
return surface;
|
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 *
|
const char *
|
||||||
lookup_property_value (WaylandDisplay *display,
|
lookup_property_value (WaylandDisplay *display,
|
||||||
const char *name)
|
const char *name)
|
||||||
|
@ -70,6 +70,9 @@ typedef struct _WaylandSurface
|
|||||||
struct xdg_surface *xdg_surface;
|
struct xdg_surface *xdg_surface;
|
||||||
struct xdg_toplevel *xdg_toplevel;
|
struct xdg_toplevel *xdg_toplevel;
|
||||||
|
|
||||||
|
GHashTable *pending_state;
|
||||||
|
GHashTable *current_state;
|
||||||
|
|
||||||
int default_width;
|
int default_width;
|
||||||
int default_height;
|
int default_height;
|
||||||
int width;
|
int width;
|
||||||
@ -103,6 +106,9 @@ WaylandSurface * wayland_surface_new (WaylandDisplay *display,
|
|||||||
int default_height,
|
int default_height,
|
||||||
uint32_t color);
|
uint32_t color);
|
||||||
|
|
||||||
|
gboolean wayland_surface_has_state (WaylandSurface *surface,
|
||||||
|
enum xdg_toplevel_state state);
|
||||||
|
|
||||||
void draw_surface (WaylandDisplay *display,
|
void draw_surface (WaylandDisplay *display,
|
||||||
struct wl_surface *surface,
|
struct wl_surface *surface,
|
||||||
int width,
|
int width,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user