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.

59 lines
1.7 KiB

  1. #if VANITYGAPS_PATCH
  2. void
  3. grid(Monitor *m)
  4. {
  5. unsigned int i, n;
  6. int cx, cy, cw, ch, cc, cr, chrest, cwrest, cols, rows;
  7. int oh, ov, ih, iv;
  8. Client *c;
  9. getgaps(m, &oh, &ov, &ih, &iv, &n);
  10. /* grid dimensions */
  11. for (rows = 0; rows <= n/2; rows++)
  12. if (rows*rows >= n)
  13. break;
  14. cols = (rows && (rows - 1) * rows >= n) ? rows - 1 : rows;
  15. /* window geoms (cell height/width) */
  16. ch = (m->wh - 2*oh - ih * (rows - 1)) / (rows ? rows : 1);
  17. cw = (m->ww - 2*ov - iv * (cols - 1)) / (cols ? cols : 1);
  18. chrest = (m->wh - 2*oh - ih * (rows - 1)) - ch * rows;
  19. cwrest = (m->ww - 2*ov - iv * (cols - 1)) - cw * cols;
  20. for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
  21. cc = i / rows;
  22. cr = i % rows;
  23. cx = m->wx + ov + cc * (cw + iv) + MIN(cc, cwrest);
  24. cy = m->wy + oh + cr * (ch + ih) + MIN(cr, chrest);
  25. resize(c, cx, cy, cw + (cc < cwrest ? 1 : 0) - 2*c->bw, ch + (cr < chrest ? 1 : 0) - 2*c->bw, False);
  26. }
  27. }
  28. #else
  29. void
  30. grid(Monitor *m)
  31. {
  32. unsigned int i, n;
  33. int cx, cy, cw, ch, cc, cr, chrest, cwrest, cols, rows;
  34. Client *c;
  35. for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
  36. /* grid dimensions */
  37. for (rows = 0; rows <= n/2; rows++)
  38. if (rows*rows >= n)
  39. break;
  40. cols = (rows && (rows - 1) * rows >= n) ? rows - 1 : rows;
  41. /* window geoms (cell height/width) */
  42. ch = m->wh / (rows ? rows : 1);
  43. cw = m->ww / (cols ? cols : 1);
  44. chrest = m->wh - ch * rows;
  45. cwrest = m->ww - cw * cols;
  46. for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
  47. cc = i / rows;
  48. cr = i % rows;
  49. cx = m->wx + cc * cw + MIN(cc, cwrest);
  50. cy = m->wy + cr * ch + MIN(cr, chrest);
  51. resize(c, cx, cy, cw + (cc < cwrest ? 1 : 0) - 2*c->bw, ch + (cr < chrest ? 1 : 0) - 2*c->bw, False);
  52. }
  53. }
  54. #endif