diff --git a/src/common.h b/src/common.h index 5afa605..ff85cbc 100644 --- a/src/common.h +++ b/src/common.h @@ -1696,12 +1696,30 @@ cxfree(void *data) { XFree(data); } +static inline void _Noreturn +die(const char *msg) { + puts(msg); + exit(1); +} + /** * Wrapper of XInternAtom() for convenience. */ -static inline Atom +static inline xcb_atom_t get_atom(session_t *ps, const char *atom_name) { - return XInternAtom(ps->dpy, atom_name, False); + xcb_connection_t *c = XGetXCBConnection(ps->dpy); + xcb_intern_atom_reply_t *reply = + xcb_intern_atom_reply(c, + xcb_intern_atom(c, False, strlen(atom_name), atom_name), + NULL); + + xcb_atom_t atom = XCB_NONE; + if (reply) { + atom = reply->atom; + free(reply); + } else + die("Failed to intern atoms, bail out"); + return atom; } /**