Skip to content

Commit eb0f6a6

Browse files
ShahzaibIbrahimakoch-yatta
authored andcommitted
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.
1 parent 78d499e commit eb0f6a6

File tree

1 file changed

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

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6071,8 +6071,9 @@ long windowProc (long hwnd, int msg, long wParam, long lParam) {
60716071
RECT clientRect = new RECT ();
60726072
OS.GetClientRect(handle, clientRect);
60736073
RECT rect = items [0].getBounds (0, true, true, false);
6074+
int dragImageSizeInPixels = Win32DPIUtils.pointToPixel(DRAG_IMAGE_SIZE, getZoom());
60746075
if ((style & SWT.FULL_SELECTION) != 0) {
6075-
int width = DRAG_IMAGE_SIZE;
6076+
int width = dragImageSizeInPixels;
60766077
rect.left = Math.max (clientRect.left, mousePos.x - width / 2);
60776078
if (clientRect.right > rect.left + width) {
60786079
rect.right = rect.left + width;
@@ -6086,7 +6087,7 @@ long windowProc (long hwnd, int msg, long wParam, long lParam) {
60866087
}
60876088
long hRgn = OS.CreateRectRgn (rect.left, rect.top, rect.right, rect.bottom);
60886089
for (int i = 1; i < count; i++) {
6089-
if (rect.bottom - rect.top > DRAG_IMAGE_SIZE) break;
6090+
if (rect.bottom - rect.top > dragImageSizeInPixels) break;
60906091
if (rect.bottom > clientRect.bottom) break;
60916092
RECT itemRect = items[i].getBounds (0, true, true, false);
60926093
if ((style & SWT.FULL_SELECTION) != 0) {

0 commit comments

Comments
 (0)