Skip to content
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

Split Mouse from Listener #36217

Merged
merged 26 commits into from Aug 1, 2019

Conversation

@dkwingsmt
Copy link
Contributor

commented Jul 15, 2019

Description

This PR introduces a few breaking changes in order to split the mouse tracking callbacks from Listener. More specifically,

  • Move onPointer{Enter,Hover,Exit} out from Listener, into a new class, MouseRegion.
  • Move onPointer{Enter,Hover,Exit}out from RenderPointerListener, into a new class, RenderMouseRegion.
  • Rename these callbacks from onPointer{Enter,Exit,Hover} into on{Enter,Exit,Hover}.

In order to keep compatibility, Listener will keep onPointer{Enter,Hover,Exit} but mark them as deprecated. They will be removed after the next stable.

For reasoning, impact, and discussion, see #36085

Regarding test change

This PR broke some tests, namely "report which user created widget caused the error" and its variant, in a weird way. It changed the widget in which an error was built, hence changing the error description from

The following assertion was thrown building
RawGestureDetector-\[LabeledGlobalKey<RawGestureDetectorState>#.+\]\(state:
RawGestureDetectorState#.+\(gestures: <none>, behavior: opaque\)\):

into

The following assertion was thrown building Listener:

which seems like a side effect of splitting RenderMouseListener out, and should be harmless.

Since these lines are not the target lines of the aforementioned tests, I decided to tell the tests to skip checking these lines. This change has been discussed with and approved by @chunhtai .

Related Issues

Tests

I added the following tests:

Replace this with a list of the tests that you added as part of this PR. A change in behaviour with no test covering it
will likely get reverted accidentally sooner or later. PRs must include tests for all changed/updated/fixed behaviors. See Test Coverage.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require Flutter developers to manually update their apps to accommodate your change?

dkwingsmt added 2 commits Jul 13, 2019
@dnfield dnfield requested a review from gspencergoog Jul 17, 2019
@dkwingsmt dkwingsmt requested a review from Hixie Jul 24, 2019
onPointerExit: (PointerExitEvent event) => _hideTooltip(),
result = MouseRegion(
onEnter: (PointerEnterEvent event) => _showTooltip(),
onExit: (PointerExitEvent event) => _hideTooltip(),

This comment has been minimized.

Copy link
@Hixie

Hixie Jul 24, 2019

Contributor

why do we use methods in the previous two files and closures here? we should be consistent.

This comment has been minimized.

Copy link
@dkwingsmt

dkwingsmt Jul 24, 2019

Author Contributor

I agree, but I'm leaning towards making as few changes in other files as possible since it's a breaking PR.

This comment has been minimized.

Copy link
@Hixie

Hixie Jul 24, 2019

Contributor

not sure why it being a breaking PR matters here?

But if you want to change it in another PR that's fine. :-)

if (listeners.isEmpty)
listeners.add('<none>');
properties.add(IterableProperty<String>('listeners', listeners));
// TODO(jacobr): add raw listeners to the diagnostics data.

This comment has been minimized.

Copy link
@Hixie

Hixie Jul 24, 2019

Contributor

@jacob314 Is there anything special we need to do to resolve this TODO?

This comment has been minimized.

Copy link
@jacob314

jacob314 Jul 24, 2019

Contributor
properties.add(ObjectFlagProperty<PointerDownEventListener>('onPointerDown', onPointerDown, ifPresent: 'down', level: DiagnosticLevel.fine);

Would be an idiomatic way to expose each of these.
That would hide the output from the default display but let the inspector provide links to the actual listeners used.

This comment has been minimized.

Copy link
@dkwingsmt

dkwingsmt Aug 23, 2019

Author Contributor

@jacob314
The current way allows a clean format with the help of IterableProperty,

'listeners: down, move, up, cancel, signal'

or

'listeners: <none>'

Is there a way to maintain the current format while using ObjectFlagProperty?

This comment has been minimized.

Copy link
@jacob314

jacob314 Aug 24, 2019

Contributor

Not currently. Are there any cases with a subclass that wants to add an additional listener? In that case it could make sense to come up with a scheme that enables defining each listener as an ObjectFlagProperty and then aggregate the properties into a terse summary like listeners: down, move, up, cancel when generating the string output.

dkwingsmt added 2 commits Jul 24, 2019
packages/flutter/lib/src/rendering/proxy_box.dart Outdated Show resolved Hide resolved
packages/flutter/lib/src/rendering/proxy_box.dart Outdated Show resolved Hide resolved
packages/flutter/lib/src/rendering/proxy_box.dart Outdated Show resolved Hide resolved
set onPointerEnter(PointerEnterEventListener value) {
if (_onPointerEnter != value) {
_onPointerEnter = value;
PointerEnterEventListener get onEnter => _onEnter;

This comment has been minimized.

Copy link
@gspencergoog

gspencergoog Jul 25, 2019

Contributor

It's too bad we can't now name these MouseEnterEventListener, etc., but I do understand: that would make it a larger breaking change.

packages/flutter/lib/src/widgets/basic.dart Outdated Show resolved Hide resolved
packages/flutter/lib/src/widgets/basic.dart Outdated Show resolved Hide resolved
Copy link
Contributor

left a comment

LGTM

@dkwingsmt dkwingsmt requested a review from Hixie Jul 26, 2019
@dkwingsmt dkwingsmt referenced this pull request Jul 31, 2019
8 of 9 tasks complete
@dkwingsmt dkwingsmt referenced this pull request Jul 31, 2019
8 of 9 tasks complete
@dkwingsmt dkwingsmt merged commit 5bb8d8f into flutter:master Aug 1, 2019
78 of 79 checks passed
78 of 79 checks passed
tool_coverage-linux Task Summary
Details
WIP Ready for review
Details
add2app-macos Task Summary
Details
add2app-macos
Details
analyze Task Summary
Details
analyze
Details
build_tests-linux Task Summary
Details
build_tests-linux
Details
build_tests-macos Task Summary
Details
build_tests-macos
Details
build_tests-windows Task Summary
Details
build_tests-windows
Details
cla/google All necessary CLAs are signed
customer_testing-linux Task Summary
Details
customer_testing-linux
Details
customer_testing-macos Task Summary
Details
customer_testing-macos
Details
customer_testing-windows Task Summary
Details
customer_testing-windows
Details
deploy_gallery Task Summary
Details
deploy_gallery
Details
deploy_gallery-macos Task Summary
Details
deploy_gallery-macos
Details
docs Task Summary
Details
docs
Details
flutter-build
Details
integration_tests-linux Task Summary
Details
integration_tests-linux
Details
integration_tests-macos Task Summary
Details
integration_tests-macos
Details
integration_tests-windows Task Summary
Details
integration_tests-windows
Details
integration_tests_gradle1-linux Task Summary
Details
integration_tests_gradle1-linux
Details
integration_tests_gradle1-windows Task Summary
Details
integration_tests_gradle1-windows
Details
integration_tests_gradle2-linux Task Summary
Details
integration_tests_gradle2-linux
Details
integration_tests_gradle2-windows Task Summary
Details
integration_tests_gradle2-windows
Details
release_smoke_tests Task Summary
Details
release_smoke_tests
Details
tests_extras-linux Task Summary
Details
tests_extras-linux
Details
tests_extras-macos Task Summary
Details
tests_extras-macos
Details
tests_extras-windows Task Summary
Details
tests_extras-windows
Details
tests_framework_other-linux Task Summary
Details
tests_framework_other-linux
Details
tests_framework_other-macos Task Summary
Details
tests_framework_other-macos
Details
tests_framework_other-windows Task Summary
Details
tests_framework_other-windows
Details
tests_widgets-linux Task Summary
Details
tests_widgets-linux
Details
tests_widgets-macos Task Summary
Details
tests_widgets-macos
Details
tests_widgets-windows Task Summary
Details
tests_widgets-windows
Details
tool_coverage-linux
Details
tool_tests-linux Task Summary
Details
tool_tests-linux
Details
tool_tests-macos Task Summary
Details
tool_tests-macos
Details
tool_tests-windows Task Summary
Details
tool_tests-windows
Details
tool_tests_create-linux Task Summary
Details
tool_tests_create-linux
Details
tool_tests_create-macos Task Summary
Details
tool_tests_create-macos
Details
tool_tests_create-windows Task Summary
Details
tool_tests_create-windows
Details
tool_tests_integration-linux Task Summary
Details
tool_tests_integration-linux
Details
tool_tests_integration-macos Task Summary
Details
tool_tests_integration-macos
Details
tool_tests_integration-windows Task Summary
Details
tool_tests_integration-windows
Details
@dkwingsmt dkwingsmt deleted the dkwingsmt:split-mouse-listener branch Aug 1, 2019
dkwingsmt added a commit to dkwingsmt/flutter that referenced this pull request Aug 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.