diff options
Diffstat (limited to 'xwayland')
-rw-r--r-- | xwayland/meson.build | 1 | ||||
-rw-r--r-- | xwayland/xwm.c | 47 |
2 files changed, 45 insertions, 3 deletions
diff --git a/xwayland/meson.build b/xwayland/meson.build index 2ccdf4cb..9d7f3f4a 100644 --- a/xwayland/meson.build +++ b/xwayland/meson.build @@ -15,6 +15,7 @@ lib_wlr_xwayland = static_library( xcb_image, xcb_render, xcb_icccm, + xcb_errors, xkbcommon, pixman, ], diff --git a/xwayland/xwm.c b/xwayland/xwm.c index 549a3333..09f30d3d 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -19,6 +19,9 @@ #ifdef WLR_HAS_XCB_ICCCM #include <xcb/xcb_icccm.h> #endif +#ifdef WLR_HAS_XCB_ERRORS + #include <xcb/xcb_errors.h> +#endif const char *atom_map[ATOM_LAST] = { "WL_SURFACE_ID", @@ -955,9 +958,47 @@ static void xwm_handle_focus_in(struct wlr_xwm *xwm, } static void xwm_handle_xcb_error(struct wlr_xwm *xwm, xcb_value_error_t *ev) { - wlr_log(L_ERROR, "xcb error: code %d, sequence %d, value %d, opcode %d:%d", - ev->error_code, ev->sequence, ev->bad_value, - ev->minor_opcode, ev->major_opcode); +#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, "xcb error happened, but could not allocate error context"); + goto log_raw; + } + + const char *major_name; + major_name = xcb_errors_get_name_for_major_code(err_ctx, ev->major_opcode); + if (!major_name) { + wlr_log(L_DEBUG, "xcb error happened, but could not get major name"); + xcb_errors_context_free(err_ctx); + goto log_raw; + } + + const char *minor_name; + minor_name = xcb_errors_get_name_for_minor_code(err_ctx, + ev->major_opcode, ev->minor_opcode); + + const char *error_name, *extension; + error_name = xcb_errors_get_name_for_error(err_ctx, ev->error_code, &extension); + if (!error_name) { + wlr_log(L_DEBUG, "xcb error happened, but could not get error name"); + xcb_errors_context_free(err_ctx); + goto log_raw; + } + + wlr_log(L_ERROR, "xcb error: op %s (%s), code %s (%s), value %"PRIu32, + major_name, minor_name ? minor_name : "no minor", + error_name, extension ? extension : "no extension", + ev->bad_value); + + xcb_errors_context_free(err_ctx); + return; +log_raw: +#endif + wlr_log(L_ERROR, + "xcb error: op %"PRIu8":%"PRIu16", code %"PRIu8", sequence %"PRIu16", value %"PRIu32, + ev->major_opcode, ev->minor_opcode, ev->error_code, + ev->sequence, ev->bad_value); + } /* This is in xcb/xcb_event.h, but pulling xcb-util just for a constant |