diff --git a/src/event.c b/src/event.c index 2a9d1b0..89c06ef 100644 --- a/src/event.c +++ b/src/event.c @@ -100,6 +100,9 @@ static inline xcb_window_t attr_pure ev_window(session_t *ps, xcb_generic_event_ } } +#define CASESTRRET(s) \ + case s: return #s; + static inline const char *ev_name(session_t *ps, xcb_generic_event_t *ev) { static char buf[128]; switch (ev->response_type & 0x7f) { @@ -162,6 +165,8 @@ static inline const char *attr_pure ev_focus_detail_name(xcb_focus_in_event_t *e return "Unknown"; } +#undef CASESTRRET + static inline void ev_focus_in(session_t *ps, xcb_focus_in_event_t *ev) { log_debug("{ mode: %s, detail: %s }\n", ev_focus_mode_name(ev), ev_focus_detail_name(ev)); diff --git a/src/utils.h b/src/utils.h index 657c0b2..31bf274 100644 --- a/src/utils.h +++ b/src/utils.h @@ -33,9 +33,6 @@ safe_isnan(double a) { return __builtin_isnan(a); } -#define CASESTRRET(s) \ - case s: return #s - /// Same as assert(false), but make sure we abort _even in release builds_. /// Silence compiler warning caused by release builds making some code paths reachable. #define BUG() \ diff --git a/src/x.c b/src/x.c index 5af873b..3c22414 100644 --- a/src/x.c +++ b/src/x.c @@ -337,36 +337,41 @@ _x_strerror(unsigned long serial, uint8_t major, uint16_t minor, uint8_t error_c int o = 0; const char *name = "Unknown"; +#define CASESTRRET(s) \ + case s: \ + name = #s; \ + break + #define CASESTRRET2(s) \ - case s: name = #s; break + case XCB_##s: name = #s; break // TODO separate error code out from session_t o = error_code - ps->xfixes_error; - switch (o) { CASESTRRET2(XCB_XFIXES_BAD_REGION); } + switch (o) { CASESTRRET2(XFIXES_BAD_REGION); } o = error_code - ps->damage_error; - switch (o) { CASESTRRET2(XCB_DAMAGE_BAD_DAMAGE); } + switch (o) { CASESTRRET2(DAMAGE_BAD_DAMAGE); } o = error_code - ps->render_error; switch (o) { - CASESTRRET2(XCB_RENDER_PICT_FORMAT); - CASESTRRET2(XCB_RENDER_PICTURE); - CASESTRRET2(XCB_RENDER_PICT_OP); - CASESTRRET2(XCB_RENDER_GLYPH_SET); - CASESTRRET2(XCB_RENDER_GLYPH); + CASESTRRET2(RENDER_PICT_FORMAT); + CASESTRRET2(RENDER_PICTURE); + CASESTRRET2(RENDER_PICT_OP); + CASESTRRET2(RENDER_GLYPH_SET); + CASESTRRET2(RENDER_GLYPH); } #ifdef CONFIG_OPENGL if (ps->glx_exists) { o = error_code - ps->glx_error; switch (o) { - CASESTRRET2(GLX_BAD_SCREEN); - CASESTRRET2(GLX_BAD_ATTRIBUTE); - CASESTRRET2(GLX_NO_EXTENSION); - CASESTRRET2(GLX_BAD_VISUAL); - CASESTRRET2(GLX_BAD_CONTEXT); - CASESTRRET2(GLX_BAD_VALUE); - CASESTRRET2(GLX_BAD_ENUM); + CASESTRRET(GLX_BAD_SCREEN); + CASESTRRET(GLX_BAD_ATTRIBUTE); + CASESTRRET(GLX_NO_EXTENSION); + CASESTRRET(GLX_BAD_VISUAL); + CASESTRRET(GLX_BAD_CONTEXT); + CASESTRRET(GLX_BAD_VALUE); + CASESTRRET(GLX_BAD_ENUM); } } #endif @@ -374,32 +379,33 @@ _x_strerror(unsigned long serial, uint8_t major, uint16_t minor, uint8_t error_c if (ps->xsync_exists) { o = error_code - ps->xsync_error; switch (o) { - CASESTRRET2(XSyncBadCounter); - CASESTRRET2(XSyncBadAlarm); - CASESTRRET2(XSyncBadFence); + CASESTRRET(XSyncBadCounter); + CASESTRRET(XSyncBadAlarm); + CASESTRRET(XSyncBadFence); } } switch (error_code) { - CASESTRRET2(BadAccess); - CASESTRRET2(BadAlloc); - CASESTRRET2(BadAtom); - CASESTRRET2(BadColor); - CASESTRRET2(BadCursor); - CASESTRRET2(BadDrawable); - CASESTRRET2(BadFont); - CASESTRRET2(BadGC); - CASESTRRET2(BadIDChoice); - CASESTRRET2(BadImplementation); - CASESTRRET2(BadLength); - CASESTRRET2(BadMatch); - CASESTRRET2(BadName); - CASESTRRET2(BadPixmap); - CASESTRRET2(BadRequest); - CASESTRRET2(BadValue); - CASESTRRET2(BadWindow); + CASESTRRET2(ACCESS); + CASESTRRET2(ALLOC); + CASESTRRET2(ATOM); + CASESTRRET2(COLORMAP); + CASESTRRET2(CURSOR); + CASESTRRET2(DRAWABLE); + CASESTRRET2(FONT); + CASESTRRET2(G_CONTEXT); + CASESTRRET2(ID_CHOICE); + CASESTRRET2(IMPLEMENTATION); + CASESTRRET2(LENGTH); + CASESTRRET2(MATCH); + CASESTRRET2(NAME); + CASESTRRET2(PIXMAP); + CASESTRRET2(REQUEST); + CASESTRRET2(VALUE); + CASESTRRET2(WINDOW); } +#undef CASESTRRET #undef CASESTRRET2 thread_local static char buffer[256];