Another copy of my dotfiles. Because I don't completely trust GitHub.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
923 B

  1. void
  2. grid(Monitor *m)
  3. {
  4. unsigned int i, n;
  5. int cx, cy, cw, ch, cc, cr, chrest, cwrest, cols, rows;
  6. int oh, ov, ih, iv;
  7. Client *c;
  8. getgaps(m, &oh, &ov, &ih, &iv, &n);
  9. /* grid dimensions */
  10. for (rows = 0; rows <= n/2; rows++)
  11. if (rows*rows >= n)
  12. break;
  13. cols = (rows && (rows - 1) * rows >= n) ? rows - 1 : rows;
  14. /* window geoms (cell height/width) */
  15. ch = (m->wh - 2*oh - ih * (rows - 1)) / (rows ? rows : 1);
  16. cw = (m->ww - 2*ov - iv * (cols - 1)) / (cols ? cols : 1);
  17. chrest = (m->wh - 2*oh - ih * (rows - 1)) - ch * rows;
  18. cwrest = (m->ww - 2*ov - iv * (cols - 1)) - cw * cols;
  19. for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
  20. cc = i / rows;
  21. cr = i % rows;
  22. cx = m->wx + ov + cc * (cw + iv) + MIN(cc, cwrest);
  23. cy = m->wy + oh + cr * (ch + ih) + MIN(cr, chrest);
  24. resize(c, cx, cy, cw + (cc < cwrest ? 1 : 0) - 2*c->bw, ch + (cr < chrest ? 1 : 0) - 2*c->bw, False);
  25. }
  26. }