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.

190 lines
3.1 KiB

  1. #if VANITYGAPS_PATCH
  2. void
  3. fibonacci(Monitor *m, int s)
  4. {
  5. unsigned int i, n;
  6. int nx, ny, nw, nh;
  7. int oh, ov, ih, iv;
  8. int nv, hrest = 0, wrest = 0, r = 1;
  9. Client *c;
  10. getgaps(m, &oh, &ov, &ih, &iv, &n);
  11. if (n == 0)
  12. return;
  13. nx = m->wx + ov;
  14. ny = oh;
  15. nw = m->ww - 2*ov;
  16. nh = m->wh - 2*oh;
  17. for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next)) {
  18. if (r) {
  19. if ((i % 2 && (nh - ih) / 2 <= (bh + 2*c->bw))
  20. || (!(i % 2) && (nw - iv) / 2 <= (bh + 2*c->bw))) {
  21. r = 0;
  22. }
  23. if (r && i < n - 1) {
  24. if (i % 2) {
  25. nv = (nh - ih) / 2;
  26. hrest = nh - 2*nv - ih;
  27. nh = nv;
  28. } else {
  29. nv = (nw - iv) / 2;
  30. wrest = nw - 2*nv - iv;
  31. nw = nv;
  32. }
  33. if ((i % 4) == 2 && !s)
  34. nx += nw + iv;
  35. else if ((i % 4) == 3 && !s)
  36. ny += nh + ih;
  37. }
  38. if ((i % 4) == 0) {
  39. if (s) {
  40. ny += nh + ih;
  41. nh += hrest;
  42. }
  43. else {
  44. nh -= hrest;
  45. ny -= nh + ih;
  46. }
  47. }
  48. else if ((i % 4) == 1) {
  49. nx += nw + iv;
  50. nw += wrest;
  51. }
  52. else if ((i % 4) == 2) {
  53. ny += nh + ih;
  54. nh += hrest;
  55. if (i < n - 1)
  56. nw += wrest;
  57. }
  58. else if ((i % 4) == 3) {
  59. if (s) {
  60. nx += nw + iv;
  61. nw -= wrest;
  62. } else {
  63. nw -= wrest;
  64. nx -= nw + iv;
  65. nh += hrest;
  66. }
  67. }
  68. if (i == 0) {
  69. if (n != 1) {
  70. nw = (m->ww - iv - 2*ov) - (m->ww - iv - 2*ov) * (1 - m->mfact);
  71. wrest = 0;
  72. }
  73. ny = m->wy + oh;
  74. }
  75. else if (i == 1)
  76. nw = m->ww - nw - iv - 2*ov;
  77. i++;
  78. }
  79. resize(c, nx, ny, nw - (2*c->bw), nh - (2*c->bw), False);
  80. }
  81. }
  82. #else
  83. void
  84. fibonacci(Monitor *m, int s)
  85. {
  86. unsigned int i, n;
  87. int nx, ny, nw, nh;
  88. int nv, hrest = 0, wrest = 0, r = 1;
  89. Client *c;
  90. for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
  91. if (n == 0)
  92. return;
  93. nx = m->wx;
  94. ny = m->wy;
  95. nw = m->ww;
  96. nh = m->wh;
  97. for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next)) {
  98. if (r) {
  99. if ((i % 2 && nh / 2 <= (bh + 2*c->bw))
  100. || (!(i % 2) && nw / 2 <= (bh + 2*c->bw))) {
  101. r = 0;
  102. }
  103. if (r && i < n - 1) {
  104. if (i % 2) {
  105. nv = nh / 2;
  106. hrest = nh - 2*nv;
  107. nh = nv;
  108. } else {
  109. nv = nw / 2;
  110. wrest = nw - 2*nv;
  111. nw = nv;
  112. }
  113. if ((i % 4) == 2 && !s)
  114. nx += nw;
  115. else if ((i % 4) == 3 && !s)
  116. ny += nh;
  117. }
  118. if ((i % 4) == 0) {
  119. if (s) {
  120. ny += nh;
  121. nh += hrest;
  122. }
  123. else {
  124. nh -= hrest;
  125. ny -= nh;
  126. }
  127. }
  128. else if ((i % 4) == 1) {
  129. nx += nw;
  130. nw += wrest;
  131. }
  132. else if ((i % 4) == 2) {
  133. ny += nh;
  134. nh += hrest;
  135. if (i < n - 1)
  136. nw += wrest;
  137. }
  138. else if ((i % 4) == 3) {
  139. if (s) {
  140. nx += nw;
  141. nw -= wrest;
  142. } else {
  143. nw -= wrest;
  144. nx -= nw;
  145. nh += hrest;
  146. }
  147. }
  148. if (i == 0) {
  149. if (n != 1) {
  150. nw = m->ww - m->ww * (1 - m->mfact);
  151. wrest = 0;
  152. }
  153. ny = m->wy;
  154. }
  155. else if (i == 1)
  156. nw = m->ww - nw;
  157. i++;
  158. }
  159. resize(c, nx, ny, nw - (2*c->bw), nh - (2*c->bw), False);
  160. }
  161. }
  162. #endif
  163. #if FIBONACCI_DWINDLE_LAYOUT
  164. static void
  165. dwindle(Monitor *m)
  166. {
  167. fibonacci(m, 1);
  168. }
  169. #endif
  170. #if FIBONACCI_SPIRAL_LAYOUT
  171. static void
  172. spiral(Monitor *m)
  173. {
  174. fibonacci(m, 0);
  175. }
  176. #endif