]>
Dogcows Code - chaz/tint2/blob - systray/xproperty.c
4 gboolean
xprop_get8(Window window
, Atom atom
, Atom type
, int size
,
5 gulong
*count
, guchar
**value
)
9 unsigned long ret_bytes
;
11 unsigned long nelements
= *count
;
12 unsigned long maxread
= nelements
;
16 /* try get the first element */
17 result
= XGetWindowProperty(display
, window
, atom
, 0l, 1l, False
,
18 AnyPropertyType
, &ret_type
, &ret_size
,
19 &nelements
, &ret_bytes
, value
);
20 if (! (result
== Success
&& ret_type
== type
&&
21 ret_size
== size
&& nelements
> 0)) {
22 if (*value
) XFree(*value
);
26 /* we didn't the whole property's value, more to get */
27 if (! (ret_bytes
== 0 || maxread
<= nelements
)) {
30 /* get the entire property since it is larger than one element long */
33 the number of longs that need to be retreived to get the property's
34 entire value. The last + 1 is the first long that we retrieved above.
36 remain
= (ret_bytes
- 1)/sizeof(long) + 1 + 1;
37 /* dont get more than the max */
38 if (remain
> size
/8 * (signed)maxread
)
39 remain
= size
/8 * (signed)maxread
;
40 result
= XGetWindowProperty(display
, window
, atom
, 0l, remain
,
41 False
, type
, &ret_type
, &ret_size
,
42 &nelements
, &ret_bytes
, value
);
44 If the property has changed type/size, or has grown since our first
45 read of it, then stop here and try again. If it shrank, then this will
48 if (!(result
== Success
&& ret_type
== type
&&
49 ret_size
== size
&& ret_bytes
== 0)) {
50 if (*value
) XFree(*value
);
51 xprop_get8(window
, atom
, type
, size
, count
, value
);
57 return *value
!= NULL
;
60 gboolean
xprop_get32(Window window
, Atom atom
, Atom type
, int size
,
61 gulong
*count
, gulong
**value
)
63 return xprop_get8(window
, atom
, type
, size
, count
, (guchar
**)value
);
This page took 0.035335 seconds and 4 git commands to generate.