Skip to content

Custom cursor is not shown when "swt.autoScale.updateOnRuntime" is enabled #2309

@ptziegler

Description

@ptziegler

Related to eclipse-platform/eclipse.platform.ui#3047 and #2308 but not quite the same.

On a monitor with 150% zoom, consider the following snippet:

package test;

import java.io.InputStream;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.ImageLoader;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class Snippet {
	public static void main(String[] args) {
		System.setProperty("swt.autoScale.updateOnRuntime", "true");
		Cursor cursor = new Cursor(null, getImageData(100), 0, 0);
		
		Shell shell = new Shell(SWT.NO_TRIM);
		shell.setSize(100, 100);
		shell.setCursor(cursor);
		shell.setBackground(new Color(0, 255, 0));
		shell.open();
		
		Display display = shell.getDisplay();
		while (!display.isDisposed()){ 
			display.readAndDispatch();
		}
		cursor.dispose();
	}
	
	private static ImageData getImageData(int zoom) {
		try (InputStream is = Snippet.class.getResourceAsStream("Seg_Add.png")) {
			ImageLoader imageLoader = new ImageLoader();
			return imageLoader.load(is)[0];
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
}

And the following icon:
Image

What I expect (see the other bug for the wrong scaling, otherwise this, except 50% larger):

Image

What I get:

Image

Tested with the 3.131.0.v20250709-1347.

Metadata

Metadata

Assignees

No one assigned

    Labels

    HiDPIIssues related to High resolution monitorsWindowsHappens on Windows OS

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions