-
Notifications
You must be signed in to change notification settings - Fork 6k
[Linux] Add Multi-Touch Support for Linux #54214
Conversation
|
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. |
| int32_t device_id, | ||
| int modifiers_state); | ||
|
|
||
| void SendPointerEventWithData(FlEngine* engine, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be called fl_engine_send_pointer_event
| double scroll_delta_y, | ||
| int64_t buttons); | ||
|
|
||
| void OnPointerDown(FlEngine* self, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FlEngine shouldn't contain handlers like this, instead look at fl_scrolling_manager.cc as an example of how to handle this in a separate class.
shell/platform/linux/fl_renderer.h
Outdated
| // Struct holding the state of an individual pointer. The engine doesn't keep | ||
| // track of which buttons have been pressed, so it's the embedding's | ||
| // responsibility. | ||
| struct PointerState { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This struct seems to be in the wrong place, as it relates to the engine, not the renderer. To match existing code like fl_engine_send_mouse_pointer_event this should probably be an internal struct and not in a header.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved it to the engine, but not 100% sure what you meant.. Can you help me with this, please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This structure is only used in fl_engine.cc, therefore it should be defined in there. It's currently in a header, which suggests it's part of external API for a module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thanks for the clarification!
shell/platform/linux/fl_engine.cc
Outdated
| static constexpr int32_t kPointerPanZoomDeviceId = 1; | ||
|
|
||
| // Keeps track of pointer states in relation to the window. | ||
| std::unordered_map<int32_t, std::unique_ptr<PointerState>> pointer_states_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be inside a class and use GHashTable (it gets too confusing mixing C++ and GObject).
|
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. |
|
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! |
|
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. |
|
@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... |
|
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 Any chances you'll resume work on this soon ? |
|
@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! |
|
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. |
0c5aaff to
8c74a1e
Compare
|
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. |
shell/platform/linux/fl_engine.cc
Outdated
| } | ||
| } | ||
|
|
||
| void fl_engine_send_pointer_event(FlEngine* self, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The engine has methods for each type of event, e.g. fl_engine_send_pointer_pan_zoom_event - adding this general event method doesn't fit in with the existing architecture. How many new pointer events are required? Could there be specific methods for these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel the naming could be clearer. It might make more sense as fl_engine_send_touch_pointer_event. Otherwise, if I'm getting this right, we’d end up needing five separate methods for each phase we use. Should I go ahead with that approach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say yes, make five methods to match the existing code. We can always consolidate them later if necessary.
| struct _FlTouchManager { | ||
| GObject parent_instance; | ||
|
|
||
| GWeakRef view_delegate; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be replaced with a reference to the engine - the view delegate only forwards the events to the engine. The existing delegates have been reduced or removed as part of the multi-view work.
| @@ -0,0 +1,77 @@ | |||
| // Copyright 2013 The Flutter Authors. All rights reserved. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class makes this very hard to understand. It's copied from another project, it's in C++ style which doesn't fit in well with the other code. A number of methods aren't being used. It's not used by any other code. I think this could be simplified and merged into FlTouchManager, though that's not a blocker and could be done at a later stage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think with the removal of the view delegate this should be pretty close to landing. I can see some parts of it being refactored later, but it's not worth blocking on. You will need to add some tests though. Thanks for your patience!
0e416b6 to
45e850f
Compare
3e02739 to
1ae0500
Compare
|
I wonder how you see the relationship between the touch manager and the pointer manager.
|
|
@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. :) |
…wn, move, up, and remove events
…Table for touch ID management
49ceb1d to
59190a5
Compare
|
I moved and simplified the state to FtTouchManager. Also, I integrated the ID generation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks!
|
@dkwingsmt do want to do a review before landing this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for your contribution!
| EXPECT_EQ(pointer_events[4].timestamp, | ||
| 1000lu); // Milliseconds -> Microseconds | ||
| EXPECT_EQ(pointer_events[4].phase, kRemove); | ||
| } No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised that EOF empty line isn't enforced. Just if you're interested:
| } | |
| } | |
…160128) flutter/engine@b8034f1...e352461 2024-12-11 jonahwilliams@google.com [Impeller] remove std::vector usage in render pass vk. (flutter/engine#57132) 2024-12-11 43723477+RBT22@users.noreply.github.com [Linux] Add Multi-Touch Support for Linux (flutter/engine#54214) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC jonahwilliams@google.com,zra@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: 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
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. flutter#133239 flutter#52202 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
|
will this be included in next official release ? |
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.
flutter/flutter#133239
flutter/flutter#52202
Pre-launch Checklist
///).