Skip to content

Commit 42ed1da

Browse files
committed
Add DPIUtil method for running code in custom auto-scale mode
1 parent 8569eb7 commit 42ed1da

File tree

1 file changed

+10
-4
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal

1 file changed

+10
-4
lines changed

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

+10-4
Original file line numberDiff line numberDiff line change
@@ -605,10 +605,6 @@ public static int getDeviceZoom() {
605605
return deviceZoom;
606606
}
607607

608-
public static int getDeviceZoom(String autoScaleProperty) {
609-
return getZoomForAutoscaleProperty(nativeDeviceZoom, autoScaleProperty);
610-
}
611-
612608
public static void setDeviceZoom (int nativeDeviceZoom) {
613609
DPIUtil.nativeDeviceZoom = nativeDeviceZoom;
614610
int deviceZoom = getZoomForAutoscaleProperty (nativeDeviceZoom);
@@ -676,6 +672,16 @@ private static int getZoomForAutoscaleProperty (int nativeDeviceZoom, String aut
676672
return zoom;
677673
}
678674

675+
public static void runWithAutoScaleValue(String autoScaleValue, Runnable runnable) {
676+
String initialAutoScaleValue = DPIUtil.autoScaleValue;
677+
DPIUtil.autoScaleValue = autoScaleValue;
678+
try {
679+
runnable.run();
680+
} finally {
681+
DPIUtil.autoScaleValue = initialAutoScaleValue;
682+
}
683+
}
684+
679685
public static void setMonitorSpecificScaling(boolean activate) {
680686
System.setProperty(SWT_AUTOSCALE_UPDATE_ON_RUNTIME, Boolean.toString(activate));
681687
}

0 commit comments

Comments
 (0)