Dont set input focus and send WM_TAKE_FOCUS

If input focus is set by the window manager, it is not necessary to send
WM_TAKE_FOCUS because it has already taken focus.

http://tronche.com/gui/x/icccm/sec-4.html#s-4.1.7

> The goal is to support window managers that want to assign the input
> focus to a top-level window in such a way that the top-level window
> either can assign it to one of its subwindows or can decline the offer
> of the focus. For example, a clock or a text editor with no currently
> open frames might not want to take focus even though the window
> manager generally believes that clients should take the input focus
> after being deiconified or raised.

Both setting input focus and sending WM_TAKE_FOCUS is effectively
setting focus on the window twice which is certainly against the spirit
of the spec, if not the letter.

fixes #1167
This commit is contained in:
Tony Crisci
2014-04-10 13:28:14 -04:00
committed by Michael Stapelberg
parent 819bc09375
commit 05f0585817
2 changed files with 39 additions and 18 deletions

12
src/x.c
View File

@ -1006,20 +1006,16 @@ void x_push_changes(Con *con) {
/* Invalidate focused_id to correctly focus new windows with the same ID */
focused_id = XCB_NONE;
} else {
bool set_focus = true;
if (focused->window != NULL &&
focused->window->needs_take_focus) {
focused->window->needs_take_focus &&
focused->window->doesnt_accept_focus) {
DLOG("Updating focus by sending WM_TAKE_FOCUS to window 0x%08x (focused: %p / %s)\n",
to_focus, focused, focused->name);
send_take_focus(to_focus, last_timestamp);
set_focus = !focused->window->doesnt_accept_focus;
DLOG("set_focus = %d\n", set_focus);
if (!set_focus && to_focus != last_focused && is_con_attached(focused))
if (to_focus != last_focused && is_con_attached(focused))
ipc_send_window_event("focus", focused);
}
if (set_focus) {
} else {
DLOG("Updating focus (focused: %p / %s) to X11 window 0x%08x\n", focused, focused->name, to_focus);
/* We remove XCB_EVENT_MASK_FOCUS_CHANGE from the event mask to get
* no focus change events for our own focus changes. We only want