* add ecore_x_atom_name_get() API (will be used by ewl)
authorcaro <caro@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 9 Jul 2009 04:55:11 +0000 (04:55 +0000)
committercaro <caro@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 9 Jul 2009 04:55:11 +0000 (04:55 +0000)
 * move atom related functions from ecore_x.c to ecore_x_atom.c

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/ecore@41283 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/ecore_x/Ecore_X.h
src/lib/ecore_x/xcb/ecore_xcb_atom.c
src/lib/ecore_x/xlib/ecore_x.c
src/lib/ecore_x/xlib/ecore_x_atoms.c

index 1500b18..b3a0164 100644 (file)
@@ -1301,7 +1301,10 @@ EAPI void            ecore_x_atom_get_prefetch(const char *name);
 EAPI void            ecore_x_atom_get_fetch(void);
 EAPI Ecore_X_Atom    ecore_x_atom_get(const char *name);
 EAPI void            ecore_x_atoms_get(const char **names, int num, Ecore_X_Atom *atoms);
-       
+EAPI void            ecore_x_get_atom_name_prefetch(Ecore_X_Atom atom);
+EAPI void            ecore_x_get_atom_name_fetch(void);
+EAPI char           *ecore_x_atom_name_get(Ecore_X_Atom atom);
+
 
 
 EAPI void            ecore_x_icccm_init(void);
index ac087e8..fa5bf24 100644 (file)
@@ -421,3 +421,63 @@ ecore_x_atom_get(const char *name __UNUSED__)
 
    return reply->atom;
 }
+
+
+/**
+ * Sends the GetAtomName request.
+ * @param atom Atom to get the name from.
+ * @ingroup Ecore_X_Atom_Group
+ */
+EAPI void
+ecore_x_get_atom_name_prefetch(Ecore_X_Atom atom)
+{
+   xcb_get_atom_name_cookie_t cookie;
+
+   cookie = xcb_get_atom_name_unchecked(_ecore_xcb_conn, atom);
+   _ecore_xcb_cookie_cache(cookie.sequence);
+}
+
+/**
+ * Gets the reply of the GetAtomName request sent by ecore_x_get_atom_name_prefetch().
+ * @ingroup Ecore_X_Atom_Group
+ */
+EAPI void
+ecore_x_get_atom_name_fetch(void)
+{
+   xcb_get_atom_name_cookie_t cookie;
+   xcb_get_atom_name_reply_t *reply;
+
+   cookie.sequence = _ecore_xcb_cookie_get();
+   reply = xcb_get_atom_name_reply(_ecore_xcb_conn, cookie, NULL);
+   _ecore_xcb_reply_cache(reply);
+}
+
+/**
+ * Retrieves the name of the given atom.
+ * @param  atom Unused.
+ * @return      The name of the atom.
+ *
+ * To use this function, you must call before, and in order,
+ * ecore_x_get_atom_name_prefetch(), which sends the GetAtomName request,
+ * then ecore_x_get_atom_name_fetch(), which gets the reply.
+ * @ingroup Ecore_X_Atom_Group
+ */
+EAPI char *
+ecore_x_atom_name_get(Ecore_X_Atom atom)
+{
+   xcb_get_atom_name_reply_t *reply;
+   char                      *name;
+   int                        length;
+
+   reply = _ecore_xcb_reply_get();
+   if (!reply) return NULL;
+
+   length = xcb_get_atom_name_name_length(reply);
+   name = (char *)malloc(sizeof(char) * (length + 1));
+   if (!name) return NULL;
+
+   memcpy(name, xcb_get_atom_name_name(reply), length);
+   name[length] = '\0';
+
+   return name;
+}
index 3b033e3..f9f9b79 100644 (file)
@@ -1022,31 +1022,6 @@ ecore_x_window_client_sniff(Ecore_X_Window win)
    XShapeSelectInput(_ecore_x_disp, win, ShapeNotifyMask);
 }
 
-/**
- * Retrieves the atom value associated with the given name.
- * @param  name The given name.
- * @return Associated atom value.
- */
-EAPI Ecore_X_Atom    
-ecore_x_atom_get(const char *name)
-{
-   if (!_ecore_x_disp) return 0;
-   return XInternAtom(_ecore_x_disp, name, False);
-}
-
-EAPI void
-ecore_x_atoms_get(const char **names, int num, Ecore_X_Atom *atoms)
-{
-   Atom *atoms_int;
-   int i;
-   
-   if (!_ecore_x_disp) return;
-   atoms_int = alloca(num * sizeof(Atom));
-   XInternAtoms(_ecore_x_disp, (char **)names, num, False, atoms_int);
-   for (i = 0; i < num; i++)
-     atoms[i] = atoms_int[i];
-}
-
 
 
 
index e8fda29..a938e4b 100644 (file)
@@ -223,3 +223,45 @@ _ecore_x_atoms_init(void)
    XInternAtoms(_ecore_x_disp, names, num, False, atoms);
    for (i = 0; i < num; i++) *(items[i].atom) = atoms[i];
 }
+
+/**
+ * Retrieves the atom value associated with the given name.
+ * @param  name The given name.
+ * @return Associated atom value.
+ */
+EAPI Ecore_X_Atom
+ecore_x_atom_get(const char *name)
+{
+   if (!_ecore_x_disp) return 0;
+   return XInternAtom(_ecore_x_disp, name, False);
+}
+
+EAPI void
+ecore_x_atoms_get(const char **names, int num, Ecore_X_Atom *atoms)
+{
+   Atom *atoms_int;
+   int i;
+
+   if (!_ecore_x_disp) return;
+   atoms_int = alloca(num * sizeof(Atom));
+   XInternAtoms(_ecore_x_disp, (char **)names, num, False, atoms_int);
+   for (i = 0; i < num; i++)
+     atoms[i] = atoms_int[i];
+}
+
+EAPI char *
+ecore_x_atom_name_get(Ecore_X_Atom atom)
+{
+   char *name;
+   char *xname;
+
+   if (!_ecore_x_disp) return NULL;
+
+   xname = XGetAtomName(_ecore_x_disp, atom);
+   if (!xname) return NULL;
+
+   name = strdup(xname);
+   XFree(xname);
+
+   return name;
+}