From 7e71f46401b14d223a1161ecc704d83d177cbda3 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Wed, 3 Oct 2018 14:38:59 +0200 Subject: [PATCH] Convert XInternAtom to XCB Signed-off-by: Uli Schlachter Signed-off-by: Yuxuan Shui --- src/common.h | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) 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; } /**