|
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 | } |
@@ -302,53 +290,22 @@ public static Rectangle pointToPixel(Drawable drawable, Rectangle rect, int zoom |
302 | 290 | } |
303 | 291 |
|
304 | 292 | public static void setMonitorSpecificScaling(boolean activate) { |
305 | | - System.setProperty(SWT_AUTOSCALE_UPDATE_ON_RUNTIME, Boolean.toString(activate)); |
| 293 | + System.setProperty(DPIUtil.SWT_AUTOSCALE_UPDATE_ON_RUNTIME, Boolean.toString(activate)); |
306 | 294 | } |
307 | 295 |
|
308 | 296 | public static void setAutoScaleForMonitorSpecificScaling() { |
309 | 297 | boolean isDefaultAutoScale = DPIUtil.getAutoScaleValue() == null; |
310 | 298 | if (isDefaultAutoScale) { |
311 | 299 | DPIUtil.setAutoScaleValue("quarter"); |
312 | | - } else if (!isSupportedAutoScaleForMonitorSpecificScaling()) { |
| 300 | + } else if (!DPIUtil.isSetupCompatibleToMonitorSpecificScaling()) { |
313 | 301 | throw new SWTError(SWT.ERROR_NOT_IMPLEMENTED, |
314 | 302 | "monitor-specific scaling is only implemented for auto-scale values \"quarter\", \"exact\", \"false\" or a concrete zoom value, but \"" |
315 | 303 | + DPIUtil.getAutoScaleValue() + "\" has been specified"); |
316 | 304 | } |
317 | 305 | } |
318 | 306 |
|
319 | | - /** |
320 | | - * Monitor-specific scaling on Windows only supports auto-scale modes in which |
321 | | - * all elements (font, images, control bounds etc.) are scaled equally or almost |
322 | | - * equally. The previously default mode "integer"/"integer200", which rounded |
323 | | - * the scale factor for everything but fonts to multiples of 100, is complex and |
324 | | - * difficult to realize with monitor-specific rescaling of UI elements. Since a |
325 | | - * uniform scale factor for everything should perspectively be used anyway, |
326 | | - * there will be support for complex auto-scale modes for monitor-specific |
327 | | - * scaling. |
328 | | - * |
329 | | - * The supported modes are "quarter" and "exact" or explicit zoom values given |
330 | | - * by the value itself or "false". Every other value will be treated as |
331 | | - * "integer"/"integer200" and is thus not supported. |
332 | | - */ |
333 | | - private static boolean isSupportedAutoScaleForMonitorSpecificScaling() { |
334 | | - if (DPIUtil.getAutoScaleValue() == null) { |
335 | | - return false; |
336 | | - } |
337 | | - switch (DPIUtil.getAutoScaleValue().toLowerCase()) { |
338 | | - case "false", "quarter", "exact": return true; |
339 | | - } |
340 | | - try { |
341 | | - Integer.parseInt(DPIUtil.getAutoScaleValue()); |
342 | | - return true; |
343 | | - } catch (NumberFormatException e) { |
344 | | - // unsupported value, use default |
345 | | - } |
346 | | - return false; |
347 | | - } |
348 | | - |
349 | 307 | public static boolean isMonitorSpecificScalingActive() { |
350 | | - boolean updateOnRuntimeValue = Boolean.getBoolean (SWT_AUTOSCALE_UPDATE_ON_RUNTIME); |
351 | | - return updateOnRuntimeValue; |
| 308 | + return DPIUtil.isMonitorSpecificScalingActive(); |
352 | 309 | } |
353 | 310 |
|
354 | 311 | public static int getPrimaryMonitorZoomAtStartup() { |
|
0 commit comments