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
|
|
|
|
|
|
|
#include <stdlib.h>
|
2009-02-19 14:25:07 -08:00
|
|
|
#include <string.h>
|
2009-01-31 10:33:39 -08:00
|
|
|
|
2003-09-23 01:09:32 -07:00
|
|
|
#include "Ecore.h"
|
|
|
|
#include "ecore_x_private.h"
|
|
|
|
#include "Ecore_X.h"
|
2004-12-04 02:10:29 -08:00
|
|
|
#include "Ecore_X_Atoms.h"
|
2003-09-23 15:33:10 -07:00
|
|
|
#include <inttypes.h>
|
|
|
|
#include <limits.h>
|
2003-09-23 01:09:32 -07:00
|
|
|
|
2011-10-20 22:40:59 -07:00
|
|
|
#define _ATOM_SET_CARD32(win, atom, p_val, cnt) \
|
|
|
|
XChangeProperty(_ecore_x_disp, win, atom, XA_CARDINAL, 32, PropModeReplace, \
|
|
|
|
(unsigned char *)p_val, cnt)
|
2005-06-09 21:18:24 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set CARD32 (array) property
|
|
|
|
*/
|
2006-01-06 12:22:09 -08:00
|
|
|
EAPI void
|
2011-10-20 22:40:59 -07:00
|
|
|
ecore_x_window_prop_card32_set(Ecore_X_Window win,
|
2011-12-03 12:05:48 -08:00
|
|
|
Ecore_X_Atom atom,
|
|
|
|
unsigned int *val,
|
|
|
|
unsigned int num)
|
2005-06-09 21:18:24 -07:00
|
|
|
{
|
2005-09-07 15:16:49 -07:00
|
|
|
#if SIZEOF_INT == SIZEOF_LONG
|
|
|
|
_ATOM_SET_CARD32(win, atom, val, num);
|
2010-08-02 10:47:49 -07:00
|
|
|
#else /* if SIZEOF_INT == SIZEOF_LONG */
|
2010-07-27 22:23:42 -07:00
|
|
|
long *v2;
|
|
|
|
unsigned int i;
|
2005-09-07 16:21:42 -07:00
|
|
|
|
2010-02-25 04:19:02 -08:00
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2005-09-05 20:43:02 -07:00
|
|
|
v2 = malloc(num * sizeof(long));
|
|
|
|
if (!v2)
|
2011-10-20 22:40:59 -07:00
|
|
|
return;
|
2010-07-27 22:23:42 -07:00
|
|
|
|
2005-06-09 21:18:24 -07:00
|
|
|
for (i = 0; i < num; i++)
|
2011-10-20 22:40:59 -07:00
|
|
|
v2[i] = val[i];
|
2005-09-05 20:43:02 -07:00
|
|
|
_ATOM_SET_CARD32(win, atom, v2, num);
|
|
|
|
free(v2);
|
2010-08-02 10:47:49 -07:00
|
|
|
#endif /* if SIZEOF_INT == SIZEOF_LONG */
|
2013-07-17 22:17:40 -07:00
|
|
|
if (_ecore_xlib_sync) ecore_x_sync();
|
2011-12-03 11:41:12 -08:00
|
|
|
}
|
2005-06-09 21:18:24 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Get CARD32 (array) property
|
|
|
|
*
|
|
|
|
* At most len items are returned in val.
|
|
|
|
* If the property was successfully fetched the number of items stored in
|
|
|
|
* val is returned, otherwise -1 is returned.
|
|
|
|
* Note: Return value 0 means that the property exists but has no elements.
|
|
|
|
*/
|
2006-01-06 12:22:09 -08:00
|
|
|
EAPI int
|
2011-10-20 22:40:59 -07:00
|
|
|
ecore_x_window_prop_card32_get(Ecore_X_Window win,
|
2011-12-03 12:05:48 -08:00
|
|
|
Ecore_X_Atom atom,
|
|
|
|
unsigned int *val,
|
|
|
|
unsigned int len)
|
2005-06-09 21:18:24 -07:00
|
|
|
{
|
2010-07-27 22:23:42 -07:00
|
|
|
unsigned char *prop_ret;
|
|
|
|
Atom type_ret;
|
|
|
|
unsigned long bytes_after, num_ret;
|
|
|
|
int format_ret;
|
|
|
|
unsigned int i;
|
|
|
|
int num;
|
2005-06-09 21:18:24 -07:00
|
|
|
|
2010-02-25 04:19:02 -08:00
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2005-06-09 21:18:24 -07:00
|
|
|
prop_ret = NULL;
|
2009-07-18 03:27:51 -07:00
|
|
|
if (XGetWindowProperty(_ecore_x_disp, win, atom, 0, 0x7fffffff, False,
|
2010-07-27 22:23:42 -07:00
|
|
|
XA_CARDINAL, &type_ret, &format_ret, &num_ret,
|
|
|
|
&bytes_after, &prop_ret) != Success)
|
2011-10-20 22:40:59 -07:00
|
|
|
return -1;
|
2009-07-18 03:27:51 -07:00
|
|
|
|
|
|
|
if (type_ret != XA_CARDINAL || format_ret != 32)
|
2011-10-20 22:40:59 -07:00
|
|
|
num = -1;
|
2009-07-18 03:27:51 -07:00
|
|
|
else if (num_ret == 0 || !prop_ret)
|
2011-10-20 22:40:59 -07:00
|
|
|
num = 0;
|
2009-07-18 03:27:51 -07:00
|
|
|
else
|
2005-06-09 21:18:24 -07:00
|
|
|
{
|
2010-07-27 22:23:42 -07:00
|
|
|
if (num_ret < len)
|
2011-10-20 22:40:59 -07:00
|
|
|
len = num_ret;
|
2010-07-27 22:23:42 -07:00
|
|
|
|
|
|
|
for (i = 0; i < len; i++)
|
2011-10-20 22:40:59 -07:00
|
|
|
val[i] = ((unsigned long *)prop_ret)[i];
|
2010-07-27 22:23:42 -07:00
|
|
|
num = len;
|
2005-06-09 21:18:24 -07:00
|
|
|
}
|
2010-07-27 22:23:42 -07:00
|
|
|
|
2013-07-17 22:17:40 -07:00
|
|
|
if (_ecore_xlib_sync) ecore_x_sync();
|
2005-06-09 21:18:24 -07:00
|
|
|
if (prop_ret)
|
2011-10-20 22:40:59 -07:00
|
|
|
XFree(prop_ret);
|
2005-06-09 21:18:24 -07:00
|
|
|
return num;
|
2011-12-03 11:41:12 -08:00
|
|
|
}
|
2004-02-07 03:59:43 -08:00
|
|
|
|
2006-01-05 13:41:30 -08:00
|
|
|
/*
|
|
|
|
* Get CARD32 (array) property of any length
|
|
|
|
*
|
|
|
|
* If the property was successfully fetched the number of items stored in
|
|
|
|
* val is returned, otherwise -1 is returned.
|
|
|
|
* Note: Return value 0 means that the property exists but has no elements.
|
|
|
|
*/
|
2006-01-06 12:22:09 -08:00
|
|
|
EAPI int
|
2011-10-20 22:40:59 -07:00
|
|
|
ecore_x_window_prop_card32_list_get(Ecore_X_Window win,
|
2011-12-03 12:05:48 -08:00
|
|
|
Ecore_X_Atom atom,
|
2010-07-27 22:23:42 -07:00
|
|
|
unsigned int **plst)
|
2006-01-05 13:41:30 -08:00
|
|
|
{
|
2010-07-27 22:23:42 -07:00
|
|
|
unsigned char *prop_ret;
|
|
|
|
Atom type_ret;
|
|
|
|
unsigned long bytes_after, num_ret;
|
|
|
|
int format_ret;
|
|
|
|
unsigned int i, *val;
|
|
|
|
int num;
|
2006-01-05 13:41:30 -08:00
|
|
|
|
2010-02-25 04:19:02 -08:00
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2009-07-18 03:27:51 -07:00
|
|
|
*plst = NULL;
|
2006-01-05 13:41:30 -08:00
|
|
|
prop_ret = NULL;
|
|
|
|
if (XGetWindowProperty(_ecore_x_disp, win, atom, 0, 0x7fffffff, False,
|
2010-07-27 22:23:42 -07:00
|
|
|
XA_CARDINAL, &type_ret, &format_ret, &num_ret,
|
|
|
|
&bytes_after, &prop_ret) != Success)
|
2011-10-20 22:40:59 -07:00
|
|
|
return -1;
|
2006-01-05 13:41:30 -08:00
|
|
|
|
2011-11-11 11:11:35 -08:00
|
|
|
if ((type_ret != XA_CARDINAL) || (format_ret != 32))
|
2011-10-20 22:40:59 -07:00
|
|
|
num = -1;
|
2011-11-11 11:11:35 -08:00
|
|
|
else if ((num_ret == 0) || (!prop_ret))
|
2011-10-20 22:40:59 -07:00
|
|
|
num = 0;
|
2009-07-18 03:27:51 -07:00
|
|
|
else
|
2006-01-05 13:41:30 -08:00
|
|
|
{
|
2010-07-27 22:23:42 -07:00
|
|
|
val = malloc(num_ret * sizeof(unsigned int));
|
2011-12-03 12:05:48 -08:00
|
|
|
if (!val)
|
2011-11-11 11:11:35 -08:00
|
|
|
{
|
|
|
|
if (prop_ret) XFree(prop_ret);
|
|
|
|
return -1;
|
|
|
|
}
|
2010-07-27 22:23:42 -07:00
|
|
|
for (i = 0; i < num_ret; i++)
|
2011-11-11 16:54:22 -08:00
|
|
|
val[i] = ((unsigned long *)prop_ret)[i];
|
2010-07-27 22:23:42 -07:00
|
|
|
num = num_ret;
|
|
|
|
*plst = val;
|
2006-01-05 13:41:30 -08:00
|
|
|
}
|
2010-07-27 22:23:42 -07:00
|
|
|
|
2013-07-17 22:17:40 -07:00
|
|
|
if (_ecore_xlib_sync) ecore_x_sync();
|
2006-01-05 13:41:30 -08:00
|
|
|
if (prop_ret)
|
2011-10-20 22:40:59 -07:00
|
|
|
XFree(prop_ret);
|
2006-01-05 13:41:30 -08:00
|
|
|
return num;
|
2011-12-03 11:41:12 -08:00
|
|
|
}
|
2006-01-05 13:41:30 -08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set X ID (array) property
|
|
|
|
*/
|
2006-01-06 12:22:09 -08:00
|
|
|
EAPI void
|
2011-10-20 22:40:59 -07:00
|
|
|
ecore_x_window_prop_xid_set(Ecore_X_Window win,
|
2011-12-03 12:05:48 -08:00
|
|
|
Ecore_X_Atom atom,
|
|
|
|
Ecore_X_Atom type,
|
|
|
|
Ecore_X_ID *lst,
|
|
|
|
unsigned int num)
|
2006-01-05 13:41:30 -08:00
|
|
|
{
|
|
|
|
#if SIZEOF_INT == SIZEOF_LONG
|
|
|
|
XChangeProperty(_ecore_x_disp, win, atom, type, 32, PropModeReplace,
|
2010-07-27 22:23:42 -07:00
|
|
|
(unsigned char *)lst, num);
|
2010-08-02 10:47:49 -07:00
|
|
|
#else /* if SIZEOF_INT == SIZEOF_LONG */
|
2010-07-27 22:23:42 -07:00
|
|
|
unsigned long *pl;
|
|
|
|
unsigned int i;
|
2006-01-05 13:41:30 -08:00
|
|
|
|
2010-02-25 04:19:02 -08:00
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2013-07-16 03:58:01 -07:00
|
|
|
pl = malloc(num * sizeof(unsigned long));
|
2006-01-05 13:41:30 -08:00
|
|
|
if (!pl)
|
2011-10-20 22:40:59 -07:00
|
|
|
return;
|
2010-07-27 22:23:42 -07:00
|
|
|
|
2006-01-05 13:41:30 -08:00
|
|
|
for (i = 0; i < num; i++)
|
2011-10-20 22:40:59 -07:00
|
|
|
pl[i] = lst[i];
|
2006-01-05 13:41:30 -08:00
|
|
|
XChangeProperty(_ecore_x_disp, win, atom, type, 32, PropModeReplace,
|
2010-07-27 22:23:42 -07:00
|
|
|
(unsigned char *)pl, num);
|
2006-01-05 13:41:30 -08:00
|
|
|
free(pl);
|
2010-08-02 10:47:49 -07:00
|
|
|
#endif /* if SIZEOF_INT == SIZEOF_LONG */
|
2013-07-17 22:17:40 -07:00
|
|
|
if (_ecore_xlib_sync) ecore_x_sync();
|
2011-12-03 11:41:12 -08:00
|
|
|
}
|
2006-01-05 13:41:30 -08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Get X ID (array) property
|
|
|
|
*
|
|
|
|
* At most len items are returned in val.
|
|
|
|
* If the property was successfully fetched the number of items stored in
|
|
|
|
* val is returned, otherwise -1 is returned.
|
|
|
|
* Note: Return value 0 means that the property exists but has no elements.
|
|
|
|
*/
|
2006-01-06 12:22:09 -08:00
|
|
|
EAPI int
|
2011-10-20 22:40:59 -07:00
|
|
|
ecore_x_window_prop_xid_get(Ecore_X_Window win,
|
2011-12-03 12:05:48 -08:00
|
|
|
Ecore_X_Atom atom,
|
|
|
|
Ecore_X_Atom type,
|
|
|
|
Ecore_X_ID *lst,
|
|
|
|
unsigned int len)
|
2006-01-05 13:41:30 -08:00
|
|
|
{
|
2010-07-27 22:23:42 -07:00
|
|
|
unsigned char *prop_ret;
|
|
|
|
Atom type_ret;
|
|
|
|
unsigned long bytes_after, num_ret;
|
|
|
|
int format_ret;
|
|
|
|
int num;
|
|
|
|
unsigned i;
|
2013-07-17 22:17:40 -07:00
|
|
|
Eina_Bool success;
|
2006-01-05 13:41:30 -08:00
|
|
|
|
2010-02-25 04:19:02 -08:00
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2006-01-05 13:41:30 -08:00
|
|
|
prop_ret = NULL;
|
2013-07-17 22:17:40 -07:00
|
|
|
success = (XGetWindowProperty(_ecore_x_disp, win, atom, 0, 0x7fffffff, False,
|
2010-07-27 22:23:42 -07:00
|
|
|
type, &type_ret, &format_ret, &num_ret,
|
2013-07-17 22:17:40 -07:00
|
|
|
&bytes_after, &prop_ret) == Success);
|
|
|
|
if (_ecore_xlib_sync) ecore_x_sync();
|
|
|
|
if (!success) return -1;
|
2006-01-05 13:41:30 -08:00
|
|
|
|
2009-07-18 03:27:51 -07:00
|
|
|
if (type_ret != type || format_ret != 32)
|
2011-10-20 22:40:59 -07:00
|
|
|
num = -1;
|
2009-07-18 03:27:51 -07:00
|
|
|
else if (num_ret == 0 || !prop_ret)
|
2011-10-20 22:40:59 -07:00
|
|
|
num = 0;
|
2009-07-18 03:27:51 -07:00
|
|
|
else
|
2006-01-05 13:41:30 -08:00
|
|
|
{
|
2010-07-27 22:23:42 -07:00
|
|
|
if (num_ret < len)
|
2011-10-20 22:40:59 -07:00
|
|
|
len = num_ret;
|
2010-07-27 22:23:42 -07:00
|
|
|
|
|
|
|
for (i = 0; i < len; i++)
|
2011-10-20 22:40:59 -07:00
|
|
|
lst[i] = ((unsigned long *)prop_ret)[i];
|
2010-07-27 22:23:42 -07:00
|
|
|
num = len;
|
2006-01-05 13:41:30 -08:00
|
|
|
}
|
2010-07-27 22:23:42 -07:00
|
|
|
|
2006-01-05 13:41:30 -08:00
|
|
|
if (prop_ret)
|
2011-10-20 22:40:59 -07:00
|
|
|
XFree(prop_ret);
|
2006-01-05 13:41:30 -08:00
|
|
|
|
|
|
|
return num;
|
2011-12-03 11:41:12 -08:00
|
|
|
}
|
2006-01-05 13:41:30 -08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Get X ID (array) property
|
|
|
|
*
|
|
|
|
* If the property was successfully fetched the number of items stored in
|
|
|
|
* val is returned, otherwise -1 is returned.
|
|
|
|
* The returned array must be freed with free().
|
|
|
|
* Note: Return value 0 means that the property exists but has no elements.
|
|
|
|
*/
|
2006-01-06 12:22:09 -08:00
|
|
|
EAPI int
|
2011-10-20 22:40:59 -07:00
|
|
|
ecore_x_window_prop_xid_list_get(Ecore_X_Window win,
|
2011-12-03 12:05:48 -08:00
|
|
|
Ecore_X_Atom atom,
|
|
|
|
Ecore_X_Atom type,
|
|
|
|
Ecore_X_ID **val)
|
2006-01-05 13:41:30 -08:00
|
|
|
{
|
2010-07-27 22:23:42 -07:00
|
|
|
unsigned char *prop_ret;
|
|
|
|
Atom type_ret;
|
|
|
|
unsigned long bytes_after, num_ret;
|
|
|
|
int format_ret;
|
|
|
|
Ecore_X_Atom *alst;
|
|
|
|
int num;
|
|
|
|
unsigned i;
|
2013-07-17 22:17:40 -07:00
|
|
|
Eina_Bool success;
|
2006-01-05 13:41:30 -08:00
|
|
|
|
2010-02-25 04:19:02 -08:00
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2006-01-05 13:41:30 -08:00
|
|
|
*val = NULL;
|
|
|
|
prop_ret = NULL;
|
2013-07-17 22:17:40 -07:00
|
|
|
success = (XGetWindowProperty(_ecore_x_disp, win, atom, 0, 0x7fffffff, False,
|
2010-07-27 22:23:42 -07:00
|
|
|
type, &type_ret, &format_ret, &num_ret,
|
2013-07-17 22:17:40 -07:00
|
|
|
&bytes_after, &prop_ret) == Success);
|
|
|
|
if (_ecore_xlib_sync) ecore_x_sync();
|
|
|
|
if (!success) return -1;
|
2006-01-05 13:41:30 -08:00
|
|
|
|
2009-07-18 03:27:51 -07:00
|
|
|
if (type_ret != type || format_ret != 32)
|
2011-10-20 22:40:59 -07:00
|
|
|
num = -1;
|
2009-07-18 03:27:51 -07:00
|
|
|
else if (num_ret == 0 || !prop_ret)
|
2011-10-20 22:40:59 -07:00
|
|
|
num = 0;
|
2009-07-18 03:27:51 -07:00
|
|
|
else
|
2006-01-05 13:41:30 -08:00
|
|
|
{
|
2010-07-27 22:23:42 -07:00
|
|
|
alst = malloc(num_ret * sizeof(Ecore_X_ID));
|
|
|
|
for (i = 0; i < num_ret; i++)
|
2011-10-20 22:40:59 -07:00
|
|
|
alst[i] = ((unsigned long *)prop_ret)[i];
|
2010-07-27 22:23:42 -07:00
|
|
|
num = num_ret;
|
|
|
|
*val = alst;
|
2006-01-05 13:41:30 -08:00
|
|
|
}
|
2010-07-27 22:23:42 -07:00
|
|
|
|
2006-01-05 13:41:30 -08:00
|
|
|
if (prop_ret)
|
2011-10-20 22:40:59 -07:00
|
|
|
XFree(prop_ret);
|
2006-01-05 13:41:30 -08:00
|
|
|
return num;
|
2011-12-03 11:41:12 -08:00
|
|
|
}
|
2006-01-05 13:41:30 -08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Remove/add/toggle X ID list item.
|
|
|
|
*/
|
2006-01-06 12:22:09 -08:00
|
|
|
EAPI void
|
2011-10-20 22:40:59 -07:00
|
|
|
ecore_x_window_prop_xid_list_change(Ecore_X_Window win,
|
2011-12-03 12:05:48 -08:00
|
|
|
Ecore_X_Atom atom,
|
|
|
|
Ecore_X_Atom type,
|
|
|
|
Ecore_X_ID item,
|
|
|
|
int op)
|
2006-01-05 13:41:30 -08:00
|
|
|
{
|
2015-10-19 11:21:22 -07:00
|
|
|
Ecore_X_ID *lst, *temp;
|
2010-07-27 22:23:42 -07:00
|
|
|
int i, num;
|
2006-01-05 13:41:30 -08:00
|
|
|
|
2010-02-25 04:19:02 -08:00
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2006-01-05 13:41:30 -08:00
|
|
|
num = ecore_x_window_prop_xid_list_get(win, atom, type, &lst);
|
|
|
|
if (num < 0)
|
2010-07-27 22:23:42 -07:00
|
|
|
{
|
|
|
|
return; /* Error - assuming invalid window */
|
|
|
|
}
|
2006-01-05 13:41:30 -08:00
|
|
|
|
|
|
|
/* Is it there? */
|
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
{
|
2010-07-27 22:23:42 -07:00
|
|
|
if (lst[i] == item)
|
2011-10-20 22:40:59 -07:00
|
|
|
break;
|
2006-01-05 13:41:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (i < num)
|
|
|
|
{
|
2010-07-27 22:23:42 -07:00
|
|
|
/* Was in list */
|
2011-12-03 12:05:48 -08:00
|
|
|
if (op == ECORE_X_PROP_LIST_ADD)
|
|
|
|
goto done; /* Remove it */
|
2010-07-27 22:23:42 -07:00
|
|
|
|
2011-12-03 12:05:48 -08:00
|
|
|
num--;
|
|
|
|
for (; i < num; i++)
|
|
|
|
lst[i] = lst[i + 1];
|
2006-01-05 13:41:30 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-07-27 22:23:42 -07:00
|
|
|
/* Was not in list */
|
2011-12-03 12:05:48 -08:00
|
|
|
if (op == ECORE_X_PROP_LIST_REMOVE)
|
|
|
|
goto done; /* Add it */
|
2010-07-27 22:23:42 -07:00
|
|
|
|
2011-12-03 12:05:48 -08:00
|
|
|
num++;
|
2015-10-19 11:21:22 -07:00
|
|
|
|
|
|
|
temp = lst;
|
2011-12-03 12:05:48 -08:00
|
|
|
lst = realloc(lst, num * sizeof(Ecore_X_ID));
|
2015-10-19 11:21:22 -07:00
|
|
|
if (lst)
|
|
|
|
{
|
|
|
|
lst[i] = item;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lst = temp;
|
|
|
|
num--;
|
|
|
|
}
|
2006-01-05 13:41:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
ecore_x_window_prop_xid_set(win, atom, type, lst, num);
|
|
|
|
|
2010-07-27 22:23:42 -07:00
|
|
|
done:
|
2006-01-05 13:41:30 -08:00
|
|
|
if (lst)
|
2011-10-20 22:40:59 -07:00
|
|
|
free(lst);
|
2011-12-03 11:41:12 -08:00
|
|
|
}
|
2006-01-05 13:41:30 -08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set Atom (array) property
|
|
|
|
*/
|
2006-01-06 12:22:09 -08:00
|
|
|
EAPI void
|
2011-10-20 22:40:59 -07:00
|
|
|
ecore_x_window_prop_atom_set(Ecore_X_Window win,
|
2011-12-03 12:05:48 -08:00
|
|
|
Ecore_X_Atom atom,
|
|
|
|
Ecore_X_Atom *lst,
|
|
|
|
unsigned int num)
|
2006-01-05 13:41:30 -08:00
|
|
|
{
|
2010-02-25 04:19:02 -08:00
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2006-01-05 13:41:30 -08:00
|
|
|
ecore_x_window_prop_xid_set(win, atom, XA_ATOM, lst, num);
|
2011-12-03 11:41:12 -08:00
|
|
|
}
|
2006-01-05 13:41:30 -08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Get Atom (array) property
|
|
|
|
*
|
|
|
|
* At most len items are returned in val.
|
|
|
|
* If the property was successfully fetched the number of items stored in
|
|
|
|
* val is returned, otherwise -1 is returned.
|
|
|
|
* Note: Return value 0 means that the property exists but has no elements.
|
|
|
|
*/
|
2006-01-06 12:22:09 -08:00
|
|
|
EAPI int
|
2011-10-20 22:40:59 -07:00
|
|
|
ecore_x_window_prop_atom_get(Ecore_X_Window win,
|
2011-12-03 12:05:48 -08:00
|
|
|
Ecore_X_Atom atom,
|
|
|
|
Ecore_X_Atom *lst,
|
|
|
|
unsigned int len)
|
2006-01-05 13:41:30 -08:00
|
|
|
{
|
2013-07-17 22:17:40 -07:00
|
|
|
int ret;
|
2010-02-25 04:19:02 -08:00
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2013-07-17 22:17:40 -07:00
|
|
|
ret = ecore_x_window_prop_xid_get(win, atom, XA_ATOM, lst, len);
|
|
|
|
return ret;
|
2011-12-03 11:41:12 -08:00
|
|
|
}
|
2006-01-05 13:41:30 -08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Get Atom (array) property
|
|
|
|
*
|
|
|
|
* If the property was successfully fetched the number of items stored in
|
|
|
|
* val is returned, otherwise -1 is returned.
|
|
|
|
* The returned array must be freed with free().
|
|
|
|
* Note: Return value 0 means that the property exists but has no elements.
|
|
|
|
*/
|
2006-01-06 12:22:09 -08:00
|
|
|
EAPI int
|
2011-10-20 22:40:59 -07:00
|
|
|
ecore_x_window_prop_atom_list_get(Ecore_X_Window win,
|
2011-12-03 12:05:48 -08:00
|
|
|
Ecore_X_Atom atom,
|
2010-07-27 22:23:42 -07:00
|
|
|
Ecore_X_Atom **plst)
|
2006-01-05 13:41:30 -08:00
|
|
|
{
|
2013-07-17 22:17:40 -07:00
|
|
|
int ret;
|
2010-02-25 04:19:02 -08:00
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2013-07-17 22:17:40 -07:00
|
|
|
ret = ecore_x_window_prop_xid_list_get(win, atom, XA_ATOM, plst);
|
|
|
|
return ret;
|
2011-12-03 11:41:12 -08:00
|
|
|
}
|
2006-01-05 13:41:30 -08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Remove/add/toggle atom list item.
|
|
|
|
*/
|
2006-01-06 12:22:09 -08:00
|
|
|
EAPI void
|
2011-10-20 22:40:59 -07:00
|
|
|
ecore_x_window_prop_atom_list_change(Ecore_X_Window win,
|
2011-12-03 12:05:48 -08:00
|
|
|
Ecore_X_Atom atom,
|
|
|
|
Ecore_X_Atom item,
|
|
|
|
int op)
|
2006-01-05 13:41:30 -08:00
|
|
|
{
|
2010-02-25 04:19:02 -08:00
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2006-01-05 13:41:30 -08:00
|
|
|
ecore_x_window_prop_xid_list_change(win, atom, XA_ATOM, item, op);
|
2011-12-03 11:41:12 -08:00
|
|
|
}
|
2006-01-05 13:41:30 -08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set Window (array) property
|
|
|
|
*/
|
2006-01-06 12:22:09 -08:00
|
|
|
EAPI void
|
2011-12-03 12:05:48 -08:00
|
|
|
ecore_x_window_prop_window_set(Ecore_X_Window win,
|
|
|
|
Ecore_X_Atom atom,
|
2011-10-20 22:40:59 -07:00
|
|
|
Ecore_X_Window *lst,
|
2011-12-03 12:05:48 -08:00
|
|
|
unsigned int num)
|
2006-01-05 13:41:30 -08:00
|
|
|
{
|
2010-02-25 04:19:02 -08:00
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2006-01-05 13:41:30 -08:00
|
|
|
ecore_x_window_prop_xid_set(win, atom, XA_WINDOW, lst, num);
|
2011-12-03 11:41:12 -08:00
|
|
|
}
|
2006-01-05 13:41:30 -08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Get Window (array) property
|
|
|
|
*
|
|
|
|
* At most len items are returned in val.
|
|
|
|
* If the property was successfully fetched the number of items stored in
|
|
|
|
* val is returned, otherwise -1 is returned.
|
|
|
|
* Note: Return value 0 means that the property exists but has no elements.
|
|
|
|
*/
|
2006-01-06 12:22:09 -08:00
|
|
|
EAPI int
|
2011-12-03 12:05:48 -08:00
|
|
|
ecore_x_window_prop_window_get(Ecore_X_Window win,
|
|
|
|
Ecore_X_Atom atom,
|
2011-10-20 22:40:59 -07:00
|
|
|
Ecore_X_Window *lst,
|
2011-12-03 12:05:48 -08:00
|
|
|
unsigned int len)
|
2006-01-05 13:41:30 -08:00
|
|
|
{
|
2013-07-17 22:17:40 -07:00
|
|
|
int ret;
|
2010-02-25 04:19:02 -08:00
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2013-07-17 22:17:40 -07:00
|
|
|
ret = ecore_x_window_prop_xid_get(win, atom, XA_WINDOW, lst, len);
|
|
|
|
return ret;
|
2011-12-03 11:41:12 -08:00
|
|
|
}
|
2006-01-05 13:41:30 -08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Get Window (array) property
|
|
|
|
*
|
|
|
|
* If the property was successfully fetched the number of items stored in
|
|
|
|
* val is returned, otherwise -1 is returned.
|
|
|
|
* The returned array must be freed with free().
|
|
|
|
* Note: Return value 0 means that the property exists but has no elements.
|
|
|
|
*/
|
2006-01-06 12:22:09 -08:00
|
|
|
EAPI int
|
2011-12-03 12:05:48 -08:00
|
|
|
ecore_x_window_prop_window_list_get(Ecore_X_Window win,
|
|
|
|
Ecore_X_Atom atom,
|
2010-07-27 22:23:42 -07:00
|
|
|
Ecore_X_Window **plst)
|
2006-01-05 13:41:30 -08:00
|
|
|
{
|
2013-07-17 22:17:40 -07:00
|
|
|
int ret;
|
2010-02-25 04:19:02 -08:00
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2013-07-17 22:17:40 -07:00
|
|
|
ret = ecore_x_window_prop_xid_list_get(win, atom, XA_WINDOW, plst);
|
|
|
|
return ret;
|
2011-12-03 11:41:12 -08:00
|
|
|
}
|
2006-01-05 13:41:30 -08:00
|
|
|
|
2006-01-06 12:22:09 -08:00
|
|
|
EAPI Ecore_X_Atom
|
2004-02-21 12:44:37 -08:00
|
|
|
ecore_x_window_prop_any_type(void)
|
|
|
|
{
|
|
|
|
return AnyPropertyType;
|
2011-12-03 11:41:12 -08:00
|
|
|
}
|
2004-02-21 12:44:37 -08:00
|
|
|
|
2003-09-23 01:09:32 -07:00
|
|
|
/**
|
2012-04-23 13:09:55 -07:00
|
|
|
* @brief Set a property of Ecore_X_Window.
|
|
|
|
* @param win The window for which the property will be set.
|
|
|
|
* @param property The property of the window to be set.
|
|
|
|
* @param type The type of the property that will be set.
|
|
|
|
* @param size The size of the property that will be set.
|
|
|
|
* @param data The data of the property that will be set.
|
|
|
|
* @param number The size of data.
|
2003-09-23 01:09:32 -07:00
|
|
|
*/
|
2006-01-06 12:22:09 -08:00
|
|
|
EAPI void
|
2010-07-27 22:23:42 -07:00
|
|
|
ecore_x_window_prop_property_set(Ecore_X_Window win,
|
2011-12-03 12:05:48 -08:00
|
|
|
Ecore_X_Atom property,
|
|
|
|
Ecore_X_Atom type,
|
|
|
|
int size,
|
|
|
|
void *data,
|
|
|
|
int number)
|
2003-09-23 01:09:32 -07:00
|
|
|
{
|
2010-02-25 04:19:02 -08:00
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2010-07-27 22:23:42 -07:00
|
|
|
if (win == 0)
|
2011-10-20 22:40:59 -07:00
|
|
|
win = DefaultRootWindow(_ecore_x_disp);
|
2010-07-27 22:23:42 -07:00
|
|
|
|
2003-09-23 01:09:32 -07:00
|
|
|
if (size != 32)
|
2011-10-20 22:40:59 -07:00
|
|
|
XChangeProperty(_ecore_x_disp,
|
|
|
|
win,
|
|
|
|
property,
|
|
|
|
type,
|
|
|
|
size,
|
|
|
|
PropModeReplace,
|
|
|
|
(unsigned char *)data,
|
|
|
|
number);
|
2003-09-23 01:09:32 -07:00
|
|
|
else
|
|
|
|
{
|
2010-07-27 22:23:42 -07:00
|
|
|
unsigned long *dat;
|
|
|
|
int i, *ptr;
|
|
|
|
|
|
|
|
dat = malloc(sizeof(unsigned long) * number);
|
|
|
|
if (dat)
|
|
|
|
{
|
2011-12-03 12:05:48 -08:00
|
|
|
for (ptr = (int *)data, i = 0; i < number; i++)
|
|
|
|
dat[i] = ptr[i];
|
2010-07-27 22:23:42 -07:00
|
|
|
XChangeProperty(_ecore_x_disp, win, property, type, size,
|
|
|
|
PropModeReplace, (unsigned char *)dat, number);
|
|
|
|
free(dat);
|
|
|
|
}
|
2003-09-23 01:09:32 -07:00
|
|
|
}
|
2013-07-17 22:17:40 -07:00
|
|
|
if (_ecore_xlib_sync) ecore_x_sync();
|
2011-12-03 11:41:12 -08:00
|
|
|
}
|
2003-09-23 01:09:32 -07:00
|
|
|
|
2003-09-23 15:33:10 -07:00
|
|
|
/**
|
2012-04-23 13:09:55 -07:00
|
|
|
* @brief Get a property of Ecore_X_Window.
|
|
|
|
* @note If there aren't any data to be got the function return NULL.
|
|
|
|
* If the function can't allocate the memory then 0 is returned.
|
|
|
|
* @param win The window for which the property will be got.
|
|
|
|
* @param property The property of the window that will be gotten.
|
|
|
|
* @param type The type of the property that will be gotten.
|
|
|
|
* @param size This parameter isn't in use.
|
|
|
|
* @param data The data of the property that will be gotten.
|
|
|
|
* @param num The size of property.
|
|
|
|
* @return size_ret The size of array that contains the property.
|
2003-09-23 15:33:10 -07:00
|
|
|
*/
|
2006-01-06 12:22:09 -08:00
|
|
|
EAPI int
|
2011-12-03 12:05:48 -08:00
|
|
|
ecore_x_window_prop_property_get(Ecore_X_Window win,
|
|
|
|
Ecore_X_Atom property,
|
|
|
|
Ecore_X_Atom type,
|
2012-11-25 01:55:32 -08:00
|
|
|
int size EINA_UNUSED,
|
2010-07-27 22:23:42 -07:00
|
|
|
unsigned char **data,
|
2011-12-03 12:05:48 -08:00
|
|
|
int *num)
|
2003-09-23 15:33:10 -07:00
|
|
|
{
|
|
|
|
Atom type_ret = 0;
|
|
|
|
int ret, size_ret = 0;
|
|
|
|
unsigned long num_ret = 0, bytes = 0, i;
|
|
|
|
unsigned char *prop_ret = NULL;
|
2004-09-02 11:22:19 -07:00
|
|
|
|
|
|
|
/* make sure these are initialized */
|
2010-07-27 22:23:42 -07:00
|
|
|
if (num)
|
2011-10-20 22:40:59 -07:00
|
|
|
*num = 0;
|
2004-09-02 11:22:19 -07:00
|
|
|
|
|
|
|
if (data)
|
2011-10-20 22:40:59 -07:00
|
|
|
*data = NULL;
|
2004-09-02 11:22:19 -07:00
|
|
|
else /* we can't store the retrieved data, so just return */
|
2011-10-20 22:40:59 -07:00
|
|
|
return 0;
|
2004-09-02 11:22:19 -07:00
|
|
|
|
2010-02-25 04:19:02 -08:00
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2010-07-27 22:23:42 -07:00
|
|
|
if (!win)
|
2011-10-20 22:40:59 -07:00
|
|
|
win = DefaultRootWindow(_ecore_x_disp);
|
2003-09-23 15:33:10 -07:00
|
|
|
|
2004-01-10 16:51:15 -08:00
|
|
|
ret = XGetWindowProperty(_ecore_x_disp, win, property, 0, LONG_MAX,
|
|
|
|
False, type, &type_ret, &size_ret,
|
|
|
|
&num_ret, &bytes, &prop_ret);
|
2013-07-17 22:17:40 -07:00
|
|
|
if (_ecore_xlib_sync) ecore_x_sync();
|
2003-10-13 10:36:09 -07:00
|
|
|
if (ret != Success)
|
2011-10-20 22:40:59 -07:00
|
|
|
return 0;
|
2013-12-09 23:50:18 -08:00
|
|
|
if ((!num_ret) || (size_ret <= 0))
|
2010-07-27 22:23:42 -07:00
|
|
|
{
|
|
|
|
XFree(prop_ret);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(*data = malloc(num_ret * size_ret / 8)))
|
|
|
|
{
|
|
|
|
XFree(prop_ret);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-09-28 22:49:14 -07:00
|
|
|
switch (size_ret) {
|
2005-06-02 13:14:13 -07:00
|
|
|
case 8:
|
2011-10-20 22:40:59 -07:00
|
|
|
for (i = 0; i < num_ret; i++)
|
|
|
|
(*data)[i] = prop_ret[i];
|
|
|
|
break;
|
2010-07-27 22:23:42 -07:00
|
|
|
|
2005-06-02 13:14:13 -07:00
|
|
|
case 16:
|
2011-10-20 22:40:59 -07:00
|
|
|
for (i = 0; i < num_ret; i++)
|
|
|
|
((unsigned short *)*data)[i] = ((unsigned short *)prop_ret)[i];
|
|
|
|
break;
|
2010-07-27 22:23:42 -07:00
|
|
|
|
2005-06-02 13:14:13 -07:00
|
|
|
case 32:
|
2011-10-20 22:40:59 -07:00
|
|
|
for (i = 0; i < num_ret; i++)
|
|
|
|
((unsigned int *)*data)[i] = ((unsigned long *)prop_ret)[i];
|
|
|
|
break;
|
2011-12-03 11:41:12 -08:00
|
|
|
}
|
2003-09-23 15:33:10 -07:00
|
|
|
|
2010-08-02 10:47:49 -07:00
|
|
|
XFree(prop_ret);
|
2010-07-27 22:23:42 -07:00
|
|
|
|
|
|
|
if (num)
|
2011-10-20 22:40:59 -07:00
|
|
|
*num = num_ret;
|
2004-01-10 16:51:15 -08:00
|
|
|
|
2006-09-28 22:49:14 -07:00
|
|
|
return size_ret;
|
2011-12-03 11:41:12 -08:00
|
|
|
}
|
2003-09-23 15:33:10 -07:00
|
|
|
|
2006-01-06 12:22:09 -08:00
|
|
|
EAPI void
|
2011-10-20 22:40:59 -07:00
|
|
|
ecore_x_window_prop_property_del(Ecore_X_Window win,
|
2011-12-03 12:05:48 -08:00
|
|
|
Ecore_X_Atom property)
|
2004-02-04 23:14:56 -08:00
|
|
|
{
|
2010-02-25 04:19:02 -08:00
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2004-02-04 23:14:56 -08:00
|
|
|
XDeleteProperty(_ecore_x_disp, win, property);
|
2013-07-17 22:17:40 -07:00
|
|
|
if (_ecore_xlib_sync) ecore_x_sync();
|
2011-12-03 11:41:12 -08:00
|
|
|
}
|
2004-02-04 23:14:56 -08:00
|
|
|
|
2006-01-06 12:22:09 -08:00
|
|
|
EAPI Ecore_X_Atom *
|
2011-10-20 22:40:59 -07:00
|
|
|
ecore_x_window_prop_list(Ecore_X_Window win,
|
2011-12-03 12:05:48 -08:00
|
|
|
int *num_ret)
|
2003-10-14 12:11:35 -07:00
|
|
|
{
|
2005-06-09 21:18:24 -07:00
|
|
|
Ecore_X_Atom *atoms;
|
|
|
|
Atom *atom_ret;
|
|
|
|
int num = 0, i;
|
2010-07-27 22:23:42 -07:00
|
|
|
|
2010-02-25 04:19:02 -08:00
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2010-07-27 22:23:42 -07:00
|
|
|
if (num_ret)
|
2011-10-20 22:40:59 -07:00
|
|
|
*num_ret = 0;
|
2003-10-14 12:11:35 -07:00
|
|
|
|
2005-06-09 21:18:24 -07:00
|
|
|
atom_ret = XListProperties(_ecore_x_disp, win, &num);
|
2013-07-17 22:17:40 -07:00
|
|
|
if (_ecore_xlib_sync) ecore_x_sync();
|
2010-07-27 22:23:42 -07:00
|
|
|
if (!atom_ret)
|
2011-10-20 22:40:59 -07:00
|
|
|
return NULL;
|
2003-10-14 12:11:35 -07:00
|
|
|
|
2005-06-09 21:18:24 -07:00
|
|
|
atoms = malloc(num * sizeof(Ecore_X_Atom));
|
|
|
|
if (atoms)
|
|
|
|
{
|
2011-12-03 12:05:48 -08:00
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
atoms[i] = atom_ret[i];
|
2010-07-27 22:23:42 -07:00
|
|
|
if (num_ret)
|
2011-10-20 22:40:59 -07:00
|
|
|
*num_ret = num;
|
2005-06-09 21:18:24 -07:00
|
|
|
}
|
2010-07-27 22:23:42 -07:00
|
|
|
|
2005-06-09 21:18:24 -07:00
|
|
|
XFree(atom_ret);
|
|
|
|
return atoms;
|
2011-12-03 11:41:12 -08:00
|
|
|
}
|
2003-10-14 12:11:35 -07:00
|
|
|
|
2003-09-23 01:09:32 -07:00
|
|
|
/**
|
2003-10-11 15:14:22 -07:00
|
|
|
* Set a window string property.
|
2003-09-23 01:09:32 -07:00
|
|
|
* @param win The window
|
2003-10-11 15:14:22 -07:00
|
|
|
* @param type The property
|
|
|
|
* @param str The string
|
2010-07-27 22:23:42 -07:00
|
|
|
*
|
2003-10-11 15:14:22 -07:00
|
|
|
* Set a window string property
|
2003-09-23 01:09:32 -07:00
|
|
|
*/
|
2006-01-06 12:22:09 -08:00
|
|
|
EAPI void
|
2010-07-27 22:23:42 -07:00
|
|
|
ecore_x_window_prop_string_set(Ecore_X_Window win,
|
2011-12-03 12:05:48 -08:00
|
|
|
Ecore_X_Atom type,
|
|
|
|
const char *str)
|
2003-09-23 01:09:32 -07:00
|
|
|
{
|
2010-07-27 22:23:42 -07:00
|
|
|
XTextProperty xtp;
|
2003-10-11 15:14:22 -07:00
|
|
|
|
2010-02-25 04:19:02 -08:00
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2010-07-27 22:23:42 -07:00
|
|
|
if (win == 0)
|
2011-10-20 22:40:59 -07:00
|
|
|
win = DefaultRootWindow(_ecore_x_disp);
|
2010-07-27 22:23:42 -07:00
|
|
|
|
2005-05-16 05:59:26 -07:00
|
|
|
xtp.value = (unsigned char *)str;
|
2003-10-11 15:14:22 -07:00
|
|
|
xtp.format = 8;
|
2004-12-04 02:10:29 -08:00
|
|
|
xtp.encoding = ECORE_X_ATOM_UTF8_STRING;
|
2003-10-11 15:14:22 -07:00
|
|
|
xtp.nitems = strlen(str);
|
|
|
|
XSetTextProperty(_ecore_x_disp, win, &xtp, type);
|
2013-07-17 22:17:40 -07:00
|
|
|
if (_ecore_xlib_sync) ecore_x_sync();
|
2011-12-03 11:41:12 -08:00
|
|
|
}
|
2003-09-23 01:09:32 -07:00
|
|
|
|
|
|
|
/**
|
2003-10-11 15:14:22 -07:00
|
|
|
* Get a window string property.
|
2003-09-23 01:09:32 -07:00
|
|
|
* @param win The window
|
2003-10-11 15:14:22 -07:00
|
|
|
* @param type The property
|
2012-04-05 00:00:42 -07:00
|
|
|
* @return Window string property of a window. String must be free'd when done.
|
2003-09-23 01:09:32 -07:00
|
|
|
*/
|
2006-01-06 12:22:09 -08:00
|
|
|
EAPI char *
|
2011-10-20 22:40:59 -07:00
|
|
|
ecore_x_window_prop_string_get(Ecore_X_Window win,
|
2011-12-03 12:05:48 -08:00
|
|
|
Ecore_X_Atom type)
|
2003-09-23 01:09:32 -07:00
|
|
|
{
|
2010-07-27 22:23:42 -07:00
|
|
|
XTextProperty xtp;
|
|
|
|
char *str = NULL;
|
2003-10-11 15:14:22 -07:00
|
|
|
|
2010-02-25 04:19:02 -08:00
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2010-07-27 22:23:42 -07:00
|
|
|
if (win == 0)
|
2011-10-20 22:40:59 -07:00
|
|
|
win = DefaultRootWindow(_ecore_x_disp);
|
2010-07-27 22:23:42 -07:00
|
|
|
|
2003-10-11 15:14:22 -07:00
|
|
|
if (XGetTextProperty(_ecore_x_disp, win, &xtp, type))
|
2003-09-23 01:09:32 -07:00
|
|
|
{
|
2010-07-27 22:23:42 -07:00
|
|
|
int items;
|
|
|
|
char **list = NULL;
|
|
|
|
Status s;
|
|
|
|
|
2013-07-17 22:17:40 -07:00
|
|
|
if (_ecore_xlib_sync) ecore_x_sync();
|
2010-07-27 22:23:42 -07:00
|
|
|
if (xtp.encoding == ECORE_X_ATOM_UTF8_STRING)
|
2011-10-20 22:40:59 -07:00
|
|
|
str = strdup((char *)xtp.value);
|
2010-07-27 22:23:42 -07:00
|
|
|
else
|
|
|
|
{
|
2005-06-09 21:18:24 -07:00
|
|
|
#ifdef X_HAVE_UTF8_STRING
|
2010-07-27 22:23:42 -07:00
|
|
|
s = Xutf8TextPropertyToTextList(_ecore_x_disp, &xtp,
|
|
|
|
&list, &items);
|
2010-08-02 10:47:49 -07:00
|
|
|
#else /* ifdef X_HAVE_UTF8_STRING */
|
2010-07-27 22:23:42 -07:00
|
|
|
s = XmbTextPropertyToTextList(_ecore_x_disp, &xtp,
|
|
|
|
&list, &items);
|
2010-08-02 10:47:49 -07:00
|
|
|
#endif /* ifdef X_HAVE_UTF8_STRING */
|
2013-07-17 22:17:40 -07:00
|
|
|
if (_ecore_xlib_sync) ecore_x_sync();
|
2010-07-27 22:23:42 -07:00
|
|
|
if ((s == XLocaleNotSupported) ||
|
|
|
|
(s == XNoMemory) || (s == XConverterNotFound))
|
2011-10-20 22:40:59 -07:00
|
|
|
str = strdup((char *)xtp.value);
|
2010-07-27 22:23:42 -07:00
|
|
|
else if ((s >= Success) && (items > 0))
|
2011-10-20 22:40:59 -07:00
|
|
|
str = strdup(list[0]);
|
2010-07-27 22:23:42 -07:00
|
|
|
|
|
|
|
if (list)
|
2011-10-20 22:40:59 -07:00
|
|
|
XFreeStringList(list);
|
2010-07-27 22:23:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
XFree(xtp.value);
|
2003-09-23 01:09:32 -07:00
|
|
|
}
|
2005-06-09 21:18:24 -07:00
|
|
|
return str;
|
2011-12-03 11:41:12 -08:00
|
|
|
}
|
2003-09-23 01:09:32 -07:00
|
|
|
|
2010-09-26 10:49:05 -07:00
|
|
|
EAPI Eina_Bool
|
2011-12-03 12:05:48 -08:00
|
|
|
ecore_x_window_prop_protocol_isset(Ecore_X_Window win,
|
2004-08-22 14:57:07 -07:00
|
|
|
Ecore_X_WM_Protocol protocol)
|
|
|
|
{
|
|
|
|
Atom proto, *protos = NULL;
|
2010-09-26 10:49:05 -07:00
|
|
|
int i, protos_count = 0;
|
|
|
|
Eina_Bool ret = EINA_FALSE;
|
2004-08-22 14:57:07 -07:00
|
|
|
|
2004-08-22 15:04:12 -07:00
|
|
|
/* check for invalid values */
|
2005-03-01 23:06:44 -08:00
|
|
|
if (protocol >= ECORE_X_WM_PROTOCOL_NUM)
|
2011-10-20 22:40:59 -07:00
|
|
|
return EINA_FALSE;
|
2004-08-22 15:04:12 -07:00
|
|
|
|
2010-02-25 04:19:02 -08:00
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2004-08-22 14:57:07 -07:00
|
|
|
proto = _ecore_x_atoms_wm_protocols[protocol];
|
|
|
|
|
2013-07-17 22:17:40 -07:00
|
|
|
ret = XGetWMProtocols(_ecore_x_disp, win, &protos, &protos_count);
|
|
|
|
if (_ecore_xlib_sync) ecore_x_sync();
|
|
|
|
if (!ret)
|
2011-10-20 22:40:59 -07:00
|
|
|
return ret;
|
2004-08-22 14:57:07 -07:00
|
|
|
|
|
|
|
for (i = 0; i < protos_count; i++)
|
2011-10-20 22:40:59 -07:00
|
|
|
if (protos[i] == proto)
|
|
|
|
{
|
|
|
|
ret = EINA_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
2004-08-22 14:57:07 -07:00
|
|
|
|
|
|
|
XFree(protos);
|
|
|
|
return ret;
|
2011-12-03 11:41:12 -08:00
|
|
|
}
|
2004-08-22 14:57:07 -07:00
|
|
|
|
2004-10-18 23:34:21 -07:00
|
|
|
/**
|
2012-04-23 13:09:55 -07:00
|
|
|
* @brief Get a array containing the protocols of @a win
|
|
|
|
* @note If there aren't any properties to be counted or any protocols to get
|
|
|
|
* then the function returns NULL.
|
|
|
|
* @param win The window for which protocol list will be got.
|
|
|
|
* @param num_ret Contains the number of elements of the array to be returned.
|
|
|
|
* @return The array that contains the protocols.
|
2004-10-18 23:34:21 -07:00
|
|
|
*/
|
2006-01-06 12:22:09 -08:00
|
|
|
EAPI Ecore_X_WM_Protocol *
|
2011-10-20 22:40:59 -07:00
|
|
|
ecore_x_window_prop_protocol_list_get(Ecore_X_Window win,
|
2011-12-03 12:05:48 -08:00
|
|
|
int *num_ret)
|
2004-10-18 23:34:21 -07:00
|
|
|
{
|
|
|
|
Atom *protos = NULL;
|
|
|
|
int i, protos_count = 0;
|
|
|
|
Ecore_X_WM_Protocol *prot_ret = NULL;
|
2013-07-17 22:17:40 -07:00
|
|
|
Eina_Bool success;
|
2010-07-27 22:23:42 -07:00
|
|
|
|
2010-02-25 04:19:02 -08:00
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2013-07-17 22:17:40 -07:00
|
|
|
success = XGetWMProtocols(_ecore_x_disp, win, &protos, &protos_count);
|
|
|
|
if (_ecore_xlib_sync) ecore_x_sync();
|
|
|
|
if (!success)
|
2011-10-20 22:40:59 -07:00
|
|
|
return NULL;
|
2010-07-27 22:23:42 -07:00
|
|
|
|
|
|
|
if ((!protos) || (protos_count <= 0))
|
2011-10-20 22:40:59 -07:00
|
|
|
return NULL;
|
2004-10-18 23:34:21 -07:00
|
|
|
|
2005-01-13 05:48:38 -08:00
|
|
|
prot_ret = calloc(1, protos_count * sizeof(Ecore_X_WM_Protocol));
|
2004-10-18 23:34:21 -07:00
|
|
|
if (!prot_ret)
|
|
|
|
{
|
2010-07-27 22:23:42 -07:00
|
|
|
XFree(protos);
|
|
|
|
return NULL;
|
2004-10-18 23:34:21 -07:00
|
|
|
}
|
2010-07-27 22:23:42 -07:00
|
|
|
|
2004-10-18 23:34:21 -07:00
|
|
|
for (i = 0; i < protos_count; i++)
|
|
|
|
{
|
2010-07-27 22:23:42 -07:00
|
|
|
Ecore_X_WM_Protocol j;
|
|
|
|
|
|
|
|
prot_ret[i] = -1;
|
|
|
|
for (j = 0; j < ECORE_X_WM_PROTOCOL_NUM; j++)
|
|
|
|
{
|
|
|
|
if (_ecore_x_atoms_wm_protocols[j] == protos[i])
|
2011-10-20 22:40:59 -07:00
|
|
|
prot_ret[i] = j;
|
2010-07-27 22:23:42 -07:00
|
|
|
}
|
2004-10-18 23:34:21 -07:00
|
|
|
}
|
2010-08-02 10:47:49 -07:00
|
|
|
XFree(protos);
|
2004-10-18 23:34:21 -07:00
|
|
|
*num_ret = protos_count;
|
|
|
|
return prot_ret;
|
2011-12-03 11:41:12 -08:00
|
|
|
}
|
2010-08-02 10:47:49 -07:00
|
|
|
|