Skip to content

Replace nativeZoom of widgets with disabled autoscaling with 100#2599

Merged
HeikoKlare merged 1 commit into
eclipse-platform:masterfrom
vi-eclipse:master-446
Oct 16, 2025
Merged

Replace nativeZoom of widgets with disabled autoscaling with 100#2599
HeikoKlare merged 1 commit into
eclipse-platform:masterfrom
vi-eclipse:master-446

Conversation

@ShahzaibIbrahim
Copy link
Copy Markdown
Contributor

@ShahzaibIbrahim ShahzaibIbrahim commented Oct 6, 2025

Few Widgets do not adhere to AUTO_SCALE_DISABLED field when set to true in Widget#setData. The proposed changes are as follow:

  • In Widget when setting DATA_AUTOSCALE_DISABLED to true we also update the nativeZoom value to 100 since it is a public field and we cannot rely on everyone calling the getter for it where we previously had a logic to return 100 in case of autoScale disablement.
  • Tracker class in some cases was using same logic as getZoom() but missing one additional detail which is present in getZoom(), that is to check if autoScale is disabled then use 100%
  • In Control class when we set the bounds then we use to check for autoScale disablement but not when setting the size or location, so that's fixed too.

Detailed Analysis

These are the widgets or widget utils that should be affected when auto scale is disabled.

org.eclipse.swt.dnd.DragSource.drag(Event)
org.eclipse.swt.dnd.DropTarget.convertPixelToPoint(int, int)
org.eclipse.swt.dnd.TableDragSourceEffect.getDragSourceImage(DragSourceEvent)
org.eclipse.swt.dnd.TableDropTargetEffect.dragOver(DropTargetEvent)
org.eclipse.swt.dnd.TreeDragSourceEffect.getDragSourceImage(DragSourceEvent)
org.eclipse.swt.dnd.TreeDropTargetEffect.dragOver(DropTargetEvent)

org.eclipse.swt.widgets.Button.Button(Composite, int)
org.eclipse.swt.widgets.Button.getCheckboxTextOffset(long)
org.eclipse.swt.widgets.Button.wmDrawChild(long, long)

org.eclipse.swt.widgets.Composite.wmNCPaint(long, long, long)

org.eclipse.swt.widgets.Control.getData(String)
org.eclipse.swt.widgets.Control.setParent(Composite)
org.eclipse.swt.widgets.Control.WM_DPICHANGED(long, long)

org.eclipse.swt.widgets.ExpandBar.computeSizeInPixels(int, int, boolean)
org.eclipse.swt.widgets.ExpandBar.drawThemeBackground(long, long, RECT)
org.eclipse.swt.widgets.ExpandBar.drawWidget(GC, RECT)

org.eclipse.swt.widgets.Menu.fixMenus(Decorations)

org.eclipse.swt.widgets.MenuItem.fixMenus(Decorations)
org.eclipse.swt.widgets.MenuItem.getMenuItemIconBitmapHandle(Image)
org.eclipse.swt.widgets.MenuItem.getMenuItemIconSelectedBitmapHandle()

org.eclipse.swt.widgets.TabFolder.drawThemeBackground(long, long, RECT)

org.eclipse.swt.widgets.Table.setCheckboxImageList(int, int, boolean)
org.eclipse.swt.widgets.Table.wmNotifyHeader(NMHDR, long, long)

org.eclipse.swt.widgets.TaskBar.createShellLink(MenuItem)

org.eclipse.swt.widgets.Text.WM_DRAWITEM(long, long)

org.eclipse.swt.widgets.Tree.calculateAndApplyIndentSize()
org.eclipse.swt.widgets.Tree.setCheckboxImageList()
org.eclipse.swt.widgets.Tree.wmNotifyHeader(NMHDR, long, long)

When should auto scale disabling function?

Whenever widget#nativeZoom or widget#getNativeZoom is called from any of the widget, the native zoom must be 100%.

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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Oct 6, 2025

Test Results

  115 files  ±0    115 suites  ±0   12m 51s ⏱️ + 1m 6s
4 554 tests ±0  4 538 ✅ ±0  16 💤 ±0  0 ❌ ±0 
  311 runs  ±0    308 ✅ ±0   3 💤 ±0  0 ❌ ±0 

Results for commit 17e1814. ± Comparison against base commit 6347ad3.

♻️ This comment has been updated with latest results.

@ShahzaibIbrahim ShahzaibIbrahim marked this pull request as draft October 7, 2025 08:41
Comment thread bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java Outdated
@ShahzaibIbrahim ShahzaibIbrahim force-pushed the master-446 branch 2 times, most recently from 10fe424 to 29ded18 Compare October 7, 2025 13:17
@ShahzaibIbrahim ShahzaibIbrahim marked this pull request as ready for review October 7, 2025 13:31
Copy link
Copy Markdown
Member

@fedejeanne fedejeanne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does one test this?

Shouldn't line 186 (in the constructor) also be adapted?

	this.nativeZoom = parent != null ? parent.nativeZoom : DPIUtil.getNativeDeviceZoom();

Comment thread bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java Outdated
Comment thread bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java Outdated
@ShahzaibIbrahim ShahzaibIbrahim force-pushed the master-446 branch 2 times, most recently from 8332a07 to d98ea7b Compare October 14, 2025 13:58
@ShahzaibIbrahim
Copy link
Copy Markdown
Contributor Author

How does one test this?

I have added how to test section.

Shouldn't line 186 (in the constructor) also be adapted?

	this.nativeZoom = parent != null ? parent.nativeZoom : DPIUtil.getNativeDeviceZoom();

No, you can only disable autoscaling after the widget is created till now. So we don't need to adapt here.

@ShahzaibIbrahim ShahzaibIbrahim force-pushed the master-446 branch 3 times, most recently from d6ab406 to 4a05eb5 Compare October 14, 2025 15:35
Comment thread bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java Outdated
@ShahzaibIbrahim ShahzaibIbrahim force-pushed the master-446 branch 2 times, most recently from 3a2a53f to 75df398 Compare October 16, 2025 09:31
The nativeZoom of some controls currently always has the original native
zoom value, even if autoscaling is disabled for that control such that
they behave as if their native zoom is effectively 100. With this change
the behavior of those control will be fixed as per autoscale disabled
value.
@HeikoKlare HeikoKlare merged commit 9cacd32 into eclipse-platform:master Oct 16, 2025
17 checks passed
@HeikoKlare HeikoKlare deleted the master-446 branch October 16, 2025 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace nativeZoom of widgets with disabled autoscaling with 100

3 participants