Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Commit

Permalink
Merge pull request #4538 from psychon/log-focus-out
Browse files Browse the repository at this point in the history
Log FocusOut events
  • Loading branch information
orestisfl committed Sep 25, 2021
2 parents 535da94 + 16b0967 commit eada44b
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions src/handlers.c
Expand Up @@ -1058,6 +1058,76 @@ static void handle_focus_in(xcb_focus_in_event_t *event) {
tree_render();
}

/*
* Log FocusOut events.
*
*/
static void handle_focus_out(xcb_focus_in_event_t *event) {
Con *con = con_by_window_id(event->event);
const char *window_name, *mode, *detail;

if (con != NULL) {
window_name = con->name;
if (window_name == NULL) {
window_name = "<unnamed con>";
}
} else if (event->event == root) {
window_name = "<the root window>";
} else {
window_name = "<unknown window>";
}

switch (event->mode) {
case XCB_NOTIFY_MODE_NORMAL:
mode = "Normal";
break;
case XCB_NOTIFY_MODE_GRAB:
mode = "Grab";
break;
case XCB_NOTIFY_MODE_UNGRAB:
mode = "Ungrab";
break;
case XCB_NOTIFY_MODE_WHILE_GRABBED:
mode = "WhileGrabbed";
break;
default:
mode = "<unknown>";
break;
}

switch (event->detail) {
case XCB_NOTIFY_DETAIL_ANCESTOR:
detail = "Ancestor";
break;
case XCB_NOTIFY_DETAIL_VIRTUAL:
detail = "Virtual";
break;
case XCB_NOTIFY_DETAIL_INFERIOR:
detail = "Inferior";
break;
case XCB_NOTIFY_DETAIL_NONLINEAR:
detail = "Nonlinear";
break;
case XCB_NOTIFY_DETAIL_NONLINEAR_VIRTUAL:
detail = "NonlinearVirtual";
break;
case XCB_NOTIFY_DETAIL_POINTER:
detail = "Pointer";
break;
case XCB_NOTIFY_DETAIL_POINTER_ROOT:
detail = "PointerRoot";
break;
case XCB_NOTIFY_DETAIL_NONE:
detail = "NONE";
break;
default:
detail = "unknown";
break;
}

DLOG("focus change out: window 0x%08x (con %p, %s) lost focus with detail=%s, mode=%s\n", event->event, con, window_name, detail, mode);
}

/*
* Handles ConfigureNotify events for the root window, which are generated when
* the monitor configuration changed.
Expand Down Expand Up @@ -1434,6 +1504,10 @@ void handle_event(int type, xcb_generic_event_t *event) {
handle_focus_in((xcb_focus_in_event_t *)event);
break;

case XCB_FOCUS_OUT:
handle_focus_out((xcb_focus_out_event_t *)event);
break;

case XCB_PROPERTY_NOTIFY: {
xcb_property_notify_event_t *e = (xcb_property_notify_event_t *)event;
last_timestamp = e->time;
Expand Down

0 comments on commit eada44b

Please sign in to comment.