diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/Win32DPIUtils.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/Win32DPIUtils.java index 7d5515dfa5b..44ddd14961a 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/Win32DPIUtils.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/Win32DPIUtils.java @@ -178,7 +178,13 @@ public static Rectangle pixelToPoint(Rectangle rect, int zoom) { } public static Rectangle pixelToPointWithSufficientlyLargeSize(Rectangle rect, int zoom) { - return pixelToPoint(rect, zoom, RoundingMode.UP); + if (zoom == 100 || rect == null) return rect; + + Point scaledTopLeft = pixelToPoint(new Point(rect.x, rect.y), zoom, RoundingMode.DOWN); + Point scaledBottomRight = pixelToPoint(new Point(rect.x + rect.width, rect.y + rect.height), zoom, RoundingMode.UP); + return new Rectangle(scaledTopLeft.x, scaledTopLeft.y, + scaledBottomRight.x - scaledTopLeft.x, + scaledBottomRight.y - scaledTopLeft.y); } private static Rectangle pixelToPoint(Rectangle rect, int zoom, RoundingMode sizeRounding) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java index bda694137da..47c3ff4fff1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java @@ -1532,7 +1532,7 @@ LRESULT WM_PAINT (long wParam, long lParam) { Event event = new Event (); event.gc = gc; - event.setBounds(Win32DPIUtils.pixelToPoint(new Rectangle.OfFloat(ps.left, ps.top, width, height), getAutoscalingZoom())); + event.setBounds(Win32DPIUtils.pixelToPointWithSufficientlyLargeSize(new Rectangle.OfFloat(ps.left, ps.top, width, height), getAutoscalingZoom())); sendEvent (SWT.Paint, event); if (data.focusDrawn && !isDisposed ()) updateUIState (); gc.dispose (); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java index e8f0669a3aa..b3cf73fab06 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java @@ -210,7 +210,7 @@ void destroyScrollBar (int type) { */ public Rectangle getClientArea () { checkWidget (); - return Win32DPIUtils.pixelToPoint(getClientAreaInPixels(), getAutoscalingZoom()); + return Win32DPIUtils.pixelToPointWithSufficientlyLargeSize(getClientAreaInPixels(), getAutoscalingZoom()); } Rectangle getClientAreaInPixels () {