Skip to content

[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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Ahamed-Ali
Copy link
Contributor

@Ahamed-Ali Ahamed-Ali commented Jul 10, 2025

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

  • Events from the other (minimized) window are interfering with the active (live) window.

Description of Change

  • Only allow pointer events to be handled if they originate from the currently active (live) window

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

  • Android
  • Windows
  • iOS
  • Mac

Screenshot

Before Issue Fix After Issue Fix
WithFlickerofPointerGestures.mp4
WithFixOfPointerGestures.mp4

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Jul 10, 2025
Copy link
Contributor

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.

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Jul 10, 2025
@Ahamed-Ali Ahamed-Ali marked this pull request as ready for review July 10, 2025 13:48
@Copilot Copilot AI review requested due to automatic review settings July 10, 2025 13:48
@Ahamed-Ali Ahamed-Ali requested a review from a team as a code owner July 10, 2025 13:48
Copy link
Contributor

@Copilot Copilot AI left a 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.

Comment on lines +702 to +703
catch
{
Copy link
Preview

Copilot AI Jul 10, 2025

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.

Suggested change
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))
Copy link
Preview

Copilot AI Jul 10, 2025

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.

@PureWeen PureWeen added this to the .NET 9 SR10 milestone Jul 10, 2025
@PureWeen PureWeen added the p/0 Work that we can't release without label Jul 10, 2025
@PureWeen PureWeen moved this from Todo to Ready To Review in MAUI SDK Ongoing Jul 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community ✨ Community Contribution p/0 Work that we can't release without partner/syncfusion Issues / PR's with Syncfusion collaboration
Projects
Status: Ready To Review
2 participants