RawKeyboard synthesizes key pressing state for modifier #93897
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

This PR changes
RawKeyboardso that, if the current key is being pressed but does not exist in the modifier bit mask, add this key tokeysPressed. This change effectively disables the assertion check immediately after_synchronizeModifiers(but it is still kept there.)This change fixes a case on Linux where a very peculiar sequence of key presses result in an AltRight key down event being sent without the Alt modifier bit, breaking our assumption where the key being pressed must exist in the modifier bit. The approach of this PR adapts the
keysPressedstate to the event.An alternative solution is to pretend this event didn't happen, adapting the event to the
keysPressedstate. I didn't choose this solution because it breaksRawKeyboard's design of one-to-one mapping from the native events to the Flutter events. After all, the modifier bits are used to assist synthesization, not to change event output overall.It's a sad choice to disable this check that helped us for so long.Update: I've limited the check bypassing to Linux AltRight key.This PR fixes one of the two symptoms of #93278.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.