Win32: fall back to pixel location when GetPointerDeviceRects is unavailable - #21337
Merged
Conversation
Contributor
Author
|
Tests failed with " Warning As Error: Package 'SharpCompress' 0.41.0 has a known moderate severity vulnerability" not related to my changes |
Collaborator
|
Contributor
Author
|
@cla-avalonia agree |
|
You can test this PR using the following package version. |
MrJul
added this pull request to the merge queue
May 15, 2026
Contributor
Author
|
@MrJul Which Avalonia version contains this fix? Because I cannot find it in 12.0.4 changelog. |
Collaborator
|
The PR has no backport label, so latest nightly and v12.1 should have it. |
Contributor
Author
|
Ah, thank you! |
MrJul
added a commit
to MrJul/Avalonia
that referenced
this pull request
Jun 23, 2026
Co-authored-by: Julien Lebosquain <julien@lebosquain.net>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does the pull request do?
Adds a one-time probe for
user32.dll!GetPointerDeviceRectsand falls back toPOINTER_INFO.ptPixelLocationwhen the export is missing. This stops Avaloniafrom crashing on the first WM_POINTER message under Wine/Proton, where that
WM_POINTER ancillary API has never been implemented.
Fixes #21081.
What is the current behavior?
WindowImpl.GetHimetricLocation(added in #16850) unconditionally P/InvokesGetPointerDeviceRectsto convertptHimetricLocationRawinto screen pixels.Wine/Proton's
user32.dlldoes not export this function, so on the firsttouch/click the runtime throws:
The exception is fatal in NativeAOT builds (the original report) and in any
configuration where the Win32 message pump's exception isn't being swallowed,
which on Steam Deck means the very first tap on the window's close button
crashes the app.
How was the solution implemented (if it's not obvious)?
The probe uses the same
LoadLibrary+GetProcAddresspattern thatWin32Platform.SetDpiAwarenessalready uses forSetProcessDpiAwarenessContexti.e., the established Avalonia way ofdealing with optional Win32 entry points without paying for try/catch on a
hot path