Win32: Use native monitor zoom for menu item image scaling #2421
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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=xIssue 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