Bug 578549 - [GTK3] Custom cursor images are always scaled by Cairo on HiDPI displays
Summary: [GTK3] Custom cursor images are always scaled by Cairo on HiDPI displays
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.23   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-02-02 16:45 EST by Jonathan Meier CLA
Modified: 2022-03-26 08:37 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Meier CLA 2022-02-02 16:45:00 EST
On GTK 3 custom cursor images are always automatically scaled by Cairo according to the DPI scale factor on HiDPI displays. This makes it impossible to provide high-quality cursor images for DPI scale factors larger than 1. E.g. on a display with a DPI scale factor of 2, if we provide a high-quality cursor image that is twice as large as the unscaled image, we end up with a cursor image that is 4 times as large as the unscaled image, since it is automatically scaled again by Cairo.

There is no issue on GTK 4, where cursor images are not automatically scaled and it is (correctly!) expected that an image already scaled according to the DPI scale factor is used when creating a cursor.

To reproduce the issue compare the behavior of Snippet119 between GTK 3 and GTK 4 on a HiDPI display where an unscaled image is used to create a cursor. On GTK 3 the cursor appears scaled on the screen. On GTK 4 the cursor appears unscaled and therefore small on the screen.

Note: fixing this issue is just the first of two steps to bring proper HiDPI support to custom cursor on GTK 3 and 4. In a second step, the two constructors of the Cursor class with ImageData parameters should be deprecated in favor of two new constructors with ImageDataProvider parameters that transparently handle the DPI scaling analogously to how this is already done in the Image class.

Possibly related/affected: Bug 515794 and Bug 515795.
Comment 1 Eclipse Genie CLA 2022-02-02 16:48:10 EST
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/190344
Comment 2 Jonathan Meier CLA 2022-02-02 16:49:03 EST
Please challenge my patch, in particular the native part:

- Do the two new functions (gdk_cairo_surface_create_from_pixbuf and gdk_cursor_new_from_surface) actually belong into GDK.java even though they are only in GTK 3? I think they do, but there's also a few GDK functions in GTK3.java.

- Are static functions excluded for GTK 4 using #define's in os.h fine or should they be dynamic? I think at least for gdk_cairo_surface_create_from_pixbuf static is the only option because GdkWindow (type of its last parameter) is no longer available on GTK 4, but gdk_cursor_new_from_surface could be dynamic without exclusion using a #define.
Comment 3 Alexander Kurtakov CLA 2022-03-25 09:43:17 EDT
I've tested the following combinations with and without the patch and the cursor was always small on Fedora 36 Gnome with gtk3 (3.24.31) and gtk4 (4.6.2).
* gtk3/wayland
* gtk3/xwayland
* gtk4/wayland
* gtk4/xwayland

Which Gtk 3 version do you run on? Could it be some other difference like DE ? I really don't see any difference.
Comment 4 Jonathan Meier CLA 2022-03-26 08:37:45 EDT
Thanks for testing! The difference seems to be the windowing system. The issue appears when running gtk3 (3.24.30) with x11 on Ubuntu (21.10). I cannot reproduce it either using wayland on the same system. Running gtk3 (3.22.30) with x11 on CentOS (8.5) also shows the issue. On that system I can't test with wayland because I can't even get GNOME to run a wayland session.