[mutter] wayland/surface: Add support for wl_surface.offset



commit 370de58868070971192a91a0ee413a5680c56ed5
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Mon Mar 22 11:49:11 2021 +0100

    wayland/surface: Add support for wl_surface.offset
    
    This aims to replace the x,y arguments in wl_surface.attach(); meaning
    it can be used more sanely together with EGL, and at all when using
    Vulkan.
    
    The most common use case for the offset is setting the hotspot of DND
    surfaces.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1905>

 .gitlab-ci.yml                      |  7 ++++++-
 meson.build                         |  2 +-
 src/wayland/meta-wayland-surface.c  | 29 +++++++++++++++++++++++++++--
 src/wayland/meta-wayland-versions.h |  2 +-
 4 files changed, 35 insertions(+), 5 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 2090cd8abb..0701ab5960 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -17,7 +17,7 @@ variables:
 .mutter.fedora:35@common:
   variables:
     FDO_DISTRIBUTION_VERSION: 35
-    BASE_TAG: '2022-03-04.0'
+    BASE_TAG: '2022-03-04.1'
     FDO_DISTRIBUTION_PACKAGES:
       asciidoc
       clang
@@ -39,6 +39,7 @@ variables:
       dnf builddep -y mutter --setopt=install_weak_deps=False &&
       dnf builddep -y gnome-shell --setopt=install_weak_deps=False &&
       dnf builddep -y libinput --setopt=install_weak_deps=False &&
+      dnf builddep -y wayland --setopt=install_weak_deps=False &&
       dnf builddep -y wayland-protocols --setopt=install_weak_deps=False &&
 
       # For Xwayland
@@ -68,6 +69,10 @@ variables:
         https://gitlab.gnome.org/GNOME/gsettings-desktop-schemas.git \
         42.beta . &&
 
+      ./.gitlab-ci/install-meson-project.sh \
+        https://gitlab.freedesktop.org/wayland/wayland.git \
+        1.20.0 . &&
+
       ./.gitlab-ci/install-meson-project.sh \
         https://gitlab.freedesktop.org/wayland/wayland-protocols.git \
         1.25 . &&
diff --git a/meson.build b/meson.build
index ebe3f80141..404885404c 100644
--- a/meson.build
+++ b/meson.build
@@ -40,7 +40,7 @@ udev_req = '>= 228'
 gudev_req = '>= 232'
 
 # wayland version requirements
-wayland_server_req = '>= 1.18'
+wayland_server_req = '>= 1.20'
 wayland_protocols_req = '>= 1.25'
 
 # native backend version requirements
diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
index 499f77b912..fcac0af4f1 100644
--- a/src/wayland/meta-wayland-surface.c
+++ b/src/wayland/meta-wayland-surface.c
@@ -553,10 +553,11 @@ meta_wayland_surface_state_merge_into (MetaWaylandSurfaceState *from,
 
       to->newly_attached = TRUE;
       to->buffer = from->buffer;
-      to->dx = from->dx;
-      to->dy = from->dy;
     }
 
+  to->dx += from->dx;
+  to->dy += from->dy;
+
   wl_list_insert_list (&to->frame_callback_list, &from->frame_callback_list);
   wl_list_init (&from->frame_callback_list);
 
@@ -1055,6 +1056,16 @@ wl_surface_attach (struct wl_client   *client,
                               pending->buffer);
     }
 
+  if (wl_resource_get_version (surface_resource) >=
+      WL_SURFACE_OFFSET_SINCE_VERSION &&
+      (dx != 0 || dy != 0))
+    {
+      wl_resource_post_error (surface_resource,
+                              WL_SURFACE_ERROR_INVALID_OFFSET,
+                              "Attaching with an offset is no longer allowed");
+      return;
+    }
+
   pending->newly_attached = TRUE;
   pending->buffer = buffer;
   pending->dx = dx;
@@ -1259,6 +1270,19 @@ wl_surface_damage_buffer (struct wl_client   *client,
   cairo_region_union_rectangle (pending->buffer_damage, &rectangle);
 }
 
+static void
+wl_surface_offset (struct wl_client   *client,
+                   struct wl_resource *surface_resource,
+                   int32_t             dx,
+                   int32_t             dy)
+{
+  MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
+  MetaWaylandSurfaceState *pending = surface->pending_state;
+
+  pending->dx = dx;
+  pending->dy = dy;
+}
+
 static const struct wl_surface_interface meta_wayland_wl_surface_interface = {
   wl_surface_destroy,
   wl_surface_attach,
@@ -1270,6 +1294,7 @@ static const struct wl_surface_interface meta_wayland_wl_surface_interface = {
   wl_surface_set_buffer_transform,
   wl_surface_set_buffer_scale,
   wl_surface_damage_buffer,
+  wl_surface_offset,
 };
 
 static void
diff --git a/src/wayland/meta-wayland-versions.h b/src/wayland/meta-wayland-versions.h
index cd1a73ea63..8ffb5d9ef6 100644
--- a/src/wayland/meta-wayland-versions.h
+++ b/src/wayland/meta-wayland-versions.h
@@ -35,7 +35,7 @@
 /* #define META_WL_BUFFER_VERSION     1 */
 
 /* Global/master objects (version exported by wl_registry and negotiated through bind) */
-#define META_WL_COMPOSITOR_VERSION          4
+#define META_WL_COMPOSITOR_VERSION          5
 #define META_WL_DATA_DEVICE_MANAGER_VERSION 3
 #define META_XDG_WM_BASE_VERSION            4
 #define META_ZXDG_SHELL_V6_VERSION          1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]