Handle FocusIn events generated by clients and update decoration accordingly (Thanks mseed)

This commit is contained in:
Michael Stapelberg
2011-03-20 16:26:36 +01:00
parent 144deaaaf6
commit c130cefa93
5 changed files with 56 additions and 3 deletions

View File

@ -129,6 +129,10 @@ void handle_event(int type, xcb_generic_event_t *event) {
handle_mapping_notify(NULL, conn, (xcb_mapping_notify_event_t*)event);
break;
case XCB_FOCUS_IN:
handle_focus_in(NULL, conn, (xcb_focus_in_event_t*)event);
break;
case XCB_PROPERTY_NOTIFY:
DLOG("Property notify\n");
xcb_property_notify_event_t *e = (xcb_property_notify_event_t*)event;
@ -1023,3 +1027,34 @@ int handle_clientleader_change(void *data, xcb_connection_t *conn, uint8_t state
return 1;
}
/*
* Handles FocusIn events which are generated by clients (i3s focus changes
* dont generate FocusIn events due to a different EventMask) and updates the
* decorations accordingly.
*
*/
int handle_focus_in(void *data, xcb_connection_t *conn, xcb_focus_in_event_t *event) {
DLOG("focus change in, for window 0x%08x\n", event->event);
Con *con;
if ((con = con_by_window_id(event->event)) == NULL || con->window == NULL)
return 1;
DLOG("That is con %p / %s\n", con, con->name);
if (event->detail == XCB_NOTIFY_DETAIL_POINTER) {
DLOG("notify detail is pointer, ignoring this event\n");
return 1;
}
if (focused_id == event->event) {
DLOG("focus matches the currently focused window, not doing anything\n");
return 1;
}
DLOG("focus is different, updating decorations\n");
con_focus(con);
/* We update focused_id because we dont need to set focus again */
focused_id = event->event;
x_push_changes(croot);
return 1;
}