Skip to content

Commit 03be8b1

Browse files
committed
[Win32] Improve parameterization of monitor-specific scaling enablement
Some parts of the implementation currently assume monitor-specific scaling to be disabled by default and autoscaling mode to default to "integer". With monitor-specific scaling becoming the default in the future, these assumptions will not hold anymore. In order to prepare for that, this change adapts some code to properly deal with monitor-specific scaling and autoscaling mode having arbitrary default values.
1 parent e640660 commit 03be8b1

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -951,8 +951,8 @@ protected void create (DeviceData data) {
951951
checkDisplay (thread = Thread.currentThread (), true);
952952
if (DPIUtil.isMonitorSpecificScalingActive()) {
953953
setMonitorSpecificScaling(true);
954-
DPIUtil.setMonitorSpecificScaling(true);
955954
}
955+
DPIUtil.setMonitorSpecificScaling(DPIUtil.isMonitorSpecificScalingActive());
956956
Win32DPIUtils.initializeCustomDpiAwareness();
957957
createDisplay (data);
958958
register (this);

tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/AllNonBrowserTests_AutoscaleOsNonDefaults.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*******************************************************************************/
1111
package org.eclipse.swt.tests.junit;
1212

13+
import org.eclipse.swt.internal.DPIUtil;
1314
import org.eclipse.swt.tests.junit.AllNonBrowserTests.NonBrowserTestSuite;
1415
import org.junit.platform.suite.api.AfterSuite;
1516
import org.junit.platform.suite.api.BeforeSuite;
@@ -21,16 +22,22 @@
2122
@NonBrowserTestSuite
2223
public class AllNonBrowserTests_AutoscaleOsNonDefaults extends AllNonBrowserTests {
2324

25+
private static final String AUTO_SCALE_PROPERTY = "swt.autoScale";
26+
private static boolean originalMonitorSpecificScalingActive;
27+
28+
@SuppressWarnings("restriction")
2429
@BeforeSuite
2530
static void setNonDefaultAutoscale() {
26-
System.setProperty("swt.autoScale", "quarter");
27-
System.setProperty("swt.autoScale.updateOnRuntime", "true");
31+
originalMonitorSpecificScalingActive = DPIUtil.isMonitorSpecificScalingActive();
32+
System.setProperty(AUTO_SCALE_PROPERTY, originalMonitorSpecificScalingActive ? "integer" : "quarter");
33+
DPIUtil.setMonitorSpecificScaling(!originalMonitorSpecificScalingActive);
2834
}
2935

36+
@SuppressWarnings("restriction")
3037
@AfterSuite
3138
static void restoreDefaultAutoscale() {
32-
System.clearProperty("swt.autoScale");
33-
System.clearProperty("swt.autoScale.updateOnRuntime");
39+
System.clearProperty(AUTO_SCALE_PROPERTY);
40+
DPIUtil.setMonitorSpecificScaling(originalMonitorSpecificScalingActive);
3441
}
3542

3643

0 commit comments

Comments
 (0)