Skip to content

Commit 69a577c

Browse files
ShahzaibIbrahimfedejeanne
authored andcommitted
Fix incorrect cursor scaling by using autoscale zoom
Previously, custom cursors were scaled using the raw device zoom (getNativeZoom), which could result in mismatched sizes on high-DPI displays. This change replaces it with DPIUtil.getZoomForAutoscaleProperty to align cursor scaling with the rest of the UI. Fixes #2308
1 parent 641b5a1 commit 69a577c

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5480,7 +5480,7 @@ LRESULT WM_SETCURSOR (long wParam, long lParam) {
54805480
if (control == null) return null;
54815481
Cursor cursor = control.findCursor ();
54825482
if (cursor != null) {
5483-
OS.SetCursor (Cursor.win32_getHandle(cursor, getNativeZoom()));
5483+
OS.SetCursor (Cursor.win32_getHandle(cursor, DPIUtil.getZoomForAutoscaleProperty(getNativeZoom())));
54845484
return LRESULT.ONE;
54855485
}
54865486
}

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2651,7 +2651,7 @@ LRESULT WM_SETCURSOR (long wParam, long lParam) {
26512651
RECT rect = new RECT ();
26522652
OS.GetClientRect (handle, rect);
26532653
if (OS.PtInRect (rect, pt)) {
2654-
OS.SetCursor (Cursor.win32_getHandle(cursor, getNativeZoom()));
2654+
OS.SetCursor (Cursor.win32_getHandle(cursor, DPIUtil.getZoomForAutoscaleProperty(getNativeZoom())));
26552655
switch (msg) {
26562656
case OS.WM_LBUTTONDOWN:
26572657
case OS.WM_RBUTTONDOWN:

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tracker.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ public void setCursor(Cursor newCursor) {
823823
checkWidget();
824824
clientCursor = newCursor;
825825
if (newCursor != null) {
826-
if (inEvent) OS.SetCursor (Cursor.win32_getHandle(clientCursor, getNativeZoom()));
826+
if (inEvent) OS.SetCursor (Cursor.win32_getHandle(clientCursor, DPIUtil.getZoomForAutoscaleProperty(getNativeZoom())));
827827
}
828828
}
829829

@@ -892,7 +892,7 @@ long transparentProc (long hwnd, long msg, long wParam, long lParam) {
892892
break;
893893
case OS.WM_SETCURSOR:
894894
if (clientCursor != null) {
895-
OS.SetCursor (Cursor.win32_getHandle(clientCursor, getNativeZoom()));
895+
OS.SetCursor (Cursor.win32_getHandle(clientCursor, DPIUtil.getZoomForAutoscaleProperty(getNativeZoom())));
896896
return 1;
897897
}
898898
if (resizeCursor != 0) {

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4663,7 +4663,7 @@ void setCursor () {
46634663
* is IDC_ARROW.
46644664
*/
46654665
Cursor cursor = findCursor ();
4666-
long hCursor = cursor == null ? OS.LoadCursor (0, OS.IDC_ARROW) : Cursor.win32_getHandle(cursor, getNativeZoom());
4666+
long hCursor = cursor == null ? OS.LoadCursor (0, OS.IDC_ARROW) : Cursor.win32_getHandle(cursor, DPIUtil.getZoomForAutoscaleProperty(getNativeZoom()));
46674667
OS.SetCursor (hCursor);
46684668
}
46694669

0 commit comments

Comments
 (0)