diff options
author | Dominique Martinet <asmadeus@codewreck.org> | 2018-03-03 16:27:26 +0100 |
---|---|---|
committer | Dominique Martinet <asmadeus@codewreck.org> | 2018-03-03 16:27:29 +0100 |
commit | f4817916697c10f9361d0e78aa6d7979db5c850a (patch) | |
tree | fc0aae036058daaa4005e1d1784d216ffb99b3c8 /xwayland | |
parent | 8026cd2a06023e70abf1758093ff15914145ea96 (diff) |
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)
Diffstat (limited to 'xwayland')
-rw-r--r-- | xwayland/xwm.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/xwayland/xwm.c b/xwayland/xwm.c index dad6e63d..ca6786db 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -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); |