|
33 | 33 | * @noreference This class is not intended to be referenced by clients |
34 | 34 | */ |
35 | 35 | public class Win32DPIUtils { |
36 | | - /** |
37 | | - * System property to enable to scale the application on runtime |
38 | | - * when a DPI change is detected. |
39 | | - * <ul> |
40 | | - * <li>"true": the application is scaled on DPI changes</li> |
41 | | - * <li>"false": the application will remain in its initial scaling</li> |
42 | | - * </ul> |
43 | | - * <b>Important:</b> This flag is only parsed and used on Win32. Setting it to |
44 | | - * true on GTK or cocoa will be ignored. |
45 | | - */ |
46 | | - private static final String SWT_AUTOSCALE_UPDATE_ON_RUNTIME = "swt.autoScale.updateOnRuntime"; |
47 | | - |
48 | 36 | static { |
49 | 37 | DPIUtil.setUseSmoothScalingByDefaultProvider(() -> isMonitorSpecificScalingActive()); |
50 | 38 | } |
@@ -278,53 +266,22 @@ public static Rectangle pointToPixel(Drawable drawable, Rectangle rect, int zoom |
278 | 266 | } |
279 | 267 |
|
280 | 268 | public static void setMonitorSpecificScaling(boolean activate) { |
281 | | - System.setProperty(SWT_AUTOSCALE_UPDATE_ON_RUNTIME, Boolean.toString(activate)); |
| 269 | + System.setProperty(DPIUtil.SWT_AUTOSCALE_UPDATE_ON_RUNTIME, Boolean.toString(activate)); |
282 | 270 | } |
283 | 271 |
|
284 | 272 | public static void setAutoScaleForMonitorSpecificScaling() { |
285 | 273 | boolean isDefaultAutoScale = DPIUtil.getAutoScaleValue() == null; |
286 | 274 | if (isDefaultAutoScale) { |
287 | 275 | DPIUtil.setAutoScaleValue("quarter"); |
288 | | - } else if (!isSupportedAutoScaleForMonitorSpecificScaling()) { |
| 276 | + } else if (!DPIUtil.isSetupCompatibleToMonitorSpecificScaling()) { |
289 | 277 | throw new SWTError(SWT.ERROR_NOT_IMPLEMENTED, |
290 | 278 | "monitor-specific scaling is only implemented for auto-scale values \"quarter\", \"exact\", \"false\" or a concrete zoom value, but \"" |
291 | 279 | + DPIUtil.getAutoScaleValue() + "\" has been specified"); |
292 | 280 | } |
293 | 281 | } |
294 | 282 |
|
295 | | - /** |
296 | | - * Monitor-specific scaling on Windows only supports auto-scale modes in which |
297 | | - * all elements (font, images, control bounds etc.) are scaled equally or almost |
298 | | - * equally. The previously default mode "integer"/"integer200", which rounded |
299 | | - * the scale factor for everything but fonts to multiples of 100, is complex and |
300 | | - * difficult to realize with monitor-specific rescaling of UI elements. Since a |
301 | | - * uniform scale factor for everything should perspectively be used anyway, |
302 | | - * there will be support for complex auto-scale modes for monitor-specific |
303 | | - * scaling. |
304 | | - * |
305 | | - * The supported modes are "quarter" and "exact" or explicit zoom values given |
306 | | - * by the value itself or "false". Every other value will be treated as |
307 | | - * "integer"/"integer200" and is thus not supported. |
308 | | - */ |
309 | | - private static boolean isSupportedAutoScaleForMonitorSpecificScaling() { |
310 | | - if (DPIUtil.getAutoScaleValue() == null) { |
311 | | - return false; |
312 | | - } |
313 | | - switch (DPIUtil.getAutoScaleValue().toLowerCase()) { |
314 | | - case "false", "quarter", "exact": return true; |
315 | | - } |
316 | | - try { |
317 | | - Integer.parseInt(DPIUtil.getAutoScaleValue()); |
318 | | - return true; |
319 | | - } catch (NumberFormatException e) { |
320 | | - // unsupported value, use default |
321 | | - } |
322 | | - return false; |
323 | | - } |
324 | | - |
325 | 283 | public static boolean isMonitorSpecificScalingActive() { |
326 | | - boolean updateOnRuntimeValue = Boolean.getBoolean (SWT_AUTOSCALE_UPDATE_ON_RUNTIME); |
327 | | - return updateOnRuntimeValue; |
| 284 | + return DPIUtil.isMonitorSpecificScalingActive(); |
328 | 285 | } |
329 | 286 |
|
330 | 287 | public static int getPrimaryMonitorZoomAtStartup() { |
|
0 commit comments