Skip to content

Commit

Permalink
seat: Set keyboard if seat keyboard is NULL
Browse files Browse the repository at this point in the history
sway sends wl_keyboard.enter on seat focus change and when a keyboard
active on a seat is configured. If all keyboards are removed and a
keyboard is added back without changing the focused client, no new
notify event would be sent despite having keyboard focus. This could
lead to key events without notify, which is a protocol violation.

As a quick fix, when configuring a keyboard on a seat where no keyboard
is currently active, activate the keyboard so that a focused surface
will receive a notify event.

Regressed by: e1b268a
Closes: swaywm#7330
  • Loading branch information
kennylevinsen committed Dec 18, 2022
1 parent fbf9191 commit 64d7737
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sway/input/keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,13 @@ void sway_keyboard_configure(struct sway_keyboard *keyboard) {
}
}

// If the seat has no active keyboard, set this one
struct wlr_seat *seat = keyboard->seat_device->sway_seat->wlr_seat;
struct wlr_keyboard *current_keyboard = seat->keyboard_state.keyboard;
if (current_keyboard == NULL) {
wlr_seat_set_keyboard(seat, keyboard->wlr);
}

wl_list_remove(&keyboard->keyboard_key.link);
wl_signal_add(&keyboard->wlr->events.key, &keyboard->keyboard_key);
keyboard->keyboard_key.notify = handle_keyboard_key;
Expand Down

0 comments on commit 64d7737

Please sign in to comment.