diff --git a/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/widgets/DisplayWin32Test.java b/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/widgets/DisplayWin32Test.java index 3d380ef1469..96dcd965168 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/widgets/DisplayWin32Test.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/widgets/DisplayWin32Test.java @@ -1,9 +1,9 @@ package org.eclipse.swt.widgets; import static org.eclipse.swt.internal.DPIUtil.setMonitorSpecificScaling; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.*; +import org.eclipse.swt.graphics.*; import org.eclipse.swt.internal.*; import org.eclipse.swt.internal.win32.*; import org.junit.jupiter.api.*; @@ -104,4 +104,23 @@ public void setRescaleAtRuntime_toggling() { assertExpectedDpiAwareness(OS.DPI_AWARENESS_CONTEXT_SYSTEM_AWARE); } + // https://github.com/eclipse-platform/eclipse.platform.swt/issues/3530 + @Test + public void getBoundsAndGetClientAreaUseZoomOfPrimaryMonitor_MatchingGCZoom() throws Exception { + Display display = Display.getDefault(); + + DPIUtil.setDeviceZoom(200); // must not be considered + Rectangle bounds1 = display.getBounds(); + Rectangle clientArea1 = display.getClientArea(); + DPIUtil.setDeviceZoom(100); // must not be considered + Rectangle bounds2 = display.getBounds(); + Rectangle clientArea2 = display.getClientArea(); + + assertEquals(bounds2.width, bounds1.width); + assertEquals(clientArea2.width, clientArea1.width); + + GC gc = new GC(display); + assertEquals(display.getPrimaryMonitor().getZoom(), gc.getGCData().nativeZoom); + } + } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java index bf07037f1fc..25a8366ca1c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java @@ -1592,7 +1592,7 @@ public Menu getMenuBar () { @Override public Rectangle getBounds() { checkDevice (); - return Win32DPIUtils.pixelToPoint(getBoundsInPixels(), DPIUtil.getDeviceZoom()); + return Win32DPIUtils.pixelToPoint(getBoundsInPixels(), getDeviceZoom()); } Rectangle getBoundsInPixels () { @@ -1665,7 +1665,7 @@ int getClickCount (int type, int button, long hwnd, long lParam) { @Override public Rectangle getClientArea () { checkDevice (); - return Win32DPIUtils.pixelToPoint(getClientAreaInPixels(), DPIUtil.getDeviceZoom()); + return Win32DPIUtils.pixelToPoint(getClientAreaInPixels(), getDeviceZoom()); } Rectangle getClientAreaInPixels () {