Skip to content

Conversation

@ShahzaibIbrahim
Copy link
Contributor

On Win32, the OS paints MenuItem images using sizes defined by SM_CXMENUCHECK / SM_CYMENUCHECK. If images are not provided at these metrics-specific sizes, Windows rescales them, causing unexpected sizes and alpha channel issues.

In getMenuItemIconSelectedBitmapHandle, adaptZoomForMenuItem was called which returns a fixed scaled value from getZoom() when fix autoScale value is provided e.g. 250 instead of the current
monitor's native zoom (150). This caused the OS to perform additional scaling.

Updated code to call adaptZoomForMenuItem(nativeZoom, image) so that the image is prepared for the actual monitor zoom, avoiding unnecessary OS scaling and preserving alpha channel integrity.

How to Reproduce

The issue can be reproduced when autoScale value is provided. e.g. -Dswt.autoScale=x

Issue Case 1
Primary monitor is Quarter (125, 175, 225 ..) and AutoScale > Primary

Primary monitor at 175%
Secondary monitor at 100, 125, 150, 300, 350
VM-Arg: -Dswt.autoScale=275

Issue Case 2
Primary is Half Zoom (150, 250, 350) and AutoScale is also Half Zoom and AutoScale > Primary

VM-Arg: -Dswt.autoScale=250, Primary = 150
Secondary = 100, 125, 300, 350

at Secondary 150, 175, 200, 225, 250 -> no Issue
Any Value between Primary and AutoScale is ok

On Win32, the OS paints MenuItem images using sizes defined by
SM_CXMENUCHECK / SM_CYMENUCHECK. If images are not provided at these
metrics-specific sizes, Windows rescales them, causing unexpected sizes
and alpha channel issues.

In getMenuItemIconSelectedBitmapHandle, adaptZoomForMenuItem was called
which returns a fixed scaled value from getZoom() when fix autoScale
value is provided e.g. 250 instead of the current
monitor's native zoom (150). This caused the OS to perform additional
scaling.

Updated code to call adaptZoomForMenuItem(nativeZoom, image) so that the
image is prepared for the actual monitor zoom, avoiding unnecessary OS
scaling and preserving alpha channel integrity.
@github-actions
Copy link
Contributor

Test Results

   546 files  ±0     546 suites  ±0   32m 27s ⏱️ + 3m 54s
 4 425 tests ±0   4 408 ✅ ±0   17 💤 ±0  0 ❌ ±0 
16 746 runs  ±0  16 619 ✅ ±0  127 💤 ±0  0 ❌ ±0 

Results for commit 84160f5. ± Comparison against base commit 8838c9d.

@HeikoKlare
Copy link
Contributor

The change totally makes sense. The existing implementation seem to have been wrong, but without any noticeable impact in most use cases since with monitor-specific scaling and thus DPI awareness PerMonitorV2 and swt.autoScale=quarter this change has no effect as nativeZoom == getZoom(). When not using monitor-specific scaling, usually DPI awareness System is used, which does not have any issues with icon sizes as menus are system-/blurry-scaled. So the relevant use case is monitor-specific scaling (and thus DPI awareness PerMonitorV2) with a mode where nativeZoom != getZoom(), which happens when a fixed-Zoom swt.autoScale value is defined.

@HeikoKlare HeikoKlare merged commit f59f98a into eclipse-platform:master Aug 14, 2025
17 checks passed
@HeikoKlare HeikoKlare deleted the master-401 branch August 14, 2025 21:21
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.

Broken menu images when using -Dswt.autoScale and monitor-specific scaling

2 participants