diff --git a/awesome.c b/awesome.c index 530e756b..5917a006 100644 --- a/awesome.c +++ b/awesome.c @@ -498,6 +498,7 @@ main(int argc, char **argv) | XCB_EVENT_MASK_PROPERTY_CHANGE | XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE + | XCB_EVENT_MASK_FOCUS_CHANGE }; xcb_change_window_attributes(globalconf.connection, diff --git a/client.c b/client.c index 7fbae028..ec1d5651 100644 --- a/client.c +++ b/client.c @@ -187,11 +187,12 @@ client_unfocus_update(client_t *c) void client_unfocus(client_t *c) { - xcb_window_t root_win = xutil_screen_get(globalconf.connection, c->phys_screen)->root; - globalconf.screens.tab[c->phys_screen].client_focus = NULL; + xcb_window_t root_win = xutil_screen_get(globalconf.connection, c->phys_screen)->root; /* Set focus on root window, so no events leak to the current window. */ window_setfocus(root_win, true); + + client_unfocus_update(c); } /** Ban client and move it out of the viewport. @@ -239,6 +240,15 @@ client_focus_update(client_t *c) return; } + if(globalconf.screen_focus + && globalconf.screen_focus->client_focus) + { + if (globalconf.screen_focus->client_focus != c) + client_unfocus_update(globalconf.screen_focus->client_focus); + else + /* Already focused */ + return; + } /* stop hiding client */ c->ishidden = false; client_setminimized(c, false); @@ -281,8 +291,8 @@ client_focus(client_t *c) if(!client_maybevisible(c, c->screen)) return; - globalconf.screen_focus = &globalconf.screens.tab[c->phys_screen]; - globalconf.screen_focus->client_focus = c; + if (!c->nofocus) + client_focus_update(c); window_setfocus(c->win, !c->nofocus); } diff --git a/event.c b/event.c index 452107b7..7dbabe5a 100644 --- a/event.c +++ b/event.c @@ -506,15 +506,8 @@ event_handle_focusin(void *data __attribute__ ((unused)), /* Events that we are interested in: */ switch(ev->detail) { - /* These are events that jump between windows of a toplevel client. - * - * NotifyVirtual event is handled in case where NotifyAncestor or - * NotifyInferior event is not generated on window that is managed by - * awesome ( client_* returns NULL ) - * - * Can someone explain exactly why they are needed ? + /* These are events that jump between root windows. */ - case XCB_NOTIFY_DETAIL_VIRTUAL: case XCB_NOTIFY_DETAIL_ANCESTOR: case XCB_NOTIFY_DETAIL_INFERIOR: @@ -528,37 +521,9 @@ event_handle_focusin(void *data __attribute__ ((unused)), client_focus_update(c); /* all other events are ignored */ default: - return 0; - } -} - -/** The focus out event handler. - * \param data currently unused. - * \param connection The connection to the X server. - * \param ev The event. - */ -static int -event_handle_focusout(void *data __attribute__ ((unused)), - xcb_connection_t *connection, - xcb_focus_out_event_t *ev) -{ - client_t *c; - - /* Events that we are interested in: */ - switch(ev->detail) - { - /* These are events that jump between clients. - * Virtual events ensure we always get an event on our top-level window. - */ - case XCB_NOTIFY_DETAIL_NONLINEAR_VIRTUAL: - case XCB_NOTIFY_DETAIL_NONLINEAR: - if((c = client_getbytitlebarwin(ev->event)) - || (c = client_getbywin(ev->event))) - client_unfocus_update(c); - /* all other events are ignored */ - default: - return 0; + break; } + return 0; } /** The expose event handler. @@ -851,7 +816,6 @@ void a_xcb_set_event_handlers(void) xcb_event_set_enter_notify_handler(&globalconf.evenths, event_handle_enternotify, NULL); xcb_event_set_leave_notify_handler(&globalconf.evenths, event_handle_leavenotify, NULL); xcb_event_set_focus_in_handler(&globalconf.evenths, event_handle_focusin, NULL); - xcb_event_set_focus_out_handler(&globalconf.evenths, event_handle_focusout, NULL); xcb_event_set_motion_notify_handler(&globalconf.evenths, event_handle_motionnotify, NULL); xcb_event_set_expose_handler(&globalconf.evenths, event_handle_expose, NULL); xcb_event_set_key_press_handler(&globalconf.evenths, event_handle_key, NULL);