New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow GestureBinding
subclasses to know hitTest
information
#113831
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 (don't just cc him here, he won't see it! He's on 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. |
@@ -330,6 +330,8 @@ mixin GestureBinding on BindingBase implements HitTestable, HitTestDispatcher, H | |||
/// | |||
/// The state of hovering pointers is not tracked because that would require | |||
/// hit-testing on every frame. | |||
@protected | |||
Map<int, HitTestResult> get hitTests => _hitTests; |
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 don't think we should make this part of the public API.
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.
Hmm what about the "alternative soluution" described above?
An alternative solution, which the flutter-smooth branch is currently using (but more hacky), may be to add a filter to dispatchEvent. Then, we can utilize the filter to skip those RenderObjects in the main tree.
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.
Or, as for this one: Is it acceptable to expose a readonly version? For example:
UnmodifiableMapView<int, UnmodifiableHitTestResultView> get hitTests => ...;
where unmodifiable map is https://api.flutter.dev/flutter/dart-collection/UnmodifiableMapView-class.html
and UnmodifiableHitTestResultView can be something like:
class UnmodifiableHitTestResultView {
final HitTestResult _actual;
... only provide a few readonly method, so users have no possibility to write anything to it...
}
This is internal state that nobody should depend on. If you have a use case for this, I suggest filing an issue that describes what you want to achieve instead of describing a solution. |
Ok, I will explain why this is needed in a separate issue later. |
Issue created describing this: #115899 |
This PR allows the subclasses of
GestureBinding
to read thehitTest
information. It is directly needed in flutter_smooth, because flutter_smooth has extra call todispatchEvent
and only execute those who are in auxiliary tree (and omit those in the main tree) during preempt render. I can copy-and-paste the content ofdispatchEvent
to mimic the behavior, but there is one missing piece: the hitTest information. By adding this PR, it can work.An alternative solution, which the
flutter-smooth
branch is currently using (but more hacky), may be to add afilter
todispatchEvent
. Then, we can utilize the filter to skip those RenderObjects in the main tree.Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.