diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java index 306319d46d..54e1b6c9d7 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java @@ -5251,4 +5251,15 @@ static String withCrLf (String string) { static boolean isActivateShellOnForceFocus() { return "true".equals(System.getProperty("org.eclipse.swt.internal.activateShellOnForceFocus", "true")); //$NON-NLS-1$ } + +Monitor getContainingMonitor(int x, int y) { + Monitor[] monitors = getMonitors(); + for (Monitor current : monitors) { + Rectangle clientArea = current.getClientArea(); + if (clientArea.contains(x, y)) { + return current; + } + } + return getPrimaryMonitor(); +} } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java index 88bef96ac5..a9ab293f7c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java @@ -1571,6 +1571,40 @@ public void setAlpha (int alpha) { } } +private void updateNativeZoomBeforePositionChange(int x, int y) { + if (DPIUtil.isAutoScaleOnRuntimeActive()) { + Monitor monitor = display.getContainingMonitor(x, y); + this.nativeZoom = monitor.zoom; + System.out.println("Update shell zoom (" + handle + ") " + monitor.zoom); + } +} + +@Override +public void setLocation(Point location) { + if (location == null) error (SWT.ERROR_NULL_ARGUMENT); + updateNativeZoomBeforePositionChange(location.x, location.y); + super.setLocation(location); +} + +@Override +public void setLocation(int x, int y) { + updateNativeZoomBeforePositionChange(x, y); + super.setLocation(x, y); +} + +@Override +public void setBounds(Rectangle rect) { + if (rect == null) error (SWT.ERROR_NULL_ARGUMENT); + updateNativeZoomBeforePositionChange(rect.x, rect.y); + super.setBounds(rect); +} + +@Override +public void setBounds(int x, int y, int width, int height) { + updateNativeZoomBeforePositionChange(x, y); + super.setBounds(x, y, width, height); +} + @Override void setBoundsInPixels (int x, int y, int width, int height, int flags, boolean defer) { if (fullScreen) setFullScreen (false);