1 #include "ecore_xcb_private.h"
2 #include "ecore_x_atoms_decl.h"
4 /* NB: Increment if you add new atoms */
5 #define ECORE_X_ATOMS_COUNT 199
7 /* local function prototypes */
10 static xcb_intern_atom_cookie_t cookies[ECORE_X_ATOMS_COUNT];
13 _ecore_xcb_atoms_init(void)
17 LOGFN(__FILE__, __LINE__, __FUNCTION__);
20 num = (sizeof(atom_items) / sizeof(Atom_Item));
21 for (i = 0; i < num; i++)
24 xcb_intern_atom_unchecked(_ecore_xcb_conn, 0,
25 strlen(atom_items[i].name), atom_items[i].name);
30 _ecore_xcb_atoms_finalize(void)
34 LOGFN(__FILE__, __LINE__, __FUNCTION__);
37 num = (sizeof(atom_items) / sizeof(Atom_Item));
38 for (i = 0; i < num; i++)
40 xcb_intern_atom_reply_t *reply = NULL;
42 if (!(reply = xcb_intern_atom_reply(_ecore_xcb_conn, cookies[i], 0)))
44 *(atom_items[i].atom) = reply->atom;
50 * @defgroup Ecore_X_Atom_Group XCB Atom Functions
52 * Functions that operate on atoms
56 * Retrieves the atom value associated to a name.
59 * @return Associated atom value.
61 * Retrieves the atom value associated to a name. The reply is the
62 * returned value of the function ecore_xcb_intern_atom_reply(). If
63 * @p reply is @c NULL, the NULL atom is returned. Otherwise, the atom
64 * associated to the name is returned.
66 * @ingroup Ecore_X_Atom_Group
69 ecore_x_atom_get(const char *name)
71 xcb_intern_atom_cookie_t cookie;
72 xcb_intern_atom_reply_t *reply;
75 LOGFN(__FILE__, __LINE__, __FUNCTION__);
78 cookie = xcb_intern_atom_unchecked(_ecore_xcb_conn, 0, strlen(name), name);
79 reply = xcb_intern_atom_reply(_ecore_xcb_conn, cookie, NULL);
80 if (!reply) return XCB_ATOM_NONE;
87 * Retrieves the name of the given atom.
90 * @return The name of the atom.
92 * @ingroup Ecore_X_Atom_Group
95 ecore_x_atom_name_get(Ecore_X_Atom atom)
97 xcb_get_atom_name_cookie_t cookie;
98 xcb_get_atom_name_reply_t *reply;
102 LOGFN(__FILE__, __LINE__, __FUNCTION__);
105 cookie = xcb_get_atom_name_unchecked(_ecore_xcb_conn, atom);
106 reply = xcb_get_atom_name_reply(_ecore_xcb_conn, cookie, NULL);
107 if (!reply) return NULL;
108 len = xcb_get_atom_name_name_length(reply);
109 name = (char *)malloc(sizeof(char) * (len + 1));
115 memcpy(name, xcb_get_atom_name_name(reply), len);
123 ecore_x_atoms_get(const char **names,
127 xcb_intern_atom_cookie_t cookies[num];
130 LOGFN(__FILE__, __LINE__, __FUNCTION__);
133 for (i = 0; i < num; i++)
136 xcb_intern_atom_unchecked(_ecore_xcb_conn, 0,
137 strlen(names[i]), names[i]);
139 for (i = 0; i < num; i++)
141 xcb_intern_atom_reply_t *reply = NULL;
143 if (!(reply = xcb_intern_atom_reply(_ecore_xcb_conn, cookies[i], 0)))
145 atoms[i] = reply->atom;