Skip to content

Commit c91d7f8

Browse files
committed
Improve Shell::setBounds scaling on monitor change
This commit contributes to the correct scaling of the Shell using its own zoom on Shell::setBounds call as the scaling of the shell in case of a monitor change is also handled by the DPI_CHANGED event. contributes to #62 and #127
1 parent a0a0485 commit c91d7f8

File tree

1 file changed

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

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1596,7 +1596,11 @@ public void setBounds(Rectangle rect) {
15961596
if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);
15971597
checkWidget ();
15981598
Rectangle boundsInPixels = getDisplay().translateToDisplayCoordinates(rect, getZoom());
1599-
setBoundsInPixels(boundsInPixels.x, boundsInPixels.y, boundsInPixels.width, boundsInPixels.height);
1599+
// The scaling of the width and height in case of a monitor change is handled by
1600+
// the WM_DPICHANGED event so we don't need to use the target monitor zoom for
1601+
// scaling them here.
1602+
setBoundsInPixels(boundsInPixels.x, boundsInPixels.y, DPIUtil.scaleUp(rect.width, getZoom()),
1603+
DPIUtil.scaleUp(rect.height, getZoom()));
16001604
}
16011605

16021606
@Override

0 commit comments

Comments
 (0)