input/keyboard: don't send key release if we don't have focused surface

"The compositor must not send this event if the wl_keyboard did not
have an active surface immediately before this event. The compositor
must not send this event if state is pressed (resp. released) and the
key was already logically down (resp. was not logically down)
immediately before this event."

From https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/382
master
llyyr 7 months ago committed by Alexander Orzechowski
parent 4e38f93f36
commit dfbcd1fbaa

@ -509,12 +509,13 @@ static void handle_key_event(struct sway_keyboard *keyboard,
} }
if (event->state == WL_KEYBOARD_KEY_STATE_RELEASED) { if (event->state == WL_KEYBOARD_KEY_STATE_RELEASED) {
// If the pressed event was sent to a client, also send the released // If the pressed event was sent to a client and we have a focused
// surface immediately before this event, also send the released
// event. In particular, don't send the released event to the IM grab. // event. In particular, don't send the released event to the IM grab.
bool pressed_sent = update_shortcut_state( bool pressed_sent = update_shortcut_state(
&keyboard->state_pressed_sent, event->keycode, &keyboard->state_pressed_sent, event->keycode,
event->state, keyinfo.keycode, 0); event->state, keyinfo.keycode, 0);
if (pressed_sent) { if (pressed_sent && seat->wlr_seat->keyboard_state.focused_surface) {
wlr_seat_set_keyboard(wlr_seat, keyboard->wlr); wlr_seat_set_keyboard(wlr_seat, keyboard->wlr);
wlr_seat_keyboard_notify_key(wlr_seat, event->time_msec, wlr_seat_keyboard_notify_key(wlr_seat, event->time_msec,
event->keycode, event->state); event->keycode, event->state);

Loading…
Cancel
Save