wayland: Don't crash during DND with Cairo renderer
authorBenjamin Otte <otte@redhat.com>
Tue, 7 Mar 2023 04:50:08 +0000 (05:50 +0100)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 8 Mar 2023 01:16:59 +0000 (20:16 -0500)
Attaching buffers with offsets is forbidden now and nobody
checked the Cairo renderer.

gdk/wayland/gdksurface-wayland.c

index 21488fc987b5f22650ee9e955097ca72d35df4cc..a76a2c7247ea8a1435addd758af7971f1d338515 100644 (file)
@@ -561,8 +561,14 @@ gdk_wayland_surface_attach_image (GdkSurface           *surface,
   /* Attach this new buffer to the surface */
   wl_surface_attach (impl->display_server.wl_surface,
                      _gdk_wayland_shm_surface_get_wl_buffer (cairo_surface),
-                     impl->pending_buffer_offset_x,
-                     impl->pending_buffer_offset_y);
+                     0, 0);
+
+  if ((impl->pending_buffer_offset_x || impl->pending_buffer_offset_y) &&
+      wl_surface_get_version (impl->display_server.wl_surface) >=
+      WL_SURFACE_OFFSET_SINCE_VERSION)
+    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;