Fix incorrect touch point coordinates when running application on secondary screen with WM_Pointer enabled#11051
Open
lindexi wants to merge 1 commit intodotnet:mainfrom
Open
Fix incorrect touch point coordinates when running application on secondary screen with WM_Pointer enabled#11051lindexi wants to merge 1 commit intodotnet:mainfrom
lindexi wants to merge 1 commit intodotnet:mainfrom
Conversation
82d18c2 to
c2cd95f
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an issue where touch point coordinates were incorrect when running a WPF application on a secondary screen with WM_Pointer enabled. The problem occurred because coordinates were being calculated relative to the primary screen instead of the current screen.
Key changes:
- Modified the
GetOriginOffsetsLogicalmethod to calculate coordinates relative to the current screen - Replaced direct
PointToScreencall with manual coordinate calculation usingClientToScreenand display rectangle offsets - Added proper handling for multi-screen scenarios by subtracting display rectangle offsets
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
...Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/HwndPointerInputProvider.cs
Show resolved
Hide resolved
...Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/HwndPointerInputProvider.cs
Show resolved
Hide resolved
…ondary screen with WM_Pointer enabled dotnet#8517
c2cd95f to
9df0243
Compare
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.
Fixes #8517
Main PR
Description
In the GetOriginOffsetsLogical method, the expected behavior is to return coordinates relative to the current screen. However, due to Windows' mechanism, when operating on a non-primary screen, the method returns coordinates relative to the primary screen. This leads to issue #8517. The fix involves subtracting the Left and Top values of displayRect during the calculation, ensuring that the resulting coordinates are relative to the current screen rather than the primary screen, thereby resolving the touch offset problem.
Customer Impact
Fix the bug.
Regression
Testing
The dotnet-campus#9 was tested for two years in many my users device. And this PR is pick from dotnet-campus#9
Risk
Low. For the vast majority of users, this has no impact. Most users have only a single touchscreen, in which case the displayRect's Left and Top values are both zero. This means that point.x - displayRect.left and point.y - displayRect.top will not alter the x and y values of the point.
Microsoft Reviewers: Open in CodeFlow