From 0b95f4f0583005debd2ab125813b7e43da91dd6f Mon Sep 17 00:00:00 2001 From: Shahzaib Ibrahim Date: Wed, 27 Aug 2025 15:12:02 +0200 Subject: [PATCH] Scale Table.DRAG_IMAGE_SIZE by zoom level instead of using fixed pixels The Table.DRAG_IMAGE_SIZE constant specifies the width of the drag image when a table 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/Table.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java index f3cf5c5fc0e..d72fe48a7b5 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java @@ -5745,8 +5745,9 @@ long windowProc (long hwnd, int msg, long wParam, long lParam) { OS.GetClientRect (handle, clientRect); TableItem item = _getItem (selection); RECT rect = item.getBounds (selection, 0, true, true, true); + int dragImageSizeInPixel = Win32DPIUtils.pointToPixel(DRAG_IMAGE_SIZE, getZoom()); if ((style & SWT.FULL_SELECTION) != 0) { - int width = DRAG_IMAGE_SIZE; + int width = dragImageSizeInPixel; rect.left = Math.max (clientRect.left, mousePos.x - width / 2); if (clientRect.right > rect.left + width) { rect.right = rect.left + width; @@ -5757,7 +5758,7 @@ long windowProc (long hwnd, int msg, long wParam, long lParam) { } long hRgn = OS.CreateRectRgn (rect.left, rect.top, rect.right, rect.bottom); while ((selection = (int)OS.SendMessage (handle, OS.LVM_GETNEXTITEM, selection, OS.LVNI_SELECTED)) != -1) { - if (rect.bottom - rect.top > DRAG_IMAGE_SIZE) break; + if (rect.bottom - rect.top > dragImageSizeInPixel) break; if (rect.bottom > clientRect.bottom) break; RECT itemRect = item.getBounds (selection, 0, true, true, true); long rectRgn = OS.CreateRectRgn (rect.left, itemRect.top, rect.right, itemRect.bottom);