-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Add KeyEventDeviceType
to KeyData
#47315
Conversation
a27fe79
to
50ef672
Compare
c5256ea
to
a5384f1
Compare
899ddb4
to
d7db7bf
Compare
adaeb93
to
17395ad
Compare
lib/ui/key.dart
Outdated
/// | ||
/// Not all platforms supply an accurate type. | ||
/// | ||
/// Defaults to [keyboard]. |
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 default value should belong to a variable/field, not a type.
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, good point. I already removed this comment in other places, I just missed this one.
ba2b0d7
to
67cc255
Compare
@gspencergoog Before I pull down the branch and test. Do you happen to know if this change will also help to address flutter/flutter#120351 and similar issues? There is a whole class of issues related to the way certain IME key events vs. batch edits are handled. |
@mossmana No, that has to do with touch keyboards, which don't produce key events. This has to do with events generated by hardware keyboards. |
Interesting, I didn't realize only hardware keyboards sent key events. Based on this comment flutter/flutter#120351 (comment), the Samsung soft keyboard does appear to send key events in some cases. Perhaps, the word key event is being overloaded. |
Yes, some soft keyboards also synthesize hardware key events, sometimes only for specific keys, sometimes for all keys, but it's very dependent upon the soft keyboard and its settings. And the default keyboards don't seem to produce any events (GBoard, iOS keyboard). |
67cc255
to
8bb1eb7
Compare
@@ -27,6 +67,7 @@ class KeyData { | |||
required this.logical, | |||
required this.character, | |||
required this.synthesized, | |||
this.deviceType = KeyEventDeviceType.keyboard, |
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.
In order to pass the smoke test for the framework, this needs to be optional. Should we keep it that way, just to make migration easier? I'm leaning towards "yes", although all the other properties are required.
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.
Yeah I think it's fine. At the end of the day it's PlatformDispatcher
that creates this object, right?
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, usually, although you could write your own test framework or something that used it.
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
…137979) flutter/engine@461d815...b1a5d77 2023-11-07 skia-flutter-autoroll@skia.org Roll Skia from 7e3119240ae4 to 9106e374e08d (1 revision) (flutter/engine#47732) 2023-11-07 skia-flutter-autoroll@skia.org Roll Dart SDK from 82731b940e7f to aded6314af29 (1 revision) (flutter/engine#47731) 2023-11-07 skia-flutter-autoroll@skia.org Roll Fuchsia Mac SDK from HQfFSkurc6-jKM2jh... to wmM4lS2lYcphFSHPV... (flutter/engine#47730) 2023-11-07 skia-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from _vGlgDiKOrtlKrZAP... to NaQb_BU6PSbKXSAoU... (flutter/engine#47728) 2023-11-07 skia-flutter-autoroll@skia.org Roll Skia from bd5f57c9bd1a to 7e3119240ae4 (10 revisions) (flutter/engine#47726) 2023-11-06 gspencergoog@users.noreply.github.com Add `KeyEventDeviceType` to `KeyData` (flutter/engine#47315) 2023-11-06 skia-flutter-autoroll@skia.org Roll Skia from 2b218381e226 to bd5f57c9bd1a (2 revisions) (flutter/engine#47719) 2023-11-06 skia-flutter-autoroll@skia.org Roll Dart SDK from 07d4c9d85a5a to 82731b940e7f (1 revision) (flutter/engine#47717) 2023-11-06 skia-flutter-autoroll@skia.org Roll Skia from 77aeee3b81a5 to 2b218381e226 (1 revision) (flutter/engine#47715) 2023-11-06 30870216+gaaclarke@users.noreply.github.com [Impeller] scales blur coverage to match rendered output (flutter/engine#47621) 2023-11-06 jonahwilliams@google.com [Impeller] Fix EntityPassTarget::Flip with implict MSAA. (flutter/engine#47701) 2023-11-06 skia-flutter-autoroll@skia.org Roll Dart SDK from 9211fc6406bb to 07d4c9d85a5a (1 revision) (flutter/engine#47709) 2023-11-06 jonahwilliams@google.com [Impeller] fix drawVertices dest fast path to apply alpha. (flutter/engine#47695) Also rolling transitive DEPS: fuchsia/sdk/core/linux-amd64 from _vGlgDiKOrtl to NaQb_BU6PSbK fuchsia/sdk/core/mac-amd64 from HQfFSkurc6-j to wmM4lS2lYcph 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 rmistry@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 was introduced in flutter#47315. Internally, this lint breaks the build. See also https://errorprone.info/bugpattern/ImmutableEnumChecker. Fixes: b/309552840
This was introduced in #47315. Internally, this lint breaks the build with the following error: ``` shell/platform/android/io/flutter/embedding/android/KeyData.java:78: Error: DeviceType is an enum, which should be immutable, but field DeviceType.value is not final [ImmutableEnum] private long value; ~~~~~~~~~~~~~~~~~~~ ``` See also https://errorprone.info/bugpattern/ImmutableEnumChecker. Fixes: b/309552840 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
output.timestamp = event.getEventTime(); | ||
output.type = type; | ||
output.logicalKey = logicalKey; | ||
output.physicalKey = physicalKey; | ||
output.character = character; | ||
output.synthesized = false; | ||
output.deviceType = KeyData.DeviceType.kKeyboard; |
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.
From Android triage (specifically flutter/flutter#151308):
Does this line override the above switch statement in all cases?
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.
Yeah, seems like it does. That line should probably be removed.
Description
Before we deprecate the
RawKeyEvent
code, it needs to provide parity in functionality. One thing that is missing is theeventSource
field from theRawKeyEventDataAndroid
class, which provides the device type for the event.See https://developer.android.com/reference/android/view/InputDevice#SOURCE_KEYBOARD for an example.
This PR implements that support, and sets the source to
KeyEventDeviceType.keyboard
for platforms that don't provide this information. The main thing it does is add the enumKeyEventDeviceType
, and a new fieldKeyData.deviceType
.Related Issues
RawKeyEvent
andRawKeyboard
, et al should be deprecated and removed flutter#136419Tests