2009-01-31 10:33:39 -08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
2010-08-02 10:47:49 -07:00
|
|
|
#endif /* ifdef HAVE_CONFIG_H */
|
2009-01-31 10:33:39 -08:00
|
|
|
|
2012-11-23 14:38:23 -08:00
|
|
|
#ifdef STDC_HEADERS
|
|
|
|
# include <stdlib.h>
|
|
|
|
# include <stddef.h>
|
|
|
|
#else
|
|
|
|
# ifdef HAVE_STDLIB_H
|
|
|
|
# include <stdlib.h>
|
|
|
|
# endif
|
|
|
|
#endif
|
2009-01-31 10:33:39 -08:00
|
|
|
|
2010-01-03 13:55:50 -08:00
|
|
|
#include <string.h>
|
|
|
|
|
2008-07-09 08:18:55 -07:00
|
|
|
#include "Ecore.h"
|
|
|
|
#include "ecore_x_private.h"
|
|
|
|
#include "Ecore_X.h"
|
|
|
|
#include "Ecore_X_Atoms.h"
|
|
|
|
#include "ecore_x_atoms_decl.h"
|
|
|
|
|
|
|
|
void
|
|
|
|
_ecore_x_atoms_init(void)
|
|
|
|
{
|
|
|
|
Atom *atoms;
|
|
|
|
char **names;
|
|
|
|
int i, num;
|
2008-07-13 13:20:48 -07:00
|
|
|
|
2012-06-01 06:53:18 -07:00
|
|
|
num = sizeof(atom_items) / sizeof(Atom_Item);
|
2008-07-09 08:18:55 -07:00
|
|
|
atoms = alloca(num * sizeof(Atom));
|
|
|
|
names = alloca(num * sizeof(char *));
|
2011-12-03 12:05:48 -08:00
|
|
|
for (i = 0; i < num; i++)
|
2012-06-01 06:53:18 -07:00
|
|
|
names[i] = (char *) atom_items[i].name;
|
2008-07-09 08:18:55 -07:00
|
|
|
XInternAtoms(_ecore_x_disp, names, num, False, atoms);
|
2011-12-03 12:05:48 -08:00
|
|
|
for (i = 0; i < num; i++)
|
2012-06-01 06:53:18 -07:00
|
|
|
*(atom_items[i].atom) = atoms[i];
|
2011-12-03 11:41:12 -08:00
|
|
|
}
|
2009-07-08 21:55:11 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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)
|
|
|
|
{
|
2013-07-17 22:17:40 -07:00
|
|
|
Ecore_X_Atom atom;
|
2010-07-27 22:23:42 -07:00
|
|
|
|
2010-02-25 04:19:02 -08:00
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2016-02-11 08:21:50 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(_ecore_x_disp, 0);
|
2013-07-17 22:17:40 -07:00
|
|
|
atom = XInternAtom(_ecore_x_disp, name, False);
|
|
|
|
if (_ecore_xlib_sync) ecore_x_sync();
|
|
|
|
return atom;
|
2011-12-03 11:41:12 -08:00
|
|
|
}
|
2009-07-08 21:55:11 -07:00
|
|
|
|
|
|
|
EAPI void
|
2011-12-03 12:05:48 -08:00
|
|
|
ecore_x_atoms_get(const char **names,
|
|
|
|
int num,
|
2011-10-20 22:40:59 -07:00
|
|
|
Ecore_X_Atom *atoms)
|
2009-07-08 21:55:11 -07:00
|
|
|
{
|
|
|
|
Atom *atoms_int;
|
|
|
|
int i;
|
|
|
|
|
2010-02-25 04:19:02 -08:00
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2016-02-11 07:09:51 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp);
|
2009-07-08 21:55:11 -07:00
|
|
|
atoms_int = alloca(num * sizeof(Atom));
|
|
|
|
XInternAtoms(_ecore_x_disp, (char **)names, num, False, atoms_int);
|
|
|
|
for (i = 0; i < num; i++)
|
2011-10-20 22:40:59 -07:00
|
|
|
atoms[i] = atoms_int[i];
|
2013-07-17 22:17:40 -07:00
|
|
|
if (_ecore_xlib_sync) ecore_x_sync();
|
2011-12-03 11:41:12 -08:00
|
|
|
}
|
2009-07-08 21:55:11 -07:00
|
|
|
|
|
|
|
EAPI char *
|
|
|
|
ecore_x_atom_name_get(Ecore_X_Atom atom)
|
|
|
|
{
|
|
|
|
char *name;
|
|
|
|
char *xname;
|
|
|
|
|
2010-02-25 04:19:02 -08:00
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2009-07-08 21:55:11 -07:00
|
|
|
|
2016-02-11 07:09:51 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(_ecore_x_disp, NULL);
|
|
|
|
|
2009-07-08 21:55:11 -07:00
|
|
|
xname = XGetAtomName(_ecore_x_disp, atom);
|
2013-07-17 22:17:40 -07:00
|
|
|
if (_ecore_xlib_sync) ecore_x_sync();
|
2010-07-27 22:23:42 -07:00
|
|
|
if (!xname)
|
2011-10-20 22:40:59 -07:00
|
|
|
return NULL;
|
2009-07-08 21:55:11 -07:00
|
|
|
|
|
|
|
name = strdup(xname);
|
|
|
|
XFree(xname);
|
|
|
|
|
|
|
|
return name;
|
2011-12-03 11:41:12 -08:00
|
|
|
}
|
2010-08-02 10:47:49 -07:00
|
|
|
|