Change grabkeys() to grab in synchronous mode.
{
struct ws_win *cfw = NULL;
xcb_get_input_focus_reply_t *r;
{
struct ws_win *cfw = NULL;
xcb_get_input_focus_reply_t *r;
- xcb_window_t cur_focus = XCB_WINDOW_NONE;
DNPRINTF(SWM_D_FOCUS, "focus_win: window: 0x%x\n", WINID(win));
DNPRINTF(SWM_D_FOCUS, "focus_win: window: 0x%x\n", WINID(win));
return;
if (validate_ws(win->ws))
return;
if (validate_ws(win->ws))
- return; /* XXX this gets hit with thunderbird, needs fixing */
if (validate_win(win)) {
kill_refs(win);
if (validate_win(win)) {
kill_refs(win);
r = xcb_get_input_focus_reply(conn, xcb_get_input_focus(conn), NULL);
if (r) {
r = xcb_get_input_focus_reply(conn, xcb_get_input_focus(conn), NULL);
if (r) {
+ cfw = find_window(r->focus);
- cfw = find_window(cur_focus);
-
- if (cfw == win) {
- if (win->ws->focus == win) {
- DNPRINTF(SWM_D_FOCUS, "focus_win: already focused; "
- "skipping.\n");
- return;
- } else {
- DNPRINTF(SWM_D_FOCUS, "focus_win: already has input "
- "focus.\n");
- }
- } else
- unfocus_win(cfw);
-
- win->ws->focus = win;
+ if (win->ws->focus != win) {
+ unfocus_win(win->ws->focus);
+ win->ws->focus = win;
+ }
/* Tell app it can set focus. */
if (win->take_focus) {
/* Tell app it can set focus. */
if (win->take_focus) {
client_msg(win, a_takefocus);
}
client_msg(win, a_takefocus);
}
- if (win->ws->r != NULL) {
- if (win->java == 0)
- xcb_set_input_focus(conn, XCB_INPUT_FOCUS_PARENT,
- win->id, XCB_CURRENT_TIME);
- xcb_change_window_attributes(conn, win->id,
- XCB_CW_BORDER_PIXEL,
- &win->ws->r->s->c[SWM_S_COLOR_FOCUS].pixel);
- if (win->ws->cur_layout->flags & SWM_L_MAPONFOCUS ||
- win->ws->always_raise)
- map_window_raised(win->id);
+ if (cfw != win) {
+ if (cfw)
+ unfocus_win(cfw);
+
+ if (win->ws->r != NULL) {
+ if (win->java == 0)
+ xcb_set_input_focus(conn,
+ XCB_INPUT_FOCUS_PARENT, win->id,
+ XCB_CURRENT_TIME);
+
+ xcb_change_window_attributes(conn, win->id,
+ XCB_CW_BORDER_PIXEL,
+ &win->ws->r->s->c[SWM_S_COLOR_FOCUS].pixel);
- xcb_change_property(conn, XCB_PROP_MODE_REPLACE, win->s->root,
- ewmh[_NET_ACTIVE_WINDOW].atom, XCB_ATOM_WINDOW, 32, 1,
- &win->id);
+ if (win->ws->cur_layout->flags & SWM_L_MAPONFOCUS ||
+ win->ws->always_raise)
+ map_window_raised(win->id);
+
+ xcb_change_property(conn, XCB_PROP_MODE_REPLACE,
+ win->s->root, ewmh[_NET_ACTIVE_WINDOW].atom,
+ XCB_ATOM_WINDOW, 32, 1, &win->id);
+ }
xcb_grab_key(conn, 1,
screens[k].root,
kp->mod | modifiers[j],
xcb_grab_key(conn, 1,
screens[k].root,
kp->mod | modifiers[j],
- *code, XCB_GRAB_MODE_ASYNC,
+ *code, XCB_GRAB_MODE_SYNC,
XCB_GRAB_MODE_ASYNC);
free(code);
}
XCB_GRAB_MODE_ASYNC);
free(code);
}