Skip to content

Commit 3cd1f36

Browse files
amartya4256HeikoKlare
authored andcommitted
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 d04d5a4 commit 3cd1f36

File tree

1 file changed

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

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1596,7 +1596,12 @@ 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 processing. So to avoid duplicate scaling, we always
1601+
// have to scale width and height with the zoom of the original monitor (still
1602+
// returned by getZoom()) here.
1603+
setBoundsInPixels(boundsInPixels.x, boundsInPixels.y, DPIUtil.scaleUp(rect.width, getZoom()),
1604+
DPIUtil.scaleUp(rect.height, getZoom()));
16001605
}
16011606

16021607
@Override

0 commit comments

Comments
 (0)