Skip to content

Fix non primary buttons not being captured on windows - #188394

Merged
auto-submit[bot] merged 5 commits into
flutter:masterfrom
CodeDoctorDE:windows/capture-non-primary
Jul 23, 2026
Merged

auto-submit[bot] merged 5 commits into
flutter:masterfrom
CodeDoctorDE:windows/capture-non-primary

Conversation

@CodeDoctorDE

@CodeDoctorDE CodeDoctorDE commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Closes #166309.

Windows only captured mouse input for primary-button drags. As a result,
drag gestures using middle, secondary, or X buttons received a pointer
remove when leaving the client area.

Capture is now enabled for every supported mouse button and released only
after the last pressed mouse button is released.

Also tested on my universal flutter input demo: https://github.com/CodeDoctorDE/flutter-input-demo/tree/e448c2cf42981d9c8b5186a7e43d1b82a0239619.

Currently in draft since I cannot have 2 pull requests open at the same time.

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.

@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 Jun 23, 2026
@CodeDoctorDE
CodeDoctorDE marked this pull request as ready for review June 27, 2026 08:23
@CodeDoctorDE
CodeDoctorDE requested a review from a team as a code owner June 27, 2026 08:23

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

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.

Code Review

This pull request updates pointer capture behavior in FlutterWindow to capture the pointer on any mouse button down event and adds a corresponding unit test. However, a critical bug was identified where flutter_button is calculated using button_pressed before it is updated with the current message, which can lead to incorrect button reporting. Additionally, checking flutter_button == 0 is not a reliable way to determine if all mouse buttons have been released, and using a bitmask on wparam is recommended instead.

Comment thread engine/src/flutter/shell/platform/windows/flutter_window.cc Outdated
@mattkae
mattkae self-requested a review July 1, 2026 20:44
@AbdeMohlbi AbdeMohlbi added CICD Run CI/CD and removed CICD Run CI/CD labels Jul 3, 2026
@CodeDoctorDE
CodeDoctorDE force-pushed the windows/capture-non-primary branch from 2e64b36 to 33539bf Compare July 3, 2026 08:41
@AbdeMohlbi AbdeMohlbi added the CICD Run CI/CD label Jul 3, 2026
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Jul 3, 2026
@AbdeMohlbi AbdeMohlbi added the CICD Run CI/CD label Jul 3, 2026

@mattkae mattkae left a comment

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.

Thanks for the contribution + tests! I have one piece of feedback

Comment thread engine/src/flutter/shell/platform/windows/flutter_window.cc
@mattkae
mattkae requested a review from loic-sharma July 6, 2026 20:19
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Jul 6, 2026

@mattkae mattkae left a comment

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.

Thanks for the contribution! cc @loic-sharma

@AbdeMohlbi AbdeMohlbi added the CICD Run CI/CD label Jul 9, 2026
@CodeDoctorDE

Copy link
Copy Markdown
Contributor Author

looks like infra failure?

@mattkae

mattkae commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

looks like infra failure?

Rerunning 🤞

@CodeDoctorDE

Copy link
Copy Markdown
Contributor Author

