Use the EWMH support window rather than the root window as an input focus fallback.

If no other window is available on the active workspace, we now select the EWMH support window (used to indicate that an EWMH-compliant window manager is preent) as the focus window rather than the root window. The NET_WM_ACTIVE window will still be set to XCB_WINDOW_NONE to pretend that no window is actually focused.
This fixes the issue that when using the root window, a fallback mechanism in X11 takes effect which routes keyboard input to the window under the cursor, independent of whether that window has the input focus. Using the EWMH window instead, we can avoid this behavior. We cannot simply set it to XCB_WINDOW_NONE as this would discard all keyboard events, breaking keybindings.

fixes #1378
This commit is contained in:
Ingo Bürk
2015-09-12 22:34:06 +02:00
parent ef6f2f4365
commit 5dbfb05c85
4 changed files with 76 additions and 11 deletions

10
src/x.c
View File

@ -12,6 +12,8 @@
*/
#include "all.h"
xcb_window_t ewmh_window;
/* Stores the X11 window ID of the currently focused window */
xcb_window_t focused_id = XCB_NONE;
@ -1090,10 +1092,12 @@ void x_push_changes(Con *con) {
}
if (focused_id == XCB_NONE) {
DLOG("Still no window focused, better set focus to the root window\n");
xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, root, XCB_CURRENT_TIME);
/* If we still have no window to focus, we focus the EWMH window instead. We use this rather than the
* root window in order to avoid an X11 fallback mechanism causing a ghosting effect (see #1378). */
DLOG("Still no window focused, better set focus to the EWMH support window (%d)\n", ewmh_window);
xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, ewmh_window, XCB_CURRENT_TIME);
ewmh_update_active_window(XCB_WINDOW_NONE);
focused_id = root;
focused_id = ewmh_window;
}
xcb_flush(conn);