From 28d718c0ddd8f2ba083be374f3d97e4836f615d9 Mon Sep 17 00:00:00 2001 From: Genki Sky Date: Sun, 10 Jun 2018 21:46:47 -0400 Subject: [PATCH 1/2] 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 --- rootston/seat.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rootston/seat.c b/rootston/seat.c index 91561567..0a1a10ac 100644 --- a/rootston/seat.c +++ b/rootston/seat.c @@ -825,6 +825,11 @@ void roots_seat_set_focus(struct roots_seat *seat, struct roots_view *view) { view_activate(view, 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); if (keyboard != NULL) { wlr_seat_keyboard_notify_enter(seat->seat, view->wlr_surface, From 356e466d5a40f69b66af89cb0767d5bf6410bee4 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Sun, 24 Jun 2018 18:18:30 -0400 Subject: [PATCH 2/2] use seat function to end grab --- rootston/seat.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/rootston/seat.c b/rootston/seat.c index 0a1a10ac..d8910660 100644 --- a/rootston/seat.c +++ b/rootston/seat.c @@ -825,10 +825,8 @@ void roots_seat_set_focus(struct roots_seat *seat, struct roots_view *view) { view_activate(view, 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); + // An existing keyboard grab might try to deny setting focus, so cancel it + wlr_seat_keyboard_end_grab(seat->seat); struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat->seat); if (keyboard != NULL) {