wayland: Don't overwrite surface offsets

The intention when the offset request was added to protocol was
that the attach request in a new enough protocol version should
require dx/dy to be zero, but ignore them otherwise.

The current code checks for 0, but then overwrites the existing
dx/dy with it, which renders an earlier wl_surface_offset() call
ineffective.

Fixes: #2622
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2843>
This commit is contained in:
Matthias Clasen 2023-02-13 20:24:54 -05:00
parent df653b95ad
commit ea373cb059

View File

@ -1044,19 +1044,24 @@ wl_surface_attach (struct wl_client *client,
} }
if (wl_resource_get_version (surface_resource) >= if (wl_resource_get_version (surface_resource) >=
WL_SURFACE_OFFSET_SINCE_VERSION && WL_SURFACE_OFFSET_SINCE_VERSION)
(dx != 0 || dy != 0)) {
if (dx != 0 || dy != 0)
{ {
wl_resource_post_error (surface_resource, wl_resource_post_error (surface_resource,
WL_SURFACE_ERROR_INVALID_OFFSET, WL_SURFACE_ERROR_INVALID_OFFSET,
"Attaching with an offset is no longer allowed"); "Attaching with an offset is no longer allowed");
return; return;
} }
}
else
{
pending->dx = dx;
pending->dy = dy;
}
pending->newly_attached = TRUE; pending->newly_attached = TRUE;
pending->buffer = buffer; pending->buffer = buffer;
pending->dx = dx;
pending->dy = dy;
if (buffer) if (buffer)
{ {