mirror of
https://github.com/yshui/picom.git
synced 2024-11-11 13:51:02 -05:00
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
1 changed files with 20 additions and 2 deletions
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 a new issue