+/* Strut functions
+ * Struts are spaces at the edges of the screen that are used by
+ * toolbars and statusbars such as dzen. */
+static int strut_copy(win_t *to, win_t *from, int scale)
+{
+ int left = from->sys->strut.left;
+ int right = from->sys->strut.right;
+ int top = from->sys->strut.top;
+ int bottom = from->sys->strut.bottom;
+ if (left == 0 && right == 0 && top == 0 && bottom == 0)
+ return 0;
+ to->x += scale*(left );
+ to->y += scale*(top );
+ to->w -= scale*(left+right);
+ to->h -= scale*(top+bottom);
+ return 1;
+}
+
+static int strut_add(win_t *root, win_t *win)
+{
+ /* Get X11 strut data */
+ Atom ret_type;
+ int ret_size;
+ unsigned long ret_items, bytes_left;
+ unsigned char *xdata;
+ int status = XGetWindowProperty(win->sys->dpy, win->sys->xid,
+ atoms[net_strut], 0L, 4L, False, XA_CARDINAL,
+ &ret_type, &ret_size, &ret_items, &bytes_left, &xdata);
+ if (status != Success || ret_size != 32 || ret_items != 4)
+ return 0;
+
+ win->sys->strut.left = ((int*)xdata)[0];
+ win->sys->strut.right = ((int*)xdata)[1];
+ win->sys->strut.top = ((int*)xdata)[2];
+ win->sys->strut.bottom = ((int*)xdata)[3];
+ for (list_t *cur = screens; cur; cur = cur->next)
+ strut_copy(cur->data, win, 1);
+ return strut_copy(root, win, 1);
+}
+
+static int strut_del(win_t *root, win_t *win)
+{
+ for (list_t *cur = screens; cur; cur = cur->next)
+ strut_copy(cur->data, win, -1);
+ return strut_copy(root, win, -1);
+}
+