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];
12 #define MYMIN(X, Y) (((X) < (Y)) ? (X) : (Y))
15 _ecore_xcb_atoms_init(void)
19 LOGFN(__FILE__, __LINE__, __FUNCTION__);
22 num = (sizeof(atom_items) / sizeof(Atom_Item));
23 num = MYMIN(num, ECORE_X_ATOMS_COUNT);
24 for (i = 0; i < num; i++)
27 xcb_intern_atom_unchecked(_ecore_xcb_conn, 0,
28 strlen(atom_items[i].name), atom_items[i].name);
33 _ecore_xcb_atoms_finalize(void)
37 LOGFN(__FILE__, __LINE__, __FUNCTION__);
40 num = (sizeof(atom_items) / sizeof(Atom_Item));
41 num = MYMIN(num, ECORE_X_ATOMS_COUNT);
42 for (i = 0; i < num; i++)
44 xcb_intern_atom_reply_t *reply = NULL;
46 if (!(reply = xcb_intern_atom_reply(_ecore_xcb_conn, cookies[i], 0)))
48 *(atom_items[i].atom) = reply->atom;
54 * @defgroup Ecore_X_Atom_Group X Atom Functions
55 * @ingroup Ecore_X_Group
57 * Functions that operate on atoms
61 * Retrieves the atom value associated to a name.
64 * @return Associated atom value.
66 * Retrieves the atom value associated to a name. The reply is the
67 * returned value of the function ecore_xcb_intern_atom_reply(). If
68 * @p reply is @c NULL, the NULL atom is returned. Otherwise, the atom
69 * associated to the name is returned.
71 * @ingroup Ecore_X_Atom_Group
74 ecore_x_atom_get(const char *name)
76 xcb_intern_atom_cookie_t cookie;
77 xcb_intern_atom_reply_t *reply;
80 LOGFN(__FILE__, __LINE__, __FUNCTION__);
83 cookie = xcb_intern_atom_unchecked(_ecore_xcb_conn, 0, strlen(name), name);
84 reply = xcb_intern_atom_reply(_ecore_xcb_conn, cookie, NULL);
85 if (!reply) return XCB_ATOM_NONE;
92 * Retrieves the name of the given atom.
95 * @return The name of the atom.
97 * @ingroup Ecore_X_Atom_Group
100 ecore_x_atom_name_get(Ecore_X_Atom atom)
102 xcb_get_atom_name_cookie_t cookie;
103 xcb_get_atom_name_reply_t *reply;
107 LOGFN(__FILE__, __LINE__, __FUNCTION__);
110 cookie = xcb_get_atom_name_unchecked(_ecore_xcb_conn, atom);
111 reply = xcb_get_atom_name_reply(_ecore_xcb_conn, cookie, NULL);
112 if (!reply) return NULL;
113 len = xcb_get_atom_name_name_length(reply);
114 name = (char *)malloc(sizeof(char) * (len + 1));
120 memcpy(name, xcb_get_atom_name_name(reply), len);
128 ecore_x_atoms_get(const char **names,
132 xcb_intern_atom_cookie_t cookies[num];
135 LOGFN(__FILE__, __LINE__, __FUNCTION__);
138 num = MYMIN(num, ECORE_X_ATOMS_COUNT);
139 for (i = 0; i < num; i++)
142 xcb_intern_atom_unchecked(_ecore_xcb_conn, 0,
143 strlen(names[i]), names[i]);
145 for (i = 0; i < num; i++)
147 xcb_intern_atom_reply_t *reply = NULL;
149 if (!(reply = xcb_intern_atom_reply(_ecore_xcb_conn, cookies[i], 0)))
151 atoms[i] = reply->atom;