Now everything is working execpt mac_unopt which says [ci/ios_debug_unopt_sim](https://cr-buildbucket.appspot.com/build/8676631332164702209) (infra failure).

@CodeDoctorDE
CodeDoctorDE force-pushed the windows/capture-non-primary branch from 642eba6 to 73b013a Compare July 20, 2026 16:39
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Jul 20, 2026
@AbdeMohlbi AbdeMohlbi added the CICD Run CI/CD label Jul 20, 2026
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Jul 22, 2026
@mattkae mattkae added the CICD Run CI/CD label Jul 22, 2026

@loic-sharma loic-sharma left a comment

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.

LGTM, thanks!

@loic-sharma loic-sharma added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 23, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Jul 23, 2026
Merged via the queue into flutter:master with commit 2b9bbc8 Jul 23, 2026
26 of 27 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jul 23, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Jul 24, 2026
flutter/flutter@2a2a79d...b65f4d9

2026-07-24 [email protected] Add dart_runtime_service_vm_aot.dart.snapshot to the snapshot list in the macOS code signing configuration (flutter/flutter#189981)
2026-07-24 [email protected] Roll Fuchsia Test Scripts from wLST_A-xfOeGT_5mj... to E8hJ1AfK8CtGtaES0... (flutter/flutter#189956)
2026-07-23 [email protected] Consolidate AndroidArch and DarwinArch into CpuArch (flutter/flutter#189315)
2026-07-23 [email protected] Roll Dart SDK from 9258584f98b8 to e3fc57eae9eb (7 revisions) (flutter/flutter#189949)
2026-07-23 [email protected] [flutter_tools] Do not always wait for the full timeout when running Spotlight to locate Android Studio on macOS (flutter/flutter#189952)
2026-07-23 [email protected] Roll Skia from 1d8bf9270d8c to 6e9c4687c001 (15 revisions) (flutter/flutter#189954)
2026-07-23 [email protected] [flutter_tools] Initialize Cache.flutterRoot at the start of the upgrade_test suite (flutter/flutter#189937)
2026-07-23 [email protected] Parse AndroidX property in gradle.properties (flutter/flutter#188372)
2026-07-23 [email protected] [Impeller]Use the IO context for OpenGL program setup (flutter/flutter#185723)
2026-07-23 [email protected] Allow building projects lacking Runner.xcworkspace (flutter/flutter#186239)
2026-07-23 [email protected] [flutter_tools] Invalidate WebEntrypointTarget when plugin set changes (flutter/flutter#189460)
2026-07-23 [email protected] Bump devtools_shared to 13.1.0 (flutter/flutter#189507)
2026-07-23 [email protected] forceNdkDownload should skip configuring cmake when ndk-build is used (flutter/flutter#187201)
2026-07-23 [email protected] Disable execution order shuffling for the flutter_tools upgrade_test suite (flutter/flutter#189920)
2026-07-23 [email protected] Move WindowManager outside of WidgetsApp (flutter/flutter#188866)
2026-07-23 [email protected] Roll Skia from 3424966b8a2b to 1d8bf9270d8c (3 revisions) (flutter/flutter#189901)
2026-07-23 [email protected] Roll Fuchsia Linux SDK from GswhlPRO-D1qSNclx... to 9org0yL3yZkp80x5S... (flutter/flutter#189898)
2026-07-23 [email protected] Remove outdated logs that were added to track #172636 (flutter/flutter#189282)
2026-07-23 [email protected] Roll Skia from 5e183e5aeac5 to 3424966b8a2b (33 revisions) (flutter/flutter#189890)
2026-07-23 [email protected] [examples] Use super parameters in missed spots (flutter/flutter#186194)
2026-07-23 [email protected] [flutter_tools] Bound Spotlight mdfind execution with timeout on macOS (flutter/flutter#189461)
2026-07-23 [email protected] Fix non primary buttons not being captured on windows (flutter/flutter#188394)
2026-07-22 [email protected] Listen to log reader before VM Service and make delay configurable (flutter/flutter#187202)
2026-07-22 [email protected] Roll Dart SDK from 1e65011ee004 to 9258584f98b8 (7 revisions) (flutter/flutter#189883)
2026-07-22 [email protected] Adds skill for generating engine diffs for new releases. (flutter/flutter#189869)
2026-07-22 [email protected] [ios,macos] Add Swift Sourcekit LSP support (flutter/flutter#189761)
2026-07-22 [email protected] [iOS] Mark DisplayLinkManager.shared and init() @mainactor (flutter/flutter#189815)
2026-07-22 [email protected] Fix `Rect::ExpandToMinTransformedSize` to return the input rectangle when no expansion is needed, and remove 1-pixel roundrect to rect simplification (flutter/flutter#189808)
2026-07-22 [email protected] Skip emulator.getEmulators test (flutter/flutter#189879)
2026-07-22 [email protected] Fix null terminator in input truncates clipboard (flutter/flutter#188652)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
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 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.

PanGestureRecognizer with non-primary button gets cancelled when dragging out of the window

4 participants