diff options
author | Henning Sten <henning.sten@yahoo.com> | 2008-09-17 20:59:23 +0200 |
---|---|---|
committer | Arnaud Fontaine <arnau@debian.org> | 2010-11-14 19:50:37 +0900 |
commit | 1b81ef7e1abffb9a244183d6fbf4a1e6e2cb11e1 (patch) | |
tree | 0b29944d3d96216702db87ef9f781d1164da6d93 | |
parent | 68c0ed4b85a526ff70e5363d6468ee9603f448d1 (diff) |
introduce function xcb_atom_get (essentially a synchronous xcb_intern_atom, use it only on non-performance critical execution paths)
Signed-off-by: Julien Danjou <julien@danjou.info>
-rw-r--r-- | atom/atoms.gperf.m4 | 13 | ||||
-rw-r--r-- | atom/xcb_atom.h.m4 | 10 |
2 files changed, 23 insertions, 0 deletions
diff --git a/atom/atoms.gperf.m4 b/atom/atoms.gperf.m4 index 0b7416b..d26814e 100644 --- a/atom/atoms.gperf.m4 +++ b/atom/atoms.gperf.m4 @@ -42,6 +42,19 @@ define(`DO', ` OFFSET,define(`OFFSET', eval(OFFSET+1+len($1)))')dnl include(atomlist.m4)`'dnl }; +xcb_atom_t xcb_atom_get(xcb_connection_t *connection, const char *atom_name) +{ + if(atom_name == NULL) + return XCB_NONE; + xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(connection, + xcb_intern_atom(connection, 0, strlen(atom_name), atom_name), NULL); + if(!reply) + return XCB_NONE; + xcb_atom_t atom = reply->atom; + free(reply); + return atom; +} + xcb_atom_t xcb_atom_get_predefined(uint16_t name_len, const char *name) { const struct atom_map *value = in_word_set(name, name_len); diff --git a/atom/xcb_atom.h.m4 b/atom/xcb_atom.h.m4 index d4957c5..7eb44cd 100644 --- a/atom/xcb_atom.h.m4 +++ b/atom/xcb_atom.h.m4 @@ -15,6 +15,16 @@ typedef struct { } u; } xcb_atom_fast_cookie_t; +/** + * @brief Get an atom synchronously. + * @param connection The connection to the X server. + * @param atom_name The name of the atom that should be returned. + * @return The requested atom, or XCB_NONE if there is an error. + * + * xcb_atom_get() is essentially a synchronous version of xcb_intern_atom(), + * use it only on non-performance critical execution paths. + */ +xcb_atom_t xcb_atom_get(xcb_connection_t *connection, const char *atom_name); xcb_atom_t xcb_atom_get_predefined(uint16_t name_len, const char *name); xcb_atom_fast_cookie_t xcb_atom_get_fast(xcb_connection_t *c, uint8_t only_if_exists, uint16_t name_len, const char *name); xcb_atom_t xcb_atom_get_fast_reply(xcb_connection_t *c, xcb_atom_fast_cookie_t cookie, xcb_generic_error_t **e); |