Skip to content

Commit de1f3ef

Browse files
ShahzaibIbrahimfedejeanne
authored andcommitted
Initialize nativeZoom from Shell via OS call
Shell can be created on secondary monitor but inheriting the zoom of parent (which could be on primary monitor) means the DPI change will not be triggered.
1 parent f92b752 commit de1f3ef

File tree

1 file changed

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

1 file changed

+1
-30
lines changed

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

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -300,18 +300,9 @@ public Shell (Display display, int style) {
300300
if (handle != 0 && !embedded) {
301301
state |= FOREIGN_HANDLE;
302302
}
303-
304-
int shellNativeZoom;
305-
if (parent != null) {
306-
shellNativeZoom = parent.nativeZoom;
307-
} else {
308-
int mappedDPIZoom = getMonitor().getZoom();
309-
shellNativeZoom = mappedDPIZoom;
310-
}
311-
this.nativeZoom = shellNativeZoom;
312-
313303
reskinWidget();
314304
createWidget ();
305+
this.nativeZoom = DPIUtil.mapDPIToZoom(OS.GetDpiForWindow(this.handle));
315306
}
316307

317308
/**
@@ -2728,26 +2719,6 @@ LRESULT WM_WINDOWPOSCHANGING (long wParam, long lParam) {
27282719
return result;
27292720
}
27302721

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-
27512722
private static void handleDPIChange(Widget widget, int newZoom, float scalingFactor) {
27522723
if (!(widget instanceof Shell shell)) {
27532724
return;

0 commit comments

Comments
 (0)