-
Notifications
You must be signed in to change notification settings - Fork 6k
[Win32, Keyboard] Process VK_PACKET; Unprintable keys block text #31379
Conversation
Fix embedder test Implement and finish tests
gspencergoog
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.
|
|
||
| // Set this flag to enforce prev_state to be 0. | ||
| // | ||
| // This occurs in rare cases when the message is synthesized. |
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.
Can you maybe describe at least one of the 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.
Yes, it's actually used here and is found during actual device test. It's understandable: The F key never had a key down message, and only got a key up message. It seems that the 3rd party IME blocked its key down message and turned it into the series of backspace and char messages. So the OS probably regularized its state by saying, that although it is a key up message, the key was up somehow.
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.
Sorry, I should have been more specific: I meant describe it in the comment in the code... It's OK, though.

This PR fixes issues that have been impacting the Vietnamese IME, UniKeyNT Telex Mode, the windows part of flutter/flutter#82673.
This IME adds or removes diacritics of the entire word when the last letter of the word is typed by forging Backspace keys and new characters. For example,
To get
ào, you typeaof. The detailed messages are:The first change of this PR is to process the
VK_PACKETsession, which is easy because we can just ignore theVK_PACKETmessages and take the body char messages as standalone char messages.The second change, which is way harder, is to fix a racing condition. Both the engine and the framework maintains a state of the text input field currently being edited. Sometimes the framework sends an updated state to the engine, sometimes the other way around. More specifically,
However, since all the messages triggered by the KeyF press are so tightly queued, that the first text state update above will usually, but not always, arrive after the second text state update is done locally. The symptom is that after pressing
f, the resulting text can be eitherào,ao,o, or some other random values.The best way to fix it might be to make
EditableTextwait for the text state update to finish (https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/widgets/editable_text.dart#L2171). However this might be too big of a change.The fix proposed in this PR is to make unprintable chars (such as Backspace) take up a placeholder char in the char queue, and remove this char only when the corresponding keydown message has arrived. Since the platform messenger maintains message order, and that
TextInput._instance._setEditingState(value)synchronously pushes an message to the messenger, it's guaranteed that the text state update arrives at the engine before the response of the key down event. However, this fix does not prevent the case if a key without any characters would like to change the text state.Pre-launch Checklist
writing and running engine tests.
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.