-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Properly interpret modifiers on GLFW key events #44844
Conversation
a7fe2ad
to
cdaa9fa
Compare
static const int modifierNumericPad = 0x0020; | ||
|
||
int _mergeModifiers({int modifiers, int keyCode, bool isDown}) { |
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.
So my understanding is correct: The flutter keyboard code treats the modifiers as containing the current modifier key info, like if you press left control. But GLFW doesn't include this info, so it would send a modifier without the left control info. Here you are normalizing it by updating the modifier with the current key info?
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, more or less. More accurately, GLFW just sends the value of modifiers as the state before the current event, so it lags. All the other platforms set the state of the modifier including the effect of the current event.
|
||
int modifierChange = 0; | ||
switch (keyCode) { | ||
case 341: // controlLeft |
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.
Should these keycodes have constants that could be used?
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.
Sure, done.
cdaa9fa
to
b08e525
Compare
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
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Description
GLFW key events set modifier flags based on what the modifier state was before the event, unlike every other platform. This modifies the GLFW key support to take that into account.
As a small cleanup, I fixed a documentation macro reference for the modifier flags that was duplicated.
Tests
Breaking Change