From: Michael Stapelberg Date: Wed, 7 Oct 2009 18:26:13 +0000 (+0200) Subject: Bugfix: Correctly restore the focus to the root screen after unmapping the last clien... X-Git-Tag: 3.d-bf1~34 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a22550392d1a59b669548df51e0d536517aa17ec;p=i3%2Fi3 Bugfix: Correctly restore the focus to the root screen after unmapping the last client (Thanks Rasi) Sometimes, it may happen that the focus is "nowhere" and thus the user is stuck. This was often the case with opera, sometimes with pcmanfm. See ticket #118. --- diff --git a/src/handlers.c b/src/handlers.c index 601d46f0..354d0fa6 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -721,9 +721,19 @@ int handle_unmap_notify_event(void *data, xcb_connection_t *conn, xcb_unmap_noti render_layout(conn); - /* Ensure the focus is set to the next client in the focus stack */ - if (workspace_active && to_focus != NULL) - set_focus(conn, to_focus, true); + /* Ensure the focus is set to the next client in the focus stack or to + * the screen itself (if we do not focus the screen, it can happen that + * the focus is "nowhere" and thus keypress events will not be received + * by i3, thus the user cannot use any hotkeys). */ + if (workspace_active) { + if (to_focus != NULL) + set_focus(conn, to_focus, true); + else { + LOG("Restoring focus to root screen\n"); + xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, root, XCB_CURRENT_TIME); + xcb_flush(conn); + } + } return 1; }