Convert XInternAtom to XCB
Signed-off-by: Uli Schlachter <psychon@znc.in> Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
2da0ecdf66
commit
7e71f46401
22
src/common.h
22
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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue