From b8a259a2ae9b80aff9b79c66255804b9fbd8c8e0 Mon Sep 17 00:00:00 2001 From: Shahzaib Ibrahim Date: Thu, 21 Aug 2025 13:49:39 +0200 Subject: [PATCH] Scale Tree.DRAG_IMAGE_SIZE by zoom level instead of using fixed pixels The Tree.DRAG_IMAGE_SIZE constant specifies the width of the drag image when a tree item is dragged. Previously, this value was fixed in pixels, which caused the drag image to appear too small on high-DPI monitors. This change redefines DRAG_IMAGE_SIZE in points and converts it to pixels based on the current zoom level, ensuring consistent drag image sizing across different display scales. --- .../Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java index 14cc9c49f7c..e684c1188a6 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java @@ -6071,8 +6071,9 @@ long windowProc (long hwnd, int msg, long wParam, long lParam) { RECT clientRect = new RECT (); OS.GetClientRect(handle, clientRect); RECT rect = items [0].getBounds (0, true, true, false); + int dragImageSizeInPixels = Win32DPIUtils.pointToPixel(DRAG_IMAGE_SIZE, getZoom()); if ((style & SWT.FULL_SELECTION) != 0) { - int width = DRAG_IMAGE_SIZE; + int width = dragImageSizeInPixels; rect.left = Math.max (clientRect.left, mousePos.x - width / 2); if (clientRect.right > rect.left + width) { rect.right = rect.left + width; @@ -6086,7 +6087,7 @@ long windowProc (long hwnd, int msg, long wParam, long lParam) { } long hRgn = OS.CreateRectRgn (rect.left, rect.top, rect.right, rect.bottom); for (int i = 1; i < count; i++) { - if (rect.bottom - rect.top > DRAG_IMAGE_SIZE) break; + if (rect.bottom - rect.top > dragImageSizeInPixels) break; if (rect.bottom > clientRect.bottom) break; RECT itemRect = items[i].getBounds (0, true, true, false); if ((style & SWT.FULL_SELECTION) != 0) {