Skip to content
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

Fix modifier keys getting lost due to global system shortcuts #2429

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bear24rw
Copy link

@bear24rw bear24rw commented Nov 7, 2023

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

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.
@elmindreda elmindreda added bug Bug reports and bugfix pull requests macOS input Keyboard, joystick or mouse labels Feb 4, 2024
@elmindreda elmindreda changed the title Cocoa: Fix modifier keys getting lost due to global system shortcuts Fix modifier keys getting lost due to global system shortcuts Feb 4, 2024
@elmindreda elmindreda added this to the 3.5 milestone Feb 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug reports and bugfix pull requests input Keyboard, joystick or mouse macOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Modifier keys remain in pressed state after triggering screen snipping function
2 participants