keyboard: fix pressed sent test on released events

This commit is contained in:
xdavidwu 2021-03-12 17:40:38 +08:00
parent e397ebc06f
commit 4d8d3144fc
No known key found for this signature in database
GPG key ID: EF1E781EE6BE877E

View file

@ -503,11 +503,10 @@ static void handle_key_event(struct sway_keyboard *keyboard,
keyinfo.raw_keysyms_len);
}
bool pressed_sent = false;
if (event->state == WL_KEYBOARD_KEY_STATE_RELEASED) {
// If the pressed event was sent to a client, also send the released
// event. In particular, don't send the released event to the IM grab.
pressed_sent = update_shortcut_state(
bool pressed_sent = update_shortcut_state(
&keyboard->state_pressed_sent, event->keycode,
event->state, keyinfo.keycode, 0);
if (pressed_sent) {
@ -536,7 +535,9 @@ static void handle_key_event(struct sway_keyboard *keyboard,
}
}
if (!handled && !pressed_sent) {
if (!handled && event->state != WL_KEYBOARD_KEY_STATE_RELEASED) {
// If a released event failed pressed sent test, and not in sent to
// keyboard grab, it is still not handled. Don't handle released here.
update_shortcut_state(
&keyboard->state_pressed_sent, event->keycode, event->state,
keyinfo.keycode, 0);