engine icon indicating copy to clipboard operation
engine copied to clipboard

[Linux] Add Multi-Touch Support for Linux

Open RBT22 opened this issue 1 year ago • 10 comments

This draft PR aims to address the lack of multi-touch support under Linux, leveraging the existing implementation used for Windows. As I am not an expert in this domain, I would greatly appreciate feedback on the implementation.

https://github.com/flutter/flutter/issues/133239 https://github.com/flutter/flutter/issues/52202

Pre-launch Checklist

  • [x] I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • [x] I read the Tree Hygiene wiki page, which explains my responsibilities.
  • [x] I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • [x] 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 ///).
  • [x] I signed the CLA.
  • [ ] All existing and new tests are passing.

RBT22 avatar Jul 30 '24 11:07 RBT22

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

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.

flutter-dashboard[bot] avatar Jul 30 '24 11:07 flutter-dashboard[bot]

Thanks for working on this! I did a quick first review, the main issues seem to be moving this logic into it's own class and using GObject style instead of C++ style.

robert-ancell avatar Aug 13 '24 23:08 robert-ancell

Thank you for the feedback! I’ll try to allocate some time for the restructuring next week.

I’ve been testing the code since the PR was opened, and I found an issue with the current implementation on Ubuntu 24.04. When using a three-finger gesture to switch between applications, the touch_event_cb's GDK_TOUCH_END part is not triggered when focus is lost. This results in various unexpected behaviors because the pointers are not removed. Do you have a suggestion for which signal handler could be used to handle this? Thanks in advance!

RBT22 avatar Aug 21 '24 09:08 RBT22

Based on the behaviour of the other GTK input events I think you just have to handle the missing events and synthesize any that are missing. This is because Flutter expects a perfect input stream and GTK doesn't seem to guarantee this. I expect the event was intercepted by the shell or another layer in GTK and will not be reported to the application.

If you do think it's a mistake in GTK though please make a test case and report at https://gitlab.gnome.org/GNOME/gtk/ - that should clarify if we need to handle this ourselves.

robert-ancell avatar Aug 22 '24 04:08 robert-ancell

@RBT22 Are you planning on resuming the work for this soon ?

The lack of multi-touch handling on linux is currently a blocking issue here...

chrisDexfo avatar Sep 06 '24 18:09 chrisDexfo

Sorry for the inconvenience, everyone. Something urgent has come up, and I likely won’t be able to finish this in the next 2-3 weeks.

RBT22 avatar Sep 06 '24 18:09 RBT22

@RBT22 Any chances you'll resume work on this soon ?

chrisDexfo avatar Sep 24 '24 13:09 chrisDexfo

@chrisDexfo I'm still having higher priority tasks at the moment. It will likely take about two more weeks to resolve. I'll be sure to get back to this project as soon as possible after that. Thanks for your understanding!

RBT22 avatar Sep 27 '24 14:09 RBT22

This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold.

flutter-dashboard[bot] avatar Oct 17 '24 14:10 flutter-dashboard[bot]

I’ve done some refactoring. @robert-ancell, could you please take a look?

The issue I mentioned earlier with the missing GDK_TOUCH_END events still persists. We use our app with GNOME gestures disabled, so I didn’t explore that further. I’m not entirely sure where the event synthesis should occur. What I did find is that the leave_notify_event_cb is being triggered in those cases, but with a time value of zero.

RBT22 avatar Oct 22 '24 10:10 RBT22

I wonder how you see the relationship between the touch manager and the pointer manager.

  • I was guessing that you'd like touch manager manages touch screens, while the pointer manager manages mouse. (There will be some duplicate code but it might be acceptable, since handling multi-pointer is different from handling buttons.) However, in this case the touch manager should not need to handle buttons at all.
  • Or you might want to create a unified handler that handles both multi-pointer and buttons. But then you'll want to remove the pointer manager, which this PR doesn't.

dkwingsmt avatar Dec 02 '24 22:12 dkwingsmt

@dkwingsmt I see what you mean about the relationship between the touch manager and pointer manager. Maybe it’d make sense to move a simplified state to the fl_touch_manager from the engine to clean things up a bit?

As for a unified handler, I get the idea, but I’m not up for tackling that myself right now. :)

RBT22 avatar Dec 03 '24 08:12 RBT22

Yeah I wouldn't expect the unified one as well. So I'm practically saying that you should not need to handle buttons. :)

dkwingsmt avatar Dec 03 '24 08:12 dkwingsmt

I moved and simplified the state to FtTouchManager. Also, I integrated the ID generation.

RBT22 avatar Dec 11 '24 11:12 RBT22

@dkwingsmt do want to do a review before landing this?

robert-ancell avatar Dec 11 '24 21:12 robert-ancell

will this be included in next official release ?

chrisDexfo avatar Dec 19 '24 17:12 chrisDexfo