xcb error: get unhandled events names

This provides more friendly debug messages for unhandled events,
for example:
[xwayland/xwm.c:1033] unhandled X11 event: FocusOut (10)
[xwayland/xwm.c:1033] unhandled X11 event: MappingNotify (34)
This commit is contained in:
Dominique Martinet 2018-03-03 16:27:26 +01:00
parent 8026cd2a06
commit f481791669
1 changed files with 28 additions and 2 deletions

View File

@ -1002,6 +1002,33 @@ log_raw:
}
static void xwm_handle_unhandled_event(struct wlr_xwm *xwm, xcb_generic_event_t *ev) {
#ifdef WLR_HAS_XCB_ERRORS
xcb_errors_context_t *err_ctx;
if (xcb_errors_context_new(xwm->xcb_conn, &err_ctx)) {
wlr_log(L_DEBUG, "Could not allocate context for unhandled X11 event: %u",
ev->response_type);
return;
}
const char *extension;
const char *event_name =
xcb_errors_get_name_for_xcb_event(err_ctx, ev, &extension);
if (!event_name) {
wlr_log(L_DEBUG, "no name for unhandled event: %u",
ev->response_type);
xcb_errors_context_free(err_ctx);
return;
}
wlr_log(L_DEBUG, "unhandled X11 event: %s (%u)", event_name, ev->response_type);
xcb_errors_context_free(err_ctx);
#else
wlr_log(L_DEBUG, "unhandled X11 event: %u", ev->response_type);
#endif
}
/* This is in xcb/xcb_event.h, but pulling xcb-util just for a constant
* others redefine anyway is meh
*/
@ -1062,8 +1089,7 @@ static int x11_event_handler(int fd, uint32_t mask, void *data) {
xwm_handle_xcb_error(xwm, (xcb_value_error_t *)event);
break;
default:
wlr_log(L_DEBUG, "unhandled X11 event: %d",
event->response_type);
xwm_handle_unhandled_event(xwm, event);
break;
}
free(event);