diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/DPIUtil.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/DPIUtil.java index 8d631342e8d..ebe0044a767 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/DPIUtil.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/DPIUtil.java @@ -654,10 +654,34 @@ public static int getZoomForAutoscaleProperty (int nativeDeviceZoom) { return zoom; } -public static boolean isAutoScaleOnRuntimeActive() { +public static boolean isMonitorSpecificScalingActive() { return autoScaleOnRuntime; } +public static void setAutoScaleForMonitorSpecificScaling() { + boolean isDefaultAutoScale = autoScaleValue == null; + if (isDefaultAutoScale) { + autoScaleValue = "quarter"; + } else if (!isSupportedAutoScaleForMonitorSpecificScaling()) { + throw new SWTError(SWT.ERROR_NOT_IMPLEMENTED, + "monitor-specific scaling is only implemented for auto-scale values \"quarter\", \"exact\", \"false\" or a concrete zoom value, but \"" + + autoScaleValue + "\" has been specified"); + } +} + +private static boolean isSupportedAutoScaleForMonitorSpecificScaling() { + switch (autoScaleValue) { + case "false", "quarter", "exact": return true; + } + try { + Integer.parseInt(autoScaleValue); + return true; + } catch (NumberFormatException e) { + // unsupported value, use default + } + return false; +} + /** * AutoScale ImageDataProvider. */ 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 70576d85cea..cc19d1cf3f3 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 @@ -948,8 +948,9 @@ public void close () { protected void create (DeviceData data) { checkSubclass (); checkDisplay (thread = Thread.currentThread (), true); - if (DPIUtil.isAutoScaleOnRuntimeActive()) { + if (DPIUtil.isMonitorSpecificScalingActive()) { setRescalingAtRuntime(true); + DPIUtil.setAutoScaleForMonitorSpecificScaling(); } createDisplay (data); register (this);