Bugfix: Either use SetInputFocus *or* send WM_TAKE_FOCUS, not both

This fixes problems with the Oracle JRE7, which checks the current focus after
receiving WM_TAKE_FOCUS and just does nothing when the focus is on one of its
windows. Hopefully it doesn’t introduce any regressions :).
This commit is contained in:
Michael Stapelberg 2012-01-17 23:33:33 +00:00
parent af73d3bffe
commit 21a2971b24
1 changed files with 18 additions and 15 deletions

11
src/x.c
View File

@ -848,6 +848,12 @@ void x_push_changes(Con *con) {
DLOG("Not updating focus (to %p / %s), focused window is not mapped.\n", focused, focused->name); DLOG("Not updating focus (to %p / %s), focused window is not mapped.\n", focused, focused->name);
/* Invalidate focused_id to correctly focus new windows with the same ID */ /* Invalidate focused_id to correctly focus new windows with the same ID */
focused_id = XCB_NONE; focused_id = XCB_NONE;
} else {
if (focused->window != NULL &&
focused->window->needs_take_focus) {
DLOG("Updating focus by sending WM_TAKE_FOCUS to window 0x%08x only (focused: %p / %s)\n",
to_focus, focused, focused->name);
send_take_focus(to_focus);
} else { } else {
DLOG("Updating focus (focused: %p / %s)\n", focused, focused->name); DLOG("Updating focus (focused: %p / %s)\n", focused, focused->name);
/* We remove XCB_EVENT_MASK_FOCUS_CHANGE from the event mask to get /* We remove XCB_EVENT_MASK_FOCUS_CHANGE from the event mask to get
@ -863,12 +869,9 @@ void x_push_changes(Con *con) {
xcb_change_window_attributes(conn, focused->window->id, XCB_CW_EVENT_MASK, values); xcb_change_window_attributes(conn, focused->window->id, XCB_CW_EVENT_MASK, values);
} }
if (focused->window != NULL && ewmh_update_active_window(to_focus);
focused->window->needs_take_focus) {
send_take_focus(to_focus);
} }
ewmh_update_active_window(to_focus);
focused_id = to_focus; focused_id = to_focus;
} }
} }