4 * Copyright (c) Tuomo Valkonen 1999-2001.
5 * See the included file LICENSE for details.
16 int get_property(Display
*dpy
, Window win
, Atom atom
, Atom type
,
24 status
=XGetWindowProperty(dpy
, win
, atom
, 0L, len
, False
,
25 type
, &real_type
, &format
, &n
, &extra
, p
);
27 if(status
!=Success
|| *p
==NULL
)
42 char *get_string_property(Window win
, Atom a
, int *nret
)
47 n
=get_property(wglobal
.dpy
, win
, a
, XA_STRING
, 100L, (uchar
**)&p
);
52 return (n
<=0 ? NULL
: p
);
56 void set_string_property(Window win
, Atom a
, const char *value
)
59 XDeleteProperty(wglobal
.dpy
, win
, a
);
61 XChangeProperty(wglobal
.dpy
, win
, a
, XA_STRING
,
62 8, PropModeReplace
, (uchar
*)value
, strlen(value
));
70 bool get_integer_property(Window win
, Atom a
, int *vret
)
74 if(get_property(wglobal
.dpy
, win
, a
, XA_INTEGER
, 1L, (uchar
**)&p
)<=0)
85 void set_integer_property(Window win
, Atom a
, int value
)
91 XChangeProperty(wglobal
.dpy
, win
, a
, XA_INTEGER
,
92 32, PropModeReplace
, (uchar
*)data
, 1);
99 bool get_win_state(Window win
, int *state
)
103 if(get_property(wglobal
.dpy
, win
, wglobal
.atom_wm_state
,
104 wglobal
.atom_wm_state
, 2L, (uchar
**)&p
)<=0)
115 void set_win_state(Window win
, int state
)
122 XChangeProperty(wglobal
.dpy
, win
,
123 wglobal
.atom_wm_state
, wglobal
.atom_wm_state
,
124 32, PropModeReplace
, (uchar
*)data
, 2);