-
Notifications
You must be signed in to change notification settings - Fork 20
[90] Fix cursor initialization when using fractional scaling #93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
...org.eclipse.gmf.runtime.gef.ui/src/org/eclipse/gmf/runtime/gef/ui/internal/l10n/Cursors.java
Outdated
Show resolved
Hide resolved
|
I tried out more configurations and I think this is the most promising one. I tested it with both the 2025-06 and 2025-09 and both yield good results. The only thing I'm not sure about is the auto-scaling introduced with b932e79 or whether Linux/MacOS should also always create a cursor using the 100% zoom image data. |
|
Right, there was an email about repo.eclipse.org temporarily being unavailable. I'll redo the ECA check later. |
I only have access to Linux (Fedora 42, Gnome, Wayland), but I tested this with all combinations of:
The only cases which gives invalid result are Eclipse < 2025-09 with
I don't have access to macOS, but I think at least for Windows and Linux, it looks like we could simply have: // Taken from org.eclipse.gef.internal.InternalGEFPlugin.java
private static Cursor createCursor(ImageDescriptor source, int hotspotX, int hotspotY) {
ImageDataProvider imageDataProvider = zoom -> getScaledImageData(source, zoom);
try {
// SWT version >= 3.131.0
Constructor<Cursor> ctor = Cursor.class.getConstructor(Device.class, ImageDataProvider.class, int.class,
int.class);
return ctor.newInstance(null, imageDataProvider, hotspotX, hotspotY);
} catch (NoSuchMethodException e) {
return new Cursor(null, imageDataProvider.getImageData(100), hotspotX, hotspotY);
} catch (ReflectiveOperationException e) {
throw new RuntimeException("Failed to instantiate Cursor", e); //$NON-NLS-1$
}
}
private static ImageData getScaledImageData(ImageDescriptor descriptor, int zoom) {
Image image = descriptor.createImage();
try {
return image.getImageData(zoom);
} finally {
image.dispose();
}
} |
That was my impression as well and also what we ended up doing in GEF. For MacOS, we had a similar bug report regarding the cursors and there the solution also was to use a zoom level of 100. So I think this would be a general solution: |
|
Sorry for the long silence, I was on vacation. |
Recent Eclipse version support fractional zoom level as opposed to 100% or 200% zoom. Because no icons exist for those levels, an IllegalArgumentException is thrown when trying to create the corresponding cursors. In order to solve this, one has to consider the following cases: 1) Newer SWT versions provide a Cursor constructor that accepts an ImageDataProvider. This constructor always creates image data matching the device zoom. 2) Win32: Older SWT versions automatically upscale the image data to match the device zoom. Therefore the original image data must be at 100% zoom. 3) On other operating systems, the image data should be pre-scaled, as no further scaling is done by SWT. Bug: eclipse-gmf-runtime#90





[90] Fix cursor initialization when using fractional scaling
Recent Eclipse version support fractional zoom level as opposed to 100% or 200% zoom. Because no icons exist for those levels, an IllegalArgumentException is thrown when trying to create the corresponding cursors.
In order to solve this, one has to consider the following cases:
Newer SWT versions provide a Cursor constructor that accepts an ImageDataProvider. This constructor always creates image data matching the device zoom.
Win32: Older SWT versions automatically upscale the image data to match the device zoom. Therefore the original image data must be at 100% zoom.
On other operating systems, the image data should be pre-scaled, as no further scaling is done by SWT.