Skip to content

Replace nativeZoom of widgets with disabled autoscaling with 100 #446

@HeikoKlare

Description

@HeikoKlare

Description

The nativeZoom of widgets currently always has the original native zoom value, even if autoscaling is disabled for that widget such that they behave as if their native zoom is effectively 100. As a consequence, some consumers such as DropTarget#convertPixelToPoint erroneously use the original native zoom instead of 100 in case autoscaling is disabled for that widget. This particular consumer leads to an offset of the mouse position when dropping elements into such a control.

Reproduction

The drop scenario sketched above can be easily reproduced with Snippet257:

  • Adapt the snippet as follows:
    • Start it with monitor-specific scaling enabled, e.g., add the following for line to the main method: System.setProperty("swt.autoScale.updateOnRuntime", "true");
    • Disabled autoscaling for StyledText control, i.e., call text.setData("AUTOSCALE_DISABLED", "true"); after instantiating text
  • Start the snippet and move the shell to a monitor with zoom != 100% (it's also sufficient if it starts on primary monitor with zoom != 100)
  • Drag a text from somewhere es and try to drop it into the text widget.

Here is how it looks on 200% monitor because of the wrong coordinate conversion:
Image

Expected Behavior

Widget#nativeZoom shall be adapted to always contain the actual native zoom, i.e., 100 in case autoscaleDisabled==true. All accesses to Widget#nativeZoom shall be summarized in this issue (or in the according PR) and evaluated regarding whether it is correct to use 100 when autoscaling is disabled or not. In cases where it may not be correct, getData(DATA_NATIVE_ZOOM) could be used to access the original native zoom.

Metadata

Metadata

Assignees

No one assigned

    Labels

    HiDPIA HiDPI-Related Issue or FeatureSWTIssue for SWT

    Type

    No type

    Projects

    Status

    👀 In Review

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions