Skip to content

Commit bc0f6ba

Browse files
committed
Add documentation for DPIUtil#get[Native]DeviceZoom()
The utility methods do not have a proper meaning on Windows when using monitor-specific scaling anymore. This change adds an according documentation to those methods to make consumers aware of the risk to use them and the remaining relevance they have.
1 parent 9a03bfc commit bc0f6ba

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

  • bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,32 @@ private static <T> ElementAtZoom<T> getElementAtZoom(Function<Integer, T> elemen
394394
return null;
395395
}
396396

397+
/**
398+
* Returns the native zoom of the UI and its controls according to the adapted
399+
* OS elements. Particularly on Windows, this is the zoom used for fonts by the
400+
* OS, no matter what autoscaling of SWT might be applied on top.
401+
* <p>
402+
* <b>Warning:</b> When using monitor-specific scaling on Windows, this value
403+
* may not be reasonable as there is no single zoom for the application but one
404+
* per shell and its monitor. In that case, this method will return the native
405+
* zoom for the shell whose zoom has last been changed (via moving the shell to
406+
* another monitor or changing the zoom of a monitor).
407+
*/
397408
public static int getNativeDeviceZoom() {
398409
return nativeDeviceZoom;
399410
}
400411

412+
/**
413+
* Returns the zoom of the UI and its controls according to SWT autoscaling
414+
* settings. It is an adapted value of {@link #getNativeDeviceZoom()} based on
415+
* the setting of the {@code swt.autoScale} property.
416+
* <p>
417+
* <b>Warning:</b> When using monitor-specific scaling on Windows, this value
418+
* may not be reasonable as there is no single zoom for the application but one
419+
* per shell and its monitor. In that case, this method will return the
420+
* autoscaling zoom for the shell whose zoom has last been changed (via moving
421+
* the shell to another monitor or changing the zoom of a monitor).
422+
*/
401423
public static int getDeviceZoom() {
402424
return deviceZoom;
403425
}

0 commit comments

Comments
 (0)