diff --git a/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/widgets/ControlWin32Tests.java b/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/widgets/ControlWin32Tests.java index 21cf0d781a7..eaa1f01f500 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/widgets/ControlWin32Tests.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/widgets/ControlWin32Tests.java @@ -55,6 +55,25 @@ public void testDoNotScaleFontCorrectlyInNoAutoScaleSzenario() { fontComparison.originalFontHeight, fontComparison.currentFontHeight); } + @Test + public void testCorrectScaleUpUsingDifferentSetBoundsMethod() { + DPIUtil.setMonitorSpecificScaling(true); + Display display = Display.getDefault(); + Shell shell = new Shell(display); + DPITestUtil.changeDPIZoom(shell, 175); + + Button button = new Button(shell, SWT.PUSH); + button.setText("Widget Test"); + button.setBounds(new Rectangle(0, 47, 200, 47)); + shell.open(); + assertEquals("Control::setBounds(Rectangle) doesn't scale up correctly", + new Rectangle(0, 82, 350, 83), button.getBoundsInPixels()); + + button.setBounds(0, 47, 200, 47); + assertEquals("Control::setBounds(int, int, int, int) doesn't scale up correctly", + new Rectangle(0, 82, 350, 83), button.getBoundsInPixels()); + } + record FontComparison(int originalFontHeight, int currentFontHeight) { } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java index 3b34a3d2500..c8c9a979ab6 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java @@ -3168,13 +3168,7 @@ void setBackgroundPixel (int pixel) { * */ public void setBounds(int x, int y, int width, int height) { - checkWidget (); - int zoom = getZoom(); - x = DPIUtil.scaleUp(x, zoom); - y = DPIUtil.scaleUp(y, zoom); - width = DPIUtil.scaleUp(width, zoom); - height = DPIUtil.scaleUp(height, zoom); - setBoundsInPixels(x, y, width, height); + setBounds(new Rectangle(x, y, width, height)); } void setBoundsInPixels (int x, int y, int width, int height) {