wayland/surface: Use wl_surface_offset() instead of x,y of attach()
authorJonas Ådahl <jadahl@gmail.com>
Mon, 22 Mar 2021 10:51:37 +0000 (11:51 +0100)
committerJonas Ådahl <jadahl@gmail.com>
Fri, 14 Jan 2022 08:27:07 +0000 (09:27 +0100)
This makes the hotspot of DND surfaces work when using the Vulkan and
OpenGL renderers.

This bumps the CI image used to the newly built image. This is needed to
install a new enough libwayland-client.so needed for wl_surface.offset.

This is done by adding wayland as a meson subproject, building it
on-demand if the version in the system is not new enough. As
libwayland-client.so is pulled in implicitly when linking to gtk4, the
compile step needs LD_LIBRARY_PATH set to make ld find the right library
to link to.

.gitlab-ci.yml
.gitlab-ci/fedora.Dockerfile
gdk/wayland/gdkcairocontext-wayland.c
gdk/wayland/gdkdisplay-wayland.c
gdk/wayland/gdksurface-wayland.c
meson.build
subprojects/wayland.wrap [new file with mode: 0644]

index 8b01ec772c875aaf1c39ed7a4f15127298e6ee68..279faf373ba3b0559d26d85e6e3a2d8f4bf82d25 100644 (file)
@@ -25,7 +25,7 @@ variables:
   BACKEND_FLAGS: "-Dx11-backend=true -Dwayland-backend=true -Dbroadway-backend=true"
   FEATURE_FLAGS: "-Dvulkan=enabled -Dcloudproviders=enabled"
   MESON_TEST_TIMEOUT_MULTIPLIER: 3
-  FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v35"
+  FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v36"
   FLATPAK_IMAGE: "registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master"
 
 .only-default:
@@ -88,7 +88,7 @@ fedora-x86_64:
     - meson compile -C _build
     - meson install -C _build
     - PKG_CONFIG_PATH=${CI_PROJECT_DIR}/_install/lib64/pkgconfig:${CI_PROJECT_DIR}/_install/share/pkgconfig meson setup _build_hello examples/hello
-    - meson compile -C _build_hello
+    - LD_LIBRARY_PATH=${CI_PROJECT_DIR}/_install/lib64 meson compile -C _build_hello
     - .gitlab-ci/run-tests.sh _build x11
     - .gitlab-ci/run-tests.sh _build wayland
     - .gitlab-ci/run-tests.sh _build waylandgles
index 97ece0e7ff4294b9502d36ce276ace65236e6e1d..31bb1697f55a54c70c794760b3e38a7bb72436d2 100644 (file)
@@ -95,6 +95,8 @@ RUN dnf -y install \
     weston-libs \
     which \
     xorg-x11-server-Xvfb \
+ && dnf install -y 'dnf-command(builddep)' \
+ && dnf builddep -y wayland \
  && dnf clean all
 
 # Enable sudo for wheel users
index e05ea6a7d9947d329df0b91c835f97f305718c76..b75353b5771a5bd99d05eec917b5947d047fdaf9 100644 (file)
@@ -181,8 +181,8 @@ gdk_wayland_cairo_context_end_frame (GdkDrawContext *draw_context,
   GdkWaylandCairoContext *self = GDK_WAYLAND_CAIRO_CONTEXT (draw_context);
   GdkSurface *surface = gdk_draw_context_get_surface (draw_context);
 
-  gdk_wayland_surface_attach_image (surface, self->paint_surface, painted);
   gdk_wayland_surface_sync (surface);
+  gdk_wayland_surface_attach_image (surface, self->paint_surface, painted);
   gdk_wayland_surface_request_frame (surface);
 
   gdk_profiler_add_mark (GDK_PROFILER_CURRENT_TIME, 0, "wayland", "surface commit");
index 2017e90518c220bbdebca16fbbc3a7fc98d3b0c8..1401d914156c6c2919a4a30b94a9cae90ec4d9a2 100644 (file)
@@ -366,7 +366,8 @@ gdk_registry_handle_global (void               *data,
   if (strcmp (interface, "wl_compositor") == 0)
     {
       display_wayland->compositor =
-        wl_registry_bind (display_wayland->wl_registry, id, &wl_compositor_interface, MIN (version, 4));
+        wl_registry_bind (display_wayland->wl_registry, id,
+                          &wl_compositor_interface, MIN (version, 5));
       display_wayland->compositor_version = MIN (version, 4);
     }
   else if (strcmp (interface, "wl_shm") == 0)
index 93498d7cb5df509bff232f4ba7afe935f6b4e069..8836b265b81baf5449675af0b8c72a17a1b71c0b 100644 (file)
@@ -935,12 +935,33 @@ gdk_wayland_surface_attach_image (GdkSurface           *surface,
     }
 }
 
+static void
+gdk_wayland_surface_sync_offset (GdkSurface *surface)
+{
+  GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
+
+  if (wl_surface_get_version (impl->display_server.wl_surface) <
+      WL_SURFACE_OFFSET_SINCE_VERSION)
+    return;
+
+  if (impl->pending_buffer_offset_x == 0 &&
+      impl->pending_buffer_offset_y == 0)
+    return;
+
+  wl_surface_offset (impl->display_server.wl_surface,
+                     impl->pending_buffer_offset_x,
+                     impl->pending_buffer_offset_y);
+  impl->pending_buffer_offset_x = 0;
+  impl->pending_buffer_offset_y = 0;
+}
+
 void
 gdk_wayland_surface_sync (GdkSurface *surface)
 {
   gdk_wayland_surface_sync_shadow (surface);
   gdk_wayland_surface_sync_opaque_region (surface);
   gdk_wayland_surface_sync_input_region (surface);
+  gdk_wayland_surface_sync_offset (surface);
 }
 
 static gboolean
index a40473c12add929f7fd9a87ce9b1e7256983b6b7..c74ca09284e23a0ad77cf7dfca936d0d71a76790 100644 (file)
@@ -17,7 +17,7 @@ cairo_req          = '>= 1.14.0'
 gdk_pixbuf_req     = '>= 2.30.0'
 introspection_req  = '>= 1.39.0'
 wayland_proto_req  = '>= 1.21'
-wayland_req        = '>= 1.16.91'
+wayland_req        = '>= 1.20.0'
 graphene_req       = '>= 1.9.1'
 epoxy_req          = '>= 1.4'
 cloudproviders_req = '>= 0.3.1'
@@ -510,9 +510,12 @@ cdata.set('HAVE_PANGOFT', pangoft_dep.found())
 
 wayland_pkgs = []
 if wayland_enabled
-  wlclientdep    = dependency('wayland-client', version:  wayland_req)
+  wlclientdep    = dependency('wayland-client', version:  wayland_req,
+                              fallback: 'wayland',
+                              default_options: ['documentation=false'])
   wlprotocolsdep = dependency('wayland-protocols', version: wayland_proto_req, required: false)
-  wlegldep       = dependency('wayland-egl')
+  wlegldep       = dependency('wayland-egl',
+                              fallback: 'wayland')
 
   if not wlprotocolsdep.found()
     wlproto_dir = subproject('wayland-protocols').get_variable('wayland_protocols_srcdir')
diff --git a/subprojects/wayland.wrap b/subprojects/wayland.wrap
new file mode 100644 (file)
index 0000000..5be67bf
--- /dev/null
@@ -0,0 +1,8 @@
+[wrap-git]
+directory=wayland
+url=https://gitlab.freedesktop.org/wayland/wayland.git
+revision=main
+depth=1
+
+[provide]
+dependency_names = wayland-client, wayland-egl