-
Notifications
You must be signed in to change notification settings - Fork 6k
Add support for mice on iOS 13.4+ #19965
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 Hixie on the #hackers channel in Chat. Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
A few things:
|
gaaclarke
left a comment
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.
Noice! Just a few nits. What about adding a test?
| // Flutter expects pointers to be added before events are sent for them. | ||
| bool flutter_state_is_added = false; | ||
|
|
||
| // Current coordinate of the mouse cursor |
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.
Are the units logical or real pixels?
| // UIScrollView with height zero and a content offset so we can get those events. See also: | ||
| // https://github.com/flutter/flutter/issues/35050 | ||
| fml::scoped_nsobject<UIScrollView> _scrollView; | ||
| #ifdef __IPHONE_13_4 |
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.
These don't have to be ifdef'd. I think it's better to limit the amount of conditional compilation.
| * Dart-related state and asynchronous tasks when navigating back and forth between a | ||
| * FlutterViewController and other `UIViewController`s. | ||
| */ | ||
| #ifdef __IPHONE_13_4 |
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.
You shouldn't need this, the presence of UIPointerInteractionDelegate will exist depending on the SDK used for compilation. We don't need to support old versions of Xcode.
| << "FlutterViewController's view is loaded but is not attached to a FlutterEngine"; | ||
| [_engine.get() attachView]; | ||
|
|
||
| #ifdef __IPHONE_13_4 |
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'd also remove this preprocessor guard.
| return self.presentedViewController != nil || self.isPresentingViewControllerAnimating; | ||
| } | ||
|
|
||
| #ifdef __IPHONE_13_4 |
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.
here too
| auto packet = std::make_unique<flutter::PointerDataPacket>(1); | ||
| _mouseState.location = request.location; | ||
|
|
||
| flutter::PointerData pointer_data = [self generatePointerDataForMouse]; |
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.
nit: A static C function for generatePointerDataForMouse would execute faster because of dynamic dispatch.
| flutter::PointerData pointer_data = [self generatePointerDataForMouse]; | ||
|
|
||
| pointer_data.signal_kind = flutter::PointerData::SignalKind::kNone; | ||
| packet->SetPointerData(0, pointer_data); |
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.
Please annotate what "0" means by pulling it into a variable or with arg comments.
|
|
||
| flutter::PointerData pointer_data = [self generatePointerDataForMouse]; | ||
| pointer_data.signal_kind = flutter::PointerData::SignalKind::kScroll; | ||
| pointer_data.scroll_delta_x = (translation.x - _mouseState.last_translation.x) * scale; |
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.
super nit: you are scaling these values twice, once when you receive them and once when they are used as "last_translation". You could avoid the multiplication by storing the scaled value.
|
@chinmaygarde following up from your question here (for others: what specifically I'd like looked at for review):
|
|
cc @gw280: Just going through old PR and this one looks stale. Feel free to re-open if I am mistaken. |
|
Hey @gw280 any chance you want to take another pass at this? I think the priority on this is going to rapidly escalate at the end of this year: flutter/flutter#54663 |
|
hey @gw280 , thanks for working on this feature. Might be related flutter/flutter#129640 |
Description
Initial pass at adding support for iOS 13.4+ pointer interactions. This currently supports mouse hover and basic scroll events.
Related Issues
flutter/flutter#55809