From 80811069ac264fb3a9de73b2e1d2ad57eac053b5 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 20 Mar 2024 21:09:09 -0400 Subject: [PATCH] x11: Handle callback cursors For these cursors, get the texture for the cursor image by calling the callback. We always use scale 1. --- gdk/x11/gdkcursor-x11.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/gdk/x11/gdkcursor-x11.c b/gdk/x11/gdkcursor-x11.c index 33a126075f..04603efbe6 100644 --- a/gdk/x11/gdkcursor-x11.c +++ b/gdk/x11/gdkcursor-x11.c @@ -370,11 +370,33 @@ gdk_x11_display_get_xcursor (GdkDisplay *display, if (gdk_cursor_get_name (cursor)) xcursor = gdk_x11_cursor_create_for_name (display, gdk_cursor_get_name (cursor)); - else + else if (gdk_cursor_get_texture (cursor)) xcursor = gdk_x11_cursor_create_for_texture (display, gdk_cursor_get_texture (cursor), gdk_cursor_get_hotspot_x (cursor), gdk_cursor_get_hotspot_y (cursor)); + else + { + int size; + GdkTexture *texture; + int width, height; + int hotspot_x, hotspot_y; + + size = XcursorGetDefaultSize (GDK_DISPLAY_XDISPLAY (display)); + + texture = gdk_cursor_get_texture_for_size (cursor, size, 1, + &width, &height, + &hotspot_x, &hotspot_y); + + if (texture) + { + xcursor = gdk_x11_cursor_create_for_texture (display, + texture, + hotspot_x, + hotspot_y); + g_object_unref (texture); + } + } if (xcursor != None) {