From c94b5aacfcc4b72d3f26cc03f889944e4bfd44f1 Mon Sep 17 00:00:00 2001 From: Thomas Singer Date: Thu, 28 May 2026 16:12:01 +0200 Subject: [PATCH 1/2] Win32DPIUtils: fix pixelToPointWithSufficientlyLargeSize If we need the rectangle that is large enough, the left top corner must be rounded down and the right bottom corner rounded up. --- .../win32/org/eclipse/swt/internal/Win32DPIUtils.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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) { From 91677aa69a5c4fc61d9ed8ff8e80096e2a8e298d Mon Sep 17 00:00:00 2001 From: Thomas Singer Date: Thu, 28 May 2026 16:13:46 +0200 Subject: [PATCH 2/2] [Win] StyledText with paint artifacts #3298 Scrollable.getClientArea needs to round up to contain all pixels. The same applies to the bounds set to the Paint event. --- .../Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java | 2 +- .../Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 () {