Skip to content

Commit 3983021

Browse files
committed
[win32] Adjust wrong size after DPI fix in Shell
This commit addresses an issue with the logic fixing a missing DPI change event from windows in the Shell#WM_WINDOWPOSCHANGED callback. It is no longer necessary, because the causing issue is that in some scenarios a sub shell is positioned on a random monitor. Solution is to adapt the nativeZoom of the sub Shell after the handle was created.
1 parent 9eb34bf commit 3983021

File tree

1 file changed

+8
-20
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets

1 file changed

+8
-20
lines changed

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

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,14 @@ public void close () {
553553
closeWidget ();
554554
}
555555

556+
@Override
557+
void createWidget() {
558+
super.createWidget ();
559+
if (parent != null) {
560+
this.nativeZoom = DPIUtil.mapDPIToZoom(OS.GetDpiForWindow(handle));
561+
}
562+
}
563+
556564
void createBalloonTipHandle () {
557565
balloonTipHandle = OS.CreateWindowEx (
558566
0,
@@ -2728,26 +2736,6 @@ LRESULT WM_WINDOWPOSCHANGING (long wParam, long lParam) {
27282736
return result;
27292737
}
27302738

2731-
@Override
2732-
LRESULT WM_WINDOWPOSCHANGED (long wParam, long lParam) {
2733-
LRESULT result = super.WM_WINDOWPOSCHANGED(wParam, lParam);
2734-
// When the process is started with System DPI awareness and
2735-
// only the thread is PerMonitorV2 aware, there are some scenarios, when the
2736-
// OS does not send a DPI change event when a child Shell is positioned and
2737-
// opened on another monitor as its parent Shell. To work around that limitation
2738-
// this check is added to trigger a dpi change event if an unexpected DPI value is
2739-
// detected.
2740-
if (display.isRescalingAtRuntime()) {
2741-
int dpiForWindow = DPIUtil.mapDPIToZoom(OS.GetDpiForWindow(getShell().handle));
2742-
if (dpiForWindow != nativeZoom) {
2743-
WINDOWPOS lpwp = new WINDOWPOS ();
2744-
OS.MoveMemory (lpwp, lParam, WINDOWPOS.sizeof);
2745-
handleMonitorSpecificDpiChange(dpiForWindow, new Rectangle(lpwp.x, lpwp.y, lpwp.cx, lpwp.cy));
2746-
}
2747-
}
2748-
return result;
2749-
}
2750-
27512739
private static void handleDPIChange(Widget widget, int newZoom, float scalingFactor) {
27522740
if (!(widget instanceof Shell shell)) {
27532741
return;

0 commit comments

Comments
 (0)