From ea373cb0590dbf5f857f6d96b10759f005b4fc93 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 13 Feb 2023 20:24:54 -0500 Subject: [PATCH] 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: --- src/wayland/meta-wayland-surface.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c index 624c86a05..199b652ac 100644 --- a/src/wayland/meta-wayland-surface.c +++ b/src/wayland/meta-wayland-surface.c @@ -1044,19 +1044,24 @@ wl_surface_attach (struct wl_client *client, } if (wl_resource_get_version (surface_resource) >= - WL_SURFACE_OFFSET_SINCE_VERSION && - (dx != 0 || dy != 0)) + WL_SURFACE_OFFSET_SINCE_VERSION) { - wl_resource_post_error (surface_resource, - WL_SURFACE_ERROR_INVALID_OFFSET, - "Attaching with an offset is no longer allowed"); - return; + if (dx != 0 || dy != 0) + { + wl_resource_post_error (surface_resource, + WL_SURFACE_ERROR_INVALID_OFFSET, + "Attaching with an offset is no longer allowed"); + return; + } + } + else + { + pending->dx = dx; + pending->dy = dy; } pending->newly_attached = TRUE; pending->buffer = buffer; - pending->dx = dx; - pending->dy = dy; if (buffer) {