client_focus_refresh: Always set input focus
Lua code can give the input focus to unfocusable clients. That means they have nofocus set and they don't implement WM_TAKE_FOCUS. Previously, the previously focused client continued getting input events in that event. Now the last client is properly unfocused. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
819daca18c
commit
ba64f3c3cd
|
@ -319,6 +319,7 @@ void
|
||||||
client_focus_refresh(void)
|
client_focus_refresh(void)
|
||||||
{
|
{
|
||||||
client_t *c = globalconf.focus.client;
|
client_t *c = globalconf.focus.client;
|
||||||
|
xcb_window_t win = globalconf.screen->root;
|
||||||
|
|
||||||
if(!globalconf.focus.need_update)
|
if(!globalconf.focus.need_update)
|
||||||
return;
|
return;
|
||||||
|
@ -330,16 +331,24 @@ client_focus_refresh(void)
|
||||||
client_unban(c);
|
client_unban(c);
|
||||||
/* Sets focus on window - using xcb_set_input_focus or WM_TAKE_FOCUS */
|
/* Sets focus on window - using xcb_set_input_focus or WM_TAKE_FOCUS */
|
||||||
if(!c->nofocus)
|
if(!c->nofocus)
|
||||||
xcb_set_input_focus(globalconf.connection, XCB_INPUT_FOCUS_PARENT,
|
win = c->window;
|
||||||
c->window, globalconf.timestamp);
|
else
|
||||||
|
/* Focus the root window to make sure the previously focused client
|
||||||
|
* doesn't get any input in case WM_TAKE_FOCUS gets ignored.
|
||||||
|
*/
|
||||||
|
win = globalconf.screen->root;
|
||||||
|
|
||||||
if(client_hasproto(c, WM_TAKE_FOCUS))
|
if(client_hasproto(c, WM_TAKE_FOCUS))
|
||||||
xwindow_takefocus(c->window);
|
xwindow_takefocus(c->window);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
/* Nothing has the focus, set the focus to the root window */
|
/* If nothing has the focused or the currently focused client doesn't want
|
||||||
xcb_set_input_focus(globalconf.connection, XCB_INPUT_FOCUS_PARENT,
|
* us to focus it, this sets the focus to the root window. This makes sure
|
||||||
globalconf.screen->root, globalconf.timestamp);
|
* the previously focused client actually gets unfocused. Alternatively, the
|
||||||
|
* new client gets the input focus.
|
||||||
|
*/
|
||||||
|
xcb_set_input_focus(globalconf.connection, XCB_INPUT_FOCUS_PARENT,
|
||||||
|
win, globalconf.timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue