Fix modifier keys getting lost due to global system shortcuts #2429
+9
−0
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.
In normal situations modifier key release triggers flagsChanged with the corresponding keyCode for that modifier key. If the user does a global system shortcut such as screenshoting with cmd+ctrl+shift+4 then we will see the keyDown for the cmd+ctrl+shift but no keyUp or flagsChanged after the screenshot is complete. This will leave window->keys in the wrong state: the modifier keys will be stuck in GLFW_PRESS until they are individually pressed and released again or window focus changes.
When the screenshot chord is finished we do get a flagsChanged event but with the keyCode for "a" (which is weird) but the modifiers are valid so we simply just emit each of their states and let _glfwInputKey handle de-duplicating the event if needed.
Fixes #1011