+long
+getstate(Window w)
+{
+ int format, status;
+ long result = -1;
+ unsigned char *p = NULL;
+ unsigned long n, extra;
+ Atom real;
+
+ astate = XInternAtom(display, "WM_STATE", False);
+ status = XGetWindowProperty(display, w, astate, 0L, 2L, False, astate,
+ &real, &format, &n, &extra, (unsigned char **)&p);
+ if(status != Success)
+ return (-1);
+ if(n != 0)
+ result = *p;
+ XFree(p);
+ return (result);
+}
+