Skip to content

Commit 778d04b

Browse files
Fix Cursor hotspot coordinate calculation
While retrieving the handle for the cursor for specific zoom, currently we scale up the cursor source image but not the hotspot coordinates. This commit ensures we have per-zoom coordinates for the cursor.
1 parent 13934ee commit 778d04b

File tree

1 file changed

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

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,11 +429,11 @@ public static Long win32_getHandle (Cursor cursor, int zoom) {
429429
source = DPIUtil.scaleImageData(cursor.device, cursor.source, zoom, DEFAULT_ZOOM);
430430
}
431431
if (cursor.isIcon) {
432-
Cursor newCursor = new Cursor(cursor.device, source, cursor.hotspotX, cursor.hotspotY);
432+
Cursor newCursor = new Cursor(cursor.device, source, Win32DPIUtils.pointToPixel(cursor.hotspotX, zoom), Win32DPIUtils.pointToPixel(cursor.hotspotY, zoom));
433433
cursor.setHandleForZoomLevel(newCursor.handle, zoom);
434434
} else {
435435
ImageData mask = DPIUtil.scaleImageData(cursor.device, cursor.mask, zoom, DEFAULT_ZOOM);
436-
Cursor newCursor = new Cursor(cursor.device, source, mask, cursor.hotspotX, cursor.hotspotY);
436+
Cursor newCursor = new Cursor(cursor.device, source, mask, Win32DPIUtils.pointToPixel(cursor.hotspotX, zoom), Win32DPIUtils.pointToPixel(cursor.hotspotY, zoom));
437437
cursor.setHandleForZoomLevel(newCursor.handle, zoom);
438438
}
439439
}

0 commit comments

Comments
 (0)