tests/wayland/client/utils: Add way to mark surface as opaque

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3475>
This commit is contained in:
Jonas Ådahl 2024-03-25 13:25:00 +01:00 committed by Marge Bot
parent 594cdc5b49
commit f23e1218e3
2 changed files with 14 additions and 0 deletions

View File

@ -550,11 +550,16 @@ handle_xdg_surface_configure (void *data,
uint32_t serial)
{
WaylandSurface *surface = data;
struct wl_region *opaque_region;
draw_surface (surface->display,
surface->wl_surface,
surface->width, surface->height,
surface->color);
opaque_region = wl_compositor_create_region (surface->display->compositor);
wl_region_add (opaque_region, 0, 0, surface->width, surface->height);
wl_surface_set_opaque_region (surface->wl_surface, opaque_region);
wl_region_destroy (opaque_region);
xdg_surface_ack_configure (xdg_surface, serial);
wl_surface_commit (surface->wl_surface);
@ -631,6 +636,12 @@ wayland_surface_has_state (WaylandSurface *surface,
return g_hash_table_contains (surface->current_state, GUINT_TO_POINTER (state));
}
void
wayland_surface_set_opaque (WaylandSurface *surface)
{
surface->is_opaque = TRUE;
}
const char *
lookup_property_value (WaylandDisplay *display,
const char *name)

View File

@ -79,6 +79,7 @@ typedef struct _WaylandSurface
int height;
uint32_t color;
gboolean is_opaque;
} WaylandSurface;
#define WAYLAND_TYPE_SURFACE (wayland_surface_get_type ())
@ -109,6 +110,8 @@ WaylandSurface * wayland_surface_new (WaylandDisplay *display,
gboolean wayland_surface_has_state (WaylandSurface *surface,
enum xdg_toplevel_state state);
void wayland_surface_set_opaque (WaylandSurface *surface);
void draw_surface (WaylandDisplay *display,
struct wl_surface *surface,
int width,