Skip to content

Commit 584132f

Browse files
committed
[Win32] Preserve enforcement of monitor-specific scaling
Monitor-specific scaling can be enforced (i.e, activated despite unsupported autoscaling mode) with a "force" option at its system property. This is accidentally overwritten when setting monitor-specific scaling at the Display via DPIUtil.getMonitorSpecificScaling() again. This change ensures that the enforcement will be preserved even if another enablement of monitor-specific scaling is applied.
1 parent 558c4e6 commit 584132f

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

  • bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal

bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/DPIUtil.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,23 @@ public static boolean isSetupCompatibleToMonitorSpecificScaling() {
156156
if (!"win32".equals(SWT.getPlatform())) {
157157
return false;
158158
}
159-
if (System.getProperty(SWT_AUTOSCALE) == null || "force".equals(System.getProperty(SWT_AUTOSCALE_UPDATE_ON_RUNTIME))) {
159+
if (System.getProperty(SWT_AUTOSCALE) == null || isMonitorSpecificScalingEnforced()) {
160160
return true;
161161
}
162162
return autoScaleValue.isCompatibleToMonitorSpecificScaling();
163163
}
164164

165+
private static boolean isMonitorSpecificScalingEnforced() {
166+
return "force".equals(System.getProperty(SWT_AUTOSCALE_UPDATE_ON_RUNTIME));
167+
}
168+
165169
public static void setMonitorSpecificScaling(boolean activate) {
166-
System.setProperty(DPIUtil.SWT_AUTOSCALE_UPDATE_ON_RUNTIME, Boolean.toString(activate));
170+
// If monitor-specific scaling was enforced via system property, calling this
171+
// method with "true" should preserve the enforcement and not overwrite the
172+
// system property with a simple "true"
173+
if (!activate || !isMonitorSpecificScalingEnforced()) {
174+
System.setProperty(DPIUtil.SWT_AUTOSCALE_UPDATE_ON_RUNTIME, Boolean.toString(activate));
175+
}
167176
updateAutoScaleValue();
168177
}
169178

0 commit comments

Comments
 (0)