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.

102 lines
2.1 KiB

  1. #if VANITYGAPS_PATCH
  2. void
  3. nrowgrid(Monitor *m)
  4. {
  5. unsigned int n = 0, i = 0, ri = 0, ci = 0; /* counters */
  6. int oh, ov, ih, iv; /* vanitygap settings */
  7. unsigned int cx, cy, cw, ch; /* client geometry */
  8. unsigned int uw = 0, uh = 0, uc = 0; /* utilization trackers */
  9. unsigned int cols, rows = m->nmaster + 1;
  10. Client *c;
  11. /* count clients */
  12. getgaps(m, &oh, &ov, &ih, &iv, &n);
  13. /* nothing to do here */
  14. if (n == 0)
  15. return;
  16. /* force 2 clients to always split vertically */
  17. if (FORCE_VSPLIT && n == 2)
  18. rows = 1;
  19. /* never allow empty rows */
  20. if (n < rows)
  21. rows = n;
  22. /* define first row */
  23. cols = n / rows;
  24. uc = cols;
  25. cy = m->wy + oh;
  26. ch = (m->wh - 2*oh - ih*(rows - 1)) / rows;
  27. uh = ch;
  28. for (c = nexttiled(m->clients); c; c = nexttiled(c->next), i++, ci++) {
  29. if (ci == cols) {
  30. uw = 0;
  31. ci = 0;
  32. ri++;
  33. /* next row */
  34. cols = (n - uc) / (rows - ri);
  35. uc += cols;
  36. cy = m->wy + oh + uh + ih;
  37. uh += ch + ih;
  38. }
  39. cx = m->wx + ov + uw;
  40. cw = (m->ww - 2*ov - uw) / (cols - ci);
  41. uw += cw + iv;
  42. resize(c, cx, cy, cw - (2*c->bw), ch - (2*c->bw), 0);
  43. }
  44. }
  45. #else
  46. void
  47. nrowgrid(Monitor *m)
  48. {
  49. unsigned int n = 0, i = 0, ri = 0, ci = 0; /* counters */
  50. unsigned int cx, cy, cw, ch; /* client geometry */
  51. unsigned int uw = 0, uh = 0, uc = 0; /* utilization trackers */
  52. unsigned int cols, rows = m->nmaster + 1;
  53. Client *c;
  54. for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
  55. if (n == 0)
  56. return;
  57. /* force 2 clients to always split vertically */
  58. if (FORCE_VSPLIT && n == 2)
  59. rows = 1;
  60. /* never allow empty rows */
  61. if (n < rows)
  62. rows = n;
  63. /* define first row */
  64. cols = n / rows;
  65. uc = cols;
  66. cy = m->wy;
  67. ch = m->wh / rows;
  68. uh = ch;
  69. for (c = nexttiled(m->clients); c; c = nexttiled(c->next), i++, ci++) {
  70. if (ci == cols) {
  71. uw = 0;
  72. ci = 0;
  73. ri++;
  74. /* next row */
  75. cols = (n - uc) / (rows - ri);
  76. uc += cols;
  77. cy = m->wy + uh;
  78. uh += ch;
  79. }
  80. cx = m->wx + uw;
  81. cw = (m->ww - uw) / (cols - ci);
  82. uw += cw;
  83. resize(c, cx, cy, cw - (2*c->bw), ch - (2*c->bw), 0);
  84. }
  85. }
  86. #endif