Skip to content

Moved the touch events expending to the flutter engine side#28972

Closed
chunhtai wants to merge 6 commits intoflutter:masterfrom
chunhtai:develop
Closed

Moved the touch events expending to the flutter engine side#28972
chunhtai wants to merge 6 commits intoflutter:masterfrom
chunhtai:develop

Conversation

@chunhtai
Copy link
Contributor

@chunhtai chunhtai commented Mar 7, 2019

Description

This decision came up when we try to deal with #20517
We decide the logic that normalize the touch events should reside in flutter/engine instead of flutter/flutter.
Engine should have platform specific code to ensure the clean touch events sent to flutter/flutter.

Related Issues

#20517

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.
  • My PR includes tests for all changed/updated/fixed behaviors (See Test Coverage).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • [x ] 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?

@chunhtai chunhtai requested a review from goderbauer March 7, 2019 01:00
@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: yes and removed cla: no labels Mar 7, 2019
@goderbauer goderbauer added framework flutter/packages/flutter repository. See also f: labels. f: gestures flutter/packages/flutter/gestures repository. labels Mar 7, 2019
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd keep the cases for hover and move completely separate since they don't share too much code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(github doesn't let me comment on the right line, this comment is meant for line 64):

Does it still make sense that this returns an iterable? Looks like it's a 1:1 mapping now?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need _ensureStateForPointer here? Isn't it now guaranteed by the protocol, that the PointerChange.add even will have created the state?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also document the legal sequence of events somewhere. Ideally, we add the diagram describing the legal sequence to https://github.com/flutter/assets-for-api-docs and link it in an appropriate space.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An assert should also trigger if the event we receive from the engine doesn't follow the expected sequence.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The framework here does not keep track of if the pointer is up or down since we don't need to expand the action from for move before down or hover before up. I can include it for assertion purpose, is that something we want to do?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i haven't looked to see if it makes sense here (i'll defer to @goderbauer) but as a general rule we have many places where we have debug-only code (using asserts to make it only visible in debug mode and free in release builds) to verify invariants like this.

@chunhtai chunhtai force-pushed the develop branch 3 times, most recently from 89bf457 to a05959d Compare March 12, 2019 18:09
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// format the given packet of pointer data into a framework
/// Format the given packet of pointer data into a framework

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why the generator needs to be replaced by a list?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the result is 1 to 1 mapping, we prefer to use list

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took that from @goderbauer 's suggestion. Should I change it back?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//Devices must be added before they send scroll events.
// Devices must be added before they send scroll events.

@chunhtai
Copy link
Contributor Author

chunhtai commented Mar 20, 2019

the build failures require new engine roll
@goderbauer ready for review

/// Expand the given packet of pointer data into a sequence of framework
static String _formatErrorMessage(ui.PointerChange change, String msg) => 'Invalid event \'$change\': $msg';


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: extraneous blank line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

}

/// Expand the given packet of pointer data into a sequence of framework
static String _formatErrorMessage(ui.PointerChange change, String msg) => 'Invalid event \'$change\': $msg';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

msg -> message
(we don't use abbreviations)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

/// from physical coordinates to logical pixels. See the discussion at
/// [PointerEvent] for more details on the [PointerEvent] coordinate space.
static Iterable<PointerEvent> expand(Iterable<ui.PointerData> data, double devicePixelRatio) sync* {
static List<PointerEvent> format(List<ui.PointerData> data, double devicePixelRatio) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renaming expand to format is also a breaking change. not sure that one is worth it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a use case where developer will come in and use this function directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@goderbauer
Copy link
Member

Closing for now until the engine side is ready.

@goderbauer goderbauer closed this Apr 17, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

c: API break Backwards-incompatible API changes f: gestures flutter/packages/flutter/gestures repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants