Skip to content

Commit 1900fcd

Browse files
committed
[Win] Disallow autoscale mode "integer" for monitor-specific scaling
The default auto-scale value is "integer"/"integer200", which makes everything in the UI except fonts not scale according to the actual native zoom value but according to a value rounded to 100 or 200. While most code performing adaptations to zoom considers this for a static zoom value applied to the whole application, it leads to hard-to-resolve issues when scaling every shell according to the current monitor's zoom. Since that autoscale mode is complex and should be replaced by uniform scaling of everything (in particular when images are based on vector graphics that can sharply be rendered for every zoom factor) anyway, this is not to be supported by the monitor-specific scaling feature currently being introduced for Windows. With this change, that mode will thus be limited to reasonable autoscale modes like "quarter" and "exact" or ones fixing the zoom value like specifying an explicit value or "false".
1 parent c49cee7 commit 1900fcd

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,10 +654,34 @@ public static int getZoomForAutoscaleProperty (int nativeDeviceZoom) {
654654
return zoom;
655655
}
656656

657-
public static boolean isAutoScaleOnRuntimeActive() {
657+
public static boolean isMonitorSpecificScalingActive() {
658658
return autoScaleOnRuntime;
659659
}
660660

661+
public static void setAutoScaleForMonitorSpecificScaling() {
662+
boolean isDefaultAutoScale = autoScaleValue == null;
663+
if (isDefaultAutoScale) {
664+
autoScaleValue = "quarter";
665+
} else if (!isSupportedAutoScaleForMonitorSpecificScaling()) {
666+
throw new SWTError(SWT.ERROR_NOT_IMPLEMENTED,
667+
"monitor-specific scaling is only implemented for auto-scale values \"quarter\", \"exact\", \"false\" or a concrete zoom value, but \""
668+
+ autoScaleValue + "\" has been specified");
669+
}
670+
}
671+
672+
private static boolean isSupportedAutoScaleForMonitorSpecificScaling() {
673+
switch (autoScaleValue) {
674+
case "false", "quarter", "exact": return true;
675+
}
676+
try {
677+
Integer.parseInt(autoScaleValue);
678+
return true;
679+
} catch (NumberFormatException e) {
680+
// unsupported value, use default
681+
}
682+
return false;
683+
}
684+
661685
/**
662686
* AutoScale ImageDataProvider.
663687
*/

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,8 +948,9 @@ public void close () {
948948
protected void create (DeviceData data) {
949949
checkSubclass ();
950950
checkDisplay (thread = Thread.currentThread (), true);
951-
if (DPIUtil.isAutoScaleOnRuntimeActive()) {
951+
if (DPIUtil.isMonitorSpecificScalingActive()) {
952952
setRescalingAtRuntime(true);
953+
DPIUtil.setAutoScaleForMonitorSpecificScaling();
953954
}
954955
createDisplay (data);
955956
register (this);

0 commit comments

Comments
 (0)