tests/wayland/client-utils: Bind newer wl_compositor

Out of the new metadata, only gather the preferred scale, which will be
used in a later commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4205>
This commit is contained in:
Jonas Ådahl 2025-01-08 12:06:03 +01:00 committed by Marge Bot
parent d579bf4a6c
commit ff58ef4bb7
2 changed files with 44 additions and 2 deletions

View File

@ -416,7 +416,7 @@ handle_registry_global (void *user_data,
{ {
display->compositor = display->compositor =
wl_registry_bind (registry, id, &wl_compositor_interface, wl_registry_bind (registry, id, &wl_compositor_interface,
MIN (version, 5)); MIN (version, 6));
} }
else if (strcmp (interface, wl_subcompositor_interface.name) == 0) else if (strcmp (interface, wl_subcompositor_interface.name) == 0)
{ {
@ -778,6 +778,44 @@ wayland_surface_init (WaylandSurface *surface)
{ {
} }
static void
surface_enter (void *user_data,
struct wl_surface *wl_surface,
struct wl_output *output)
{
}
static void
surface_leave (void *user_data,
struct wl_surface *wl_surface,
struct wl_output *output)
{
}
static void
surface_preferred_buffer_scale (void *user_data,
struct wl_surface *wl_surface,
int32_t factor)
{
WaylandSurface *surface = user_data;
surface->preferred_buffer_scale = factor;
}
static void
surface_preferred_buffer_transform (void *user_data,
struct wl_surface *wl_surface,
uint32_t transform)
{
}
static const struct wl_surface_listener surface_listener = {
surface_enter,
surface_leave,
surface_preferred_buffer_scale,
surface_preferred_buffer_transform,
};
WaylandSurface * WaylandSurface *
wayland_surface_new (WaylandDisplay *display, wayland_surface_new (WaylandDisplay *display,
const char *title, const char *title,
@ -794,7 +832,9 @@ wayland_surface_new (WaylandDisplay *display,
surface->default_height = default_height; surface->default_height = default_height;
surface->color = color; surface->color = color;
surface->wl_surface = wl_compositor_create_surface (display->compositor); surface->wl_surface = wl_compositor_create_surface (display->compositor);
wl_surface_set_user_data (surface->wl_surface, surface); wl_surface_add_listener (surface->wl_surface,
&surface_listener,
surface);
surface->xdg_surface = xdg_wm_base_get_xdg_surface (display->xdg_wm_base, surface->xdg_surface = xdg_wm_base_get_xdg_surface (display->xdg_wm_base,
surface->wl_surface); surface->wl_surface);
xdg_surface_add_listener (surface->xdg_surface, &xdg_surface_listener, xdg_surface_add_listener (surface->xdg_surface, &xdg_surface_listener,

View File

@ -90,6 +90,8 @@ typedef struct _WaylandSurface
uint32_t color; uint32_t color;
gboolean is_opaque; gboolean is_opaque;
int32_t preferred_buffer_scale;
} WaylandSurface; } WaylandSurface;
#define WAYLAND_TYPE_SURFACE (wayland_surface_get_type ()) #define WAYLAND_TYPE_SURFACE (wayland_surface_get_type ())