Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Include mouse back and forward buttons on Linux mouse events. #57287

Closed
wants to merge 1 commit into from

Conversation

2bndy5
Copy link

@2bndy5 2bndy5 commented Feb 16, 2025

Like the title says, this includes the mouse's backward and forward buttons reported mouse events.

resolves flutter/flutter#152128

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or the PR is test-exempt. See testing the engine for instructions on writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

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.

@robert-ancell
Copy link
Contributor

This repository is no longer in use - this change should be proposed to https://github.com/flutter/flutter which now contains the engine.

@robert-ancell
Copy link
Contributor

I did review the change, however I'm not sure if buttons 4 and 5 map to back and forward on all mice. Looking at the GTK source it seems buttons 4-7 map to scroll up/down/left/right on X11, and Wayland it states:

/* For compatibility reasons, all additional buttons go after the old 4-7 scroll ones */
gdk_button = button - BUTTON_BASE + 4;

Which I think is incorrect, as this will still set the fourth button will still be set to ID 4.

In Flutters embedder.h it states:

/// If a mouse has more than five buttons, send higher bit shifted values
/// corresponding to the button number: 1 << 5 for the 6th, etc.

which I think we should also be doing for any remaining buttons.

@2bndy5
Copy link
Author

2bndy5 commented Feb 17, 2025

I finally got around to testing this...

Apparently, the mouse back and forward buttons register as 8 & 9 respectively (in GdkEventButton.button). So, the following patch actually works as expected (using et run on a simple flutter project):

    case 8:
      *button = kFlutterPointerButtonMouseBack;
      return TRUE;
    case 9:
      *button = kFlutterPointerButtonMouseForward;
      return TRUE;

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Linux: mouse click events other than primary, secondary and tertiary are not recognized
2 participants