Files
gtk3/debian/patches/wayland-cursor-Sanity-check-cursor-image-size.patch
Simon McVittie d03dca1d46 d/patches: Update to upstream gtk-3-24 branch commit 3.24.34-204-g2fcc114870
Windows- and macOS-specific changes excluded.
2022-11-15 11:28:51 +00:00

59 lines
2.1 KiB
Diff

From: Robert Mader <robert.mader@posteo.de>
Date: Fri, 14 Jan 2022 20:28:52 +0100
Subject: wayland/cursor: Sanity check cursor image size
On Wayland it is a protocol violation to upload buffers with
dimensions that are not an integer multiple of the buffer scale.
Until recently, Mutter did not enforce this. When it started
doing so, some users started seeing crashes in GTK apps because the
cursor theme ended up with e.g. a 15x16 pixel image at scale of 2.
Add a small sanity check for this case.
Origin: upstream, 3.24.35, commit:da4066774b926880631af099469d308714b5606c
---
gdk/wayland/gdkcursor-wayland.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/gdk/wayland/gdkcursor-wayland.c b/gdk/wayland/gdkcursor-wayland.c
index a976c48..f5aa468 100644
--- a/gdk/wayland/gdkcursor-wayland.c
+++ b/gdk/wayland/gdkcursor-wayland.c
@@ -223,6 +223,7 @@ _gdk_wayland_cursor_get_buffer (GdkCursor *cursor,
if (wayland_cursor->wl_cursor)
{
struct wl_cursor_image *image;
+ int cursor_scale;
if (image_index >= wayland_cursor->wl_cursor->image_count)
{
@@ -234,12 +235,22 @@ _gdk_wayland_cursor_get_buffer (GdkCursor *cursor,
image = wayland_cursor->wl_cursor->images[image_index];
- *hotspot_x = image->hotspot_x / wayland_cursor->scale;
- *hotspot_y = image->hotspot_y / wayland_cursor->scale;
+ cursor_scale = wayland_cursor->scale;
+ if ((image->width % cursor_scale != 0) ||
+ (image->height % cursor_scale != 0))
+ {
+ g_warning (G_STRLOC " cursor image size (%dx%d) not an integer"
+ "multiple of scale (%d)", image->width, image->height,
+ cursor_scale);
+ cursor_scale = 1;
+ }
+
+ *hotspot_x = image->hotspot_x / cursor_scale;
+ *hotspot_y = image->hotspot_y / cursor_scale;
- *w = image->width / wayland_cursor->scale;
- *h = image->height / wayland_cursor->scale;
- *scale = wayland_cursor->scale;
+ *w = image->width / cursor_scale;
+ *h = image->height / cursor_scale;
+ *scale = cursor_scale;
return wl_cursor_image_get_buffer (image);
}