Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public void testCorrectScaleUpUsingDifferentSetBoundsMethod() {
}

@ParameterizedTest
@CsvSource({ "0.5, 100, true", "1.0, 200, true", "2.0, 200, true", "2.0, quarter, true", "0.5, 100, false",
@CsvSource({ "2.0, quarter, true", "0.5, 100, false",
"1.0, 200, false", "2.0, 200, false", "2.0, quarter, false", })
public void testAutoScaleImageData(float scaleFactor, String autoScale, boolean monitorSpecificScaling) {
Win32DPIUtils.setMonitorSpecificScaling(monitorSpecificScaling);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,15 @@ public static Optional<AutoScaleMethod> forString(String s) {

private static String autoScaleValue;

private static final Set<String> ALLOWED_AUTOSCALE_VALUES_FOR_UPDATE_ON_RUNTIME = Set.of("quarter", "exact", "false");
private static final Set<String> ALLOWED_AUTOSCALE_VALUES_FOR_UPDATE_ON_RUNTIME = Set.of("quarter", "exact");

/**
* System property to enable to scale the application on runtime
* when a DPI change is detected.
* System property to enable to scale the application on runtime when a DPI
* change is detected.
* <ul>
* <li>"force": the application is scaled on DPI changes even if an unsupported
* value for swt.autoScale are defined. See allowed values
* {@link #ALLOWED_AUTOSCALE_VALUES_FOR_UPDATE_ON_RUNTIME}.</li>
* <li>"true": the application is scaled on DPI changes</li>
* <li>"false": the application will remain in its initial scaling</li>
* </ul>
Expand Down Expand Up @@ -140,25 +144,19 @@ static void setAutoScaleValue(String autoScaleValueArg) {
* scaling.
*/
public static boolean isSetupCompatibleToMonitorSpecificScaling() {
if (DPIUtil.getAutoScaleValue() == null) {
if (!"win32".equals(SWT.getPlatform())) {
return false;
}

if (ALLOWED_AUTOSCALE_VALUES_FOR_UPDATE_ON_RUNTIME.contains(DPIUtil.getAutoScaleValue().toLowerCase())) {
return true;
}
try {
Integer.parseInt(DPIUtil.getAutoScaleValue());
if (autoScaleValue == null || "force".equals(System.getProperty(SWT_AUTOSCALE_UPDATE_ON_RUNTIME))) {
return true;
} catch (NumberFormatException e) {
// unsupported value, use default
}
return false;
String value = autoScaleValue.toLowerCase(Locale.ROOT);
return ALLOWED_AUTOSCALE_VALUES_FOR_UPDATE_ON_RUNTIME.contains(value);
}

public static boolean isMonitorSpecificScalingActive() {
boolean updateOnRuntimeValue = Boolean.getBoolean (DPIUtil.SWT_AUTOSCALE_UPDATE_ON_RUNTIME);
return updateOnRuntimeValue;
String updateOnRuntimeValue = System.getProperty(SWT_AUTOSCALE_UPDATE_ON_RUNTIME);
return "force".equalsIgnoreCase(updateOnRuntimeValue) || "true".equalsIgnoreCase(updateOnRuntimeValue);
}

public static int pixelToPoint(int size, int zoom) {
Expand Down
Loading