Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved Windows icon rendering quality #14564

Merged
merged 1 commit into from
Feb 14, 2024

Conversation

TomEdwardsEnscape
Copy link
Contributor

@TomEdwardsEnscape TomEdwardsEnscape commented Feb 9, 2024

On MS Windows, a window has three icons: Big, Small, and Small2. Small2 is requested by other applications, and appears to have been added to support the Taskbar displaying the window's small icon with the platform theme variant.

Previously, Avalonia only set the Big icon, and did not refresh that icon when the window's DPI changed. With this PR it provides values for all three icons and updates them when appropriate. This provides higher quality icon rendering:

Comparison image

This PR also adds handling of the WM_GETICON message. This message is sent by other applications when they request the local window's icon for their own use, and ought to have special handling because the message can request a DPI different from the window's own. This can happen when the window and taskbar are on different monitors with different DPIs, for example.

Lastly, window icons are now set synchronously. Previously they were set with PostMessage, which only enqueues the change. By using SendMessage instead, we avoid a race condition which caused the window sometimes to be briefly drawn without an icon.

Breaking changes

None

Obsoletions / Deprecations

None

Fixed issues

Fixes #11569

@TomEdwardsEnscape
Copy link
Contributor Author

I extracted these changes from #12107. We have postponed dark mode support in our product, so there is no need for any controversial API changes. But we still want to see these icon rendering improvements in time for our final release.

@TomEdwardsEnscape TomEdwardsEnscape changed the title Improved icon rendering quality Improved Windows icon rendering quality Feb 9, 2024
@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.1.999-cibuild0044727-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@maxkatz6
Copy link
Member

In general, this PR looks good to me. Will test it on my machine on Monday. And will merge it if everything is good.

@TomEdwardsEnscape
Copy link
Contributor Author

@maxkatz6

Copy link
Member

@maxkatz6 maxkatz6 left a comment

Choose a reason for hiding this comment

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

Tested, LGTM

Refresh icons when window DPI changes
Provide ICON_SMALL icons
Fixed Win32Icon.Size being incorrect when the exact size couldn't be found in the icon
@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.1.999-cibuild0044912-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@maxkatz6 maxkatz6 added this pull request to the merge queue Feb 14, 2024
Merged via the queue into AvaloniaUI:master with commit aeb2447 Feb 14, 2024
6 checks passed
@TomEdwardsEnscape TomEdwardsEnscape deleted the fixes/win32-icon-message branch February 14, 2024 15:19
TomEdwardsEnscape added a commit to Enscape/Avalonia that referenced this pull request Mar 7, 2024
Refresh icons when window DPI changes
Provide ICON_SMALL icons
Fixed Win32Icon.Size being incorrect when the exact size couldn't be found in the icon
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.

On Windows, a window's ICON_SMALL is not set
3 participants