Skip to content

Conversation

@2bndy5
Copy link

@2bndy5 2bndy5 commented Feb 17, 2025

This patch allows a mouse's back and forward buttons to be reported on Linux.
I tested/verified this on x11 using a sample flutter project that employs a custom RawGestureDetector to act upon the detected mouse event's buttons (back and forward).

This relates to #152128 and its parent issue #115641. Clearly, more discussion needs to be had about other mouse buttons before #152128 can be fully resolved.

Pre-launch Checklist

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

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!).

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. 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-linux Building on or for Linux specifically a: desktop Running on desktop labels Feb 17, 2025
@robert-ancell
Copy link
Contributor

Code change looks good, just needs more information to work out if this button mapping is consistent for all mice and the same on both X11 and Wayland. See #152128 for more discussion.

@robert-ancell
Copy link
Contributor

See #163503 which interprets the main three buttons more clearly.

Copy link
Contributor

@robert-ancell robert-ancell left a comment

Choose a reason for hiding this comment

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

Based on the prior art in https://gitlab.gnome.org/GNOME/epiphany/-/blob/main/embed/ephy-web-view.c I think this is the expected behaviour. I think we just need to add a comment about why 8 and 9 are used - use a constexpr for these at the top of the file with the comment. Also this doesn't completely resolve #152128, as this doesn't support other buttons. So remove the link from the commit message.

@2bndy5
Copy link
Author

2bndy5 commented Feb 18, 2025

I adjusted the description about related issues.

I'm open to adding more information concerning the "magic" numbers used here (8 & 9). It would certainly help to know all the platforms this patch would affect. My personal aim was just for Linux OS desktop environments, but research from @robert-ancell implies there are other implicated platforms here.

@robert-ancell Thank you for the quick responses and deep dives related to this!

@robert-ancell
Copy link
Contributor

The only platform affected here is Linux. If this was a cross-platform GTK app this would be more complicated, but since the Flutter Linux embedder only runs on Linux we don't have to worry about that. The only subplatforms are X11 vs Wayland, but it seems they send the same button value, which is probably expected as they ultimately come from the kernel.

@2bndy5
Copy link
Author

2bndy5 commented Feb 18, 2025

Thanks for all the clarification. I will try to distill the info you've posted into commented context.

add explanatory context in comments
@2bndy5
Copy link
Author

2bndy5 commented Feb 18, 2025

I couldn't find any guideline about naming const expressions. I just went with kMouseButtonBack and kMouseButtonForward (based on clang-tidy output). I'm open to suggestions if they need to be more specific (like kLinuxMouseButton***).

@2bndy5 2bndy5 requested a review from robert-ancell February 18, 2025 18:59
Copy link
Contributor

@robert-ancell robert-ancell left a comment

Choose a reason for hiding this comment

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

Nice work, thanks!

@robert-ancell
Copy link
Contributor

I've asked on Discord for a test exemption for this - I looked at writing a test but it was very hard to generate the fake mouse events. In the end the test was just confirming the mapping was the mapping, so I don't think it would add much value anyway.

robert-ancell added a commit to robert-ancell/flutter that referenced this pull request Feb 28, 2025
@robert-ancell
Copy link
Contributor

#164356 is the same change but with restructuring to make it testable.

@2bndy5
Copy link
Author

2bndy5 commented Feb 28, 2025

Excellent work!

Should I close this in favor of #164356 ?

github-merge-queue bot pushed a commit that referenced this pull request Feb 28, 2025
@2bndy5 2bndy5 closed this Feb 28, 2025
@2bndy5 2bndy5 deleted the feature-request-152128 branch February 28, 2025 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: desktop Running on desktop engine flutter/engine related. See also e: labels. platform-linux Building on or for Linux specifically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants