-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Windows]Fixed the PointerGestureRecognizer behaves incorrectly when multiple windows are open. #30537
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
base: main
Are you sure you want to change the base?
Conversation
…re with the active window
Hey there @@Ahamed-Ali! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR ensures that pointer events are only processed for the currently active window on Windows, preventing background or minimized windows from interfering with live interactions.
- Adds a relevance check (
IsPointerEventRelevantToCurrentElement
) before dispatching pointer gestures. - Early-returns from
HandlePgrPointerEvent
when events originate from a different or inactive window. - Encapsulates window-root comparison logic in a private helper with exception safety.
catch | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Catching all exceptions silently may mask underlying issues. Consider catching specific exception types and at least logging unexpected errors for diagnostics.
catch | |
{ | |
catch (Exception ex) | |
{ | |
// Log the exception for diagnostics | |
_logger?.LogError(ex, "An error occurred while validating pointer event relevance."); |
Copilot uses AI. Check for mistakes.
@@ -664,13 +664,48 @@ private void HandlePgrPointerEvent(PointerRoutedEventArgs e, Action<View, Pointe | |||
return; | |||
} | |||
|
|||
// Check if the pointer event is relevant to the current element's window | |||
if (!IsPointerEventRelevantToCurrentElement(e)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new pointer filtering logic isn’t covered by existing tests. Please add corresponding UI tests in TestCases.HostApp and unit/UI tests in TestCases.Shared.Tests to validate multi-window pointer behavior as per CodingGuidelineID 254.
Copilot uses AI. Check for mistakes.
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Root Cause of the issue
Description of Change
This ensures:
Minimized or background windows do not interfere with active window interactions.
Pointer events are scoped and filtered based on the correct visual root or window handle.
Issues Fixed
Fixes #30536
Fixes #27430
Tested the behaviour in the following platforms
Screenshot
WithFlickerofPointerGestures.mp4
WithFixOfPointerGestures.mp4