Handle FocusIn events generated by clients and update decoration accordingly (Thanks mseed)
This commit is contained in:
@ -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 (i3’s focus changes
|
||||
* don’t 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 don’t need to set focus again */
|
||||
focused_id = event->event;
|
||||
x_push_changes(croot);
|
||||
return 1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user