Skip to content

Commit bc7e9b0

Browse files
committed
[Win32] Fix hotspot of Cursor with accessibility scale factor
When a scale factor for cursors is applied via the accessibility settings, this factor currently only affects the cursor size itself but not the hotspot position calculation. In consequence, the hotspot is only scaled by the monitor zoom and not the accessibility scale factor, thus being misplaced. This change adapts the zoom to be used when scaling the hotspot coordinates.
1 parent 598ecd7 commit bc7e9b0

File tree

1 file changed

+7
-6
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics

1 file changed

+7
-6
lines changed

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Cursor.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ public CursorHandle createHandle(Device device, int zoom) {
631631
int scaledZoom = (int) (zoom * getPointerSizeScaleFactor());
632632
ImageData source = tempImage.getImageData(scaledZoom);
633633
tempImage.dispose();
634-
return setupCursorFromImageData(device, source, null, getHotpotXInPixels(zoom), getHotpotYInPixels(zoom));
634+
return setupCursorFromImageData(device, source, null, getHotpotXInPixels(scaledZoom), getHotpotYInPixels(scaledZoom));
635635
}
636636
}
637637

@@ -650,8 +650,8 @@ public CursorHandle createHandle(Device device, int zoom) {
650650
float accessibilityFactor = getPointerSizeScaleFactor();
651651
int scaledZoom = (int) (zoom * accessibilityFactor);
652652
ImageData scaledSource = DPIUtil.scaleImageData(device, this.source, scaledZoom, DEFAULT_ZOOM);
653-
return setupCursorFromImageData(device, scaledSource, null, getHotpotXInPixels(zoom),
654-
getHotpotYInPixels(zoom));
653+
return setupCursorFromImageData(device, scaledSource, null, getHotpotXInPixels(scaledZoom),
654+
getHotpotYInPixels(scaledZoom));
655655
}
656656
}
657657

@@ -680,7 +680,8 @@ private void validateMask(ImageData source, ImageData mask) {
680680

681681
@Override
682682
public CursorHandle createHandle(Device device, int zoom) {
683-
float scaledZoomFactor = zoom * getPointerSizeScaleFactor() / 100f;
683+
int scaledZoom = (int) (zoom * getPointerSizeScaleFactor());
684+
float scaledZoomFactor = scaledZoom / 100f;
684685
int scaledSourceWidth = Math.round(this.source.width * scaledZoomFactor);
685686
int scaledSourceHeight = Math.round(this.source.height * scaledZoomFactor);
686687
ImageData scaledSource = this.source.scaledTo(scaledSourceWidth, scaledSourceHeight);
@@ -690,8 +691,8 @@ public CursorHandle createHandle(Device device, int zoom) {
690691
int scaledMaskHeight = Math.round(this.mask.height * scaledZoomFactor);
691692
scaledMask = this.mask.scaledTo(scaledMaskWidth, scaledMaskHeight);
692693
}
693-
return setupCursorFromImageData(device, scaledSource, scaledMask, getHotpotXInPixels(zoom),
694-
getHotpotYInPixels(zoom));
694+
return setupCursorFromImageData(device, scaledSource, scaledMask, getHotpotXInPixels(scaledZoom),
695+
getHotpotYInPixels(scaledZoom));
695696
}
696697
}
697698

0 commit comments

Comments
 (0)