Skip to content

Fix pointer position#185850

Merged
auto-submit[bot] merged 3 commits into
flutter:masterfrom
CodeDoctorDE:windows/fix-pointer-position
May 4, 2026
Merged

Fix pointer position#185850
auto-submit[bot] merged 3 commits into
flutter:masterfrom
CodeDoctorDE:windows/fix-pointer-position

Conversation

@CodeDoctorDE
Copy link
Copy Markdown
Contributor

Closes #184954.

grafik

This pull requests fixes a regression in the POINTER input event handling that was introduced with the stylus support. The regression caused the pointer position to be global instead of relative to the window, which broke touch and stylus input handling in many applications.
Thanks to @dkmcgowan for suggesting a fix. I have updated my flutter input demo to also see the pointer position.
I tested it with the latest flutter master branch which shows the incorrect pointer position, and with my patch which shows the correct pointer position.

This fix should also be backported to the beta branch to ensure that it is included in the next stable release, as it affects a wide range of applications that rely on pointer input events.

For testing this pr, i used my flutter input demo project which can be found here: https://github.com/CodeDoctorDE/flutter-input-demo/tree/ad61c7d6f5011594a90cbb2b9840904144f877b5

PS: I run et build to build the engine and it took over 1 1/2 hours to complete. I'm not sure if this is expected or if there is a more efficient way to build the engine to test changes. Any tips on how to speed up the build process would be appreciated.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

@CodeDoctorDE CodeDoctorDE requested a review from a team as a code owner April 30, 2026 19:11
@flutter-dashboard
Copy link
Copy Markdown

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@github-actions github-actions Bot added engine flutter/engine related. See also e: labels. platform-windows Building on or for Windows specifically a: desktop Running on desktop team-windows Owned by the Windows platform team labels Apr 30, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the Windows platform implementation to convert pointer event coordinates from screen to client space for WM_POINTERUPDATE, WM_POINTERUP, and WM_POINTERLEAVE messages. Feedback indicates that the fix is incomplete because it does not address WM_POINTERDOWN or other relevant pointer events. Additionally, the changes lack automated regression tests, which are required by the Flutter style guide for engine modifications.

Comment on lines 545 to 547
case WM_POINTERUPDATE:
case WM_POINTERUP:
case WM_POINTERLEAVE: {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The fix appears to be incomplete as it does not address WM_POINTERDOWN. Like the other WM_POINTER messages, WM_POINTERDOWN also provides screen coordinates in lParam and requires conversion to client coordinates. Please ensure all relevant WM_POINTER messages (including WM_POINTERDOWN and potentially WM_POINTERENTER) are updated to use client coordinates.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not sure what the ai meant, this has all cases covered:
case WM_POINTERDOWN:
case WM_POINTERUPDATE:
case WM_POINTERUP:
case WM_POINTERLEAVE: {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems like a hallucination. Marking as closed

Comment thread engine/src/flutter/shell/platform/windows/flutter_window.cc
@AbdeMohlbi AbdeMohlbi added the CICD Run CI/CD label Apr 30, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 30, 2026
@loic-sharma loic-sharma requested a review from mattkae April 30, 2026 23:09
@loic-sharma
Copy link
Copy Markdown
Member

@mattkae would you be able to review this as well? We'll want to cherry pick this

@loic-sharma
Copy link
Copy Markdown
Member

PS: I run et build to build the engine and it took over 1 1/2 hours to complete. I'm not sure if this is expected or if there is a more efficient way to build the engine to test changes. Any tips on how to speed up the build process would be appreciated.

Oh wow. Sadly, I don't have any tips here. Good hardware can cut down the build time dramatically, but I know that can be expensive 😞

Copy link
Copy Markdown
Member

@loic-sharma loic-sharma left a comment

Choose a reason for hiding this comment

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

Thanks for the very fast turnaround, it is very appreciated!

@loic-sharma loic-sharma added the CICD Run CI/CD label Apr 30, 2026
@loic-sharma
Copy link
Copy Markdown
Member

The Google testing failures look unrelated to this change: it's a failure on setting IDE breakpoints on Linux. I've restarted Google testing. If that test fails again, we might need to rebase this PR ontop of the latest master commit.

@loic-sharma
Copy link
Copy Markdown
Member

@CodeDoctorDE Could you rebase off latest master?

After adding ScreenToClient for WM_POINTER*, the old unit tests were still injecting client coordinates in lParam. Real WM_POINTER messages provide screen coordinates, so the tests needed to convert their injected points first.
@CodeDoctorDE CodeDoctorDE force-pushed the windows/fix-pointer-position branch from 10156a6 to 592c5d0 Compare May 2, 2026 06:11
@CodeDoctorDE
Copy link
Copy Markdown
Contributor Author

CodeDoctorDE commented May 2, 2026

Thanks :)
Done

@github-actions github-actions Bot removed the CICD Run CI/CD label May 2, 2026
@loic-sharma loic-sharma added the CICD Run CI/CD label May 2, 2026
Copy link
Copy Markdown
Member

@loic-sharma loic-sharma left a comment

Choose a reason for hiding this comment

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

LGTM

@loic-sharma loic-sharma added the autosubmit Merge PR when tree becomes green via auto submit App label May 2, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label May 2, 2026
@auto-submit
Copy link
Copy Markdown
Contributor

auto-submit Bot commented May 2, 2026

autosubmit label was removed for flutter/flutter/185850, because This PR has not met approval requirements for merging. The PR author is not a member of flutter-hackers and needs 1 more review(s) in order to merge this PR.

  • Merge guidelines: A PR needs at least one approved review if the author is already part of flutter-hackers or two member reviews if the author is not a member of flutter-hackers before re-applying the autosubmit label. Reviewers: If you left a comment approving, please use the "approve" review action instead.

@loic-sharma
Copy link
Copy Markdown
Member

@mattkae or @knopp, could you do the second approval for this? We'll want to cherry pick this to the beta.

Copy link
Copy Markdown
Contributor

@mattkae mattkae left a comment

Choose a reason for hiding this comment

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

Good catch!

@mattkae
Copy link
Copy Markdown
Contributor

mattkae commented May 4, 2026

@mattkae or @knopp, could you do the second approval for this? We'll want to cherry pick this to the beta.

Done!

@loic-sharma loic-sharma added the autosubmit Merge PR when tree becomes green via auto submit App label May 4, 2026
@auto-submit auto-submit Bot added this pull request to the merge queue May 4, 2026
Merged via the queue into flutter:master with commit 18d78e9 May 4, 2026
208 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label May 4, 2026
@loic-sharma loic-sharma added the cp: beta cherry pick this pull request to beta release candidate branch label May 4, 2026
@vashworth vashworth mentioned this pull request May 5, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: desktop Running on desktop CICD Run CI/CD cp: beta cherry pick this pull request to beta release candidate branch engine flutter/engine related. See also e: labels. platform-windows Building on or for Windows specifically team-windows Owned by the Windows platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Windows][ARM64] Touchscreen taps misaligned from widgets (large offset); mouse is correct — regression after 5f58b37fdaa

4 participants