Skip to content

Commit

Permalink
Improve Shell::setBounds scaling on monitor change
Browse files Browse the repository at this point in the history
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
  • Loading branch information
amartya4256 authored and HeikoKlare committed Jan 23, 2025
1 parent d04d5a4 commit 3cd1f36
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1596,7 +1596,12 @@ public void setBounds(Rectangle rect) {
if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);
checkWidget ();
Rectangle boundsInPixels = getDisplay().translateToDisplayCoordinates(rect, getZoom());
setBoundsInPixels(boundsInPixels.x, boundsInPixels.y, boundsInPixels.width, boundsInPixels.height);
// The scaling of the width and height in case of a monitor change is handled by
// the WM_DPICHANGED event processing. So to avoid duplicate scaling, we always
// have to scale width and height with the zoom of the original monitor (still
// returned by getZoom()) here.
setBoundsInPixels(boundsInPixels.x, boundsInPixels.y, DPIUtil.scaleUp(rect.width, getZoom()),
DPIUtil.scaleUp(rect.height, getZoom()));
}

@Override
Expand Down

0 comments on commit 3cd1f36

Please sign in to comment.