rootston: Cancel existing keyboard grab when changing focus

It's possible that a non-default keyboard grab exists when we are trying
to change focus. For example, say there is an XDG popup when we click on
a different window. This popup's keyboard grab will swallow any
keyboard_notify_enter(), meaning the newly-clicked window won't receive
keyboard input.

So, we cancel any existing grabs in roots_seat_set_focus(). Before this
fix, a window would have been set as active but not receive keyboard
entry.

Fixes #233.

Signed-off-by: Genki Sky <sky@genki.is>
This commit is contained in:
Genki Sky 2018-06-10 21:46:47 -04:00 committed by Drew DeVault
parent 9a1f0e2d5f
commit 28d718c0dd

View file

@ -825,6 +825,11 @@ void roots_seat_set_focus(struct roots_seat *seat, struct roots_view *view) {
view_activate(view, true); view_activate(view, true);
seat->has_focus = true; seat->has_focus = true;
// We want to unconditionally send keyboard input to the view we are
// focusing here, so cancel any existing grabs.
struct wlr_seat_keyboard_grab *curr_grab = seat->seat->keyboard_state.grab;
curr_grab->interface->cancel(curr_grab);
struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat->seat); struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat->seat);
if (keyboard != NULL) { if (keyboard != NULL) {
wlr_seat_keyboard_notify_enter(seat->seat, view->wlr_surface, wlr_seat_keyboard_notify_enter(seat->seat, view->wlr_surface,