Skip to content

Commit

Permalink
introduce function xcb_atom_get (essentially a synchronous xcb_intern…
Browse files Browse the repository at this point in the history
…_atom, use it only on non-performance critical execution paths)

Signed-off-by: Julien Danjou <[email protected]>
  • Loading branch information
Henning Sten authored and jd committed Sep 18, 2008
1 parent 28cd98c commit 85f200a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
13 changes: 13 additions & 0 deletions atom/atoms.gperf.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 10 additions & 0 deletions atom/xcb_atom.h.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 85f200a

Please sign in to comment.