+static int win_msg(win_t *win, atom_t msg)
+{
+ int n, found = 0;
+ Atom *protos;
+ if (!XGetWMProtocols(win->sys->dpy, win->sys->xid, &protos, &n))
+ return 0;
+
+ while (!found && n--)
+ found = protos[n] == atoms[msg];
+ XFree(protos);
+ if (!found)
+ return 0;
+
+ XSendEvent(win->sys->dpy, win->sys->xid, False, NoEventMask, &(XEvent){
+ .type = ClientMessage,
+ .xclient.window = win->sys->xid,
+ .xclient.message_type = atoms[WM_PROTO],
+ .xclient.format = 32,
+ .xclient.data.l[0] = atoms[msg],
+ .xclient.data.l[1] = CurrentTime,
+ });
+ return 1;
+}
+
+static Atom win_prop(win_t *win, atom_t prop)
+{
+ int format;
+ unsigned long nitems, bytes;
+ unsigned char *buf = NULL;
+ Atom atom, type = XA_ATOM;
+ if (XGetWindowProperty(win->sys->dpy, win->sys->xid, atoms[prop],
+ 0L, sizeof(Atom), False, type, &type, &format, &nitems, &bytes, &buf) || !buf)
+ return 0;
+ atom = *(Atom *)buf;
+ XFree(buf);
+ return atom;
+}
+