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.3 KiB

  1. void
  2. horizgrid(Monitor *m) {
  3. Client *c;
  4. unsigned int n, i;
  5. int mx = 0, my = 0, mh = 0, mw = 0;
  6. int sx = 0, sy = 0, sh = 0, sw = 0;
  7. int ntop;
  8. float mfacts = 0, sfacts = 0;
  9. int mrest, srest, mtotal = 0, stotal = 0;
  10. #if VANITYGAPS_PATCH
  11. int oh, ov, ih, iv;
  12. getgaps(m, &oh, &ov, &ih, &iv, &n);
  13. #else
  14. for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
  15. #endif // VANITYGAPS_PATCH
  16. if (n == 0)
  17. return;
  18. if (n <= 2)
  19. ntop = n;
  20. else {
  21. ntop = n / 2;
  22. }
  23. #if VANITYGAPS_PATCH
  24. sx = mx = m->wx + ov;
  25. sy = my = m->wy + oh;
  26. sh = mh = m->wh - 2*oh;
  27. sw = mw = m->ww - 2*ov;
  28. if (n > ntop) {
  29. sh = (mh - ih) / 2;
  30. mh = mh - ih - sh;
  31. sy = my + mh + ih;
  32. mw = m->ww - 2*ov - iv * (ntop - 1);
  33. sw = m->ww - 2*ov - iv * (n - ntop - 1);
  34. }
  35. #else
  36. sx = mx = m->wx;
  37. sy = my = m->wy;
  38. sh = mh = m->wh;
  39. sw = mw = m->ww;
  40. if (n > ntop) {
  41. sh = mh / 2;
  42. mh = mh - sh;
  43. sy = my + mh;
  44. }
  45. #endif // VANITYGAPS_PATCH
  46. /* calculate facts */
  47. #if CFACTS_PATCH
  48. for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
  49. if (i < ntop)
  50. mfacts += c->cfact;
  51. else
  52. sfacts += c->cfact;
  53. for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
  54. if (i < ntop)
  55. mtotal += mh * (c->cfact / mfacts);
  56. else
  57. stotal += sw * (c->cfact / sfacts);
  58. #else
  59. mfacts = ntop;
  60. sfacts = n - ntop;
  61. for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
  62. if (i < ntop)
  63. mtotal += mh / mfacts;
  64. else
  65. stotal += sw / sfacts;
  66. #endif // CFACTS_PATCH
  67. mrest = mh - mtotal;
  68. srest = sw - stotal;
  69. for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
  70. if (i < ntop) {
  71. #if CFACTS_PATCH
  72. resize(c, mx, my, mw * (c->cfact / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0);
  73. #else
  74. resize(c, mx, my, mw / mfacts + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0);
  75. #endif // CFACTS_PATCH
  76. #if VANITYGAPS_PATCH
  77. mx += WIDTH(c) + iv;
  78. #else
  79. mx += WIDTH(c);
  80. #endif // VANITYGAPS_PATCH
  81. } else {
  82. #if CFACTS_PATCH
  83. resize(c, sx, sy, sw * (c->cfact / sfacts) + ((i - ntop) < srest ? 1 : 0) - (2*c->bw), sh - (2*c->bw), 0);
  84. #else
  85. resize(c, sx, sy, sw / sfacts + ((i - ntop) < srest ? 1 : 0) - (2*c->bw), sh - (2*c->bw), 0);
  86. #endif // CFACTS_PATCH
  87. #if VANITYGAPS_PATCH
  88. sx += WIDTH(c) + iv;
  89. #else
  90. sx += WIDTH(c);
  91. #endif // VANITYGAPS_PATCH
  92. }
  93. }