Skip to content

Commit 34a4d76

Browse files
committed
[Win32] Fix wrong width and height in Sash with SWT.SMOOTH when dragging
When dragging a Sash with the SWT.SMOOTH, the width and height of the sash are erroneously scaled up by the current zoom. It is caused by a recent change which replaced a setBoundsInPixels with a setBounds call still using the same pixel-based width and height values. This change adapts the according call to consistently use pixel-based values passed to the setBoundsInPixels method again. Fixes #2329
1 parent f0afb7f commit 34a4d76

File tree

1 file changed

+7
-5
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets

1 file changed

+7
-5
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -320,19 +320,21 @@ LRESULT WM_LBUTTONUP (long wParam, long lParam) {
320320
dragging = false;
321321
RECT rect = new RECT ();
322322
OS.GetWindowRect (handle, rect);
323-
int width = rect.right - rect.left;
324-
int height = rect.bottom - rect.top;
323+
int widthInPixels = rect.right - rect.left;
324+
int heightInPixels = rect.bottom - rect.top;
325325

326326
/* The event must be sent because doit flag is used */
327327
Event event = new Event ();
328-
event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle(lastX, lastY, width, height), getZoom()));
329-
drawBand (lastX, lastY, width, height);
328+
event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle(lastX, lastY, widthInPixels, heightInPixels), getZoom()));
329+
drawBand (lastX, lastY, widthInPixels, heightInPixels);
330330
sendSelectionEvent (SWT.Selection, event, true);
331331
if (isDisposed ()) return result;
332332
Rectangle bounds = event.getBounds();
333333
if (event.doit) {
334334
if ((style & SWT.SMOOTH) != 0) {
335-
setBounds (bounds.x, bounds.y, width, height);
335+
int xInPixels = Win32DPIUtils.pointToPixel(bounds.x, getZoom());
336+
int yInPixels = Win32DPIUtils.pointToPixel(bounds.y, getZoom());
337+
setBoundsInPixels (xInPixels, yInPixels, widthInPixels, heightInPixels);
336338
// widget could be disposed at this point
337339
}
338340
}

0 commit comments

Comments
 (0)