/** * Vertical grid with cols = given number of colons * n - num window * rows - num rows * cols - num cols (works with 2, more who knows?) * ch - available height without top gap * cw - available width without left gap */ void vertgrid(int x, int y, int w, int h, const Desktop *d) { int n = 0, cols = 2, cn = 0, rn = 0, i = -1; for (Client *c = d->head; c; c = c->next) if (!ISFFT(c)) ++n; if (n == 0) return; //else if (n == 5) cols = 2; int rows = (n%cols)? n/cols+1: n/cols, ch = h - USELESSGAP, cw = (w - USELESSGAP)/cols; for (Client *c = d->head; c; c = c->next) { if (ISFFT(c)) continue; else ++i; if (i==n-1 && n%cols) XMoveResizeWindow(dis, c->win, x + cn*cw + USELESSGAP, y + rn*ch/rows + USELESSGAP, cw * cols - 2*BORDER_WIDTH - USELESSGAP, ch/rows - 2*BORDER_WIDTH - USELESSGAP); else XMoveResizeWindow(dis, c->win, x + cn*cw + USELESSGAP, y + rn*ch/rows + USELESSGAP, cw - 2*BORDER_WIDTH - USELESSGAP, ch/rows - 2*BORDER_WIDTH - USELESSGAP); if (++cn >= cols) { cn = 0; rn++; } } }