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.

98 lines
1.6 KiB

  1. void
  2. fibonacci(Monitor *m, int s)
  3. {
  4. unsigned int i, n;
  5. int nx, ny, nw, nh;
  6. int oh, ov, ih, iv;
  7. int nv, hrest = 0, wrest = 0, r = 1;
  8. Client *c;
  9. getgaps(m, &oh, &ov, &ih, &iv, &n);
  10. if (n == 0)
  11. return;
  12. nx = m->wx + ov;
  13. ny = oh;
  14. nw = m->ww - 2*ov;
  15. nh = m->wh - 2*oh;
  16. for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next)) {
  17. if (r) {
  18. if ((i % 2 && (nh - ih) / 2 <= (bh + 2*c->bw))
  19. || (!(i % 2) && (nw - iv) / 2 <= (bh + 2*c->bw))) {
  20. r = 0;
  21. }
  22. if (r && i < n - 1) {
  23. if (i % 2) {
  24. nv = (nh - ih) / 2;
  25. hrest = nh - 2*nv - ih;
  26. nh = nv;
  27. } else {
  28. nv = (nw - iv) / 2;
  29. wrest = nw - 2*nv - iv;
  30. nw = nv;
  31. }
  32. if ((i % 4) == 2 && !s)
  33. nx += nw + iv;
  34. else if ((i % 4) == 3 && !s)
  35. ny += nh + ih;
  36. }
  37. if ((i % 4) == 0) {
  38. if (s) {
  39. ny += nh + ih;
  40. nh += hrest;
  41. }
  42. else {
  43. nh -= hrest;
  44. ny -= nh + ih;
  45. }
  46. }
  47. else if ((i % 4) == 1) {
  48. nx += nw + iv;
  49. nw += wrest;
  50. }
  51. else if ((i % 4) == 2) {
  52. ny += nh + ih;
  53. nh += hrest;
  54. if (i < n - 1)
  55. nw += wrest;
  56. }
  57. else if ((i % 4) == 3) {
  58. if (s) {
  59. nx += nw + iv;
  60. nw -= wrest;
  61. } else {
  62. nw -= wrest;
  63. nx -= nw + iv;
  64. nh += hrest;
  65. }
  66. }
  67. if (i == 0) {
  68. if (n != 1) {
  69. nw = (m->ww - iv - 2*ov) - (m->ww - iv - 2*ov) * (1 - m->mfact);
  70. wrest = 0;
  71. }
  72. ny = m->wy + oh;
  73. }
  74. else if (i == 1)
  75. nw = m->ww - nw - iv - 2*ov;
  76. i++;
  77. }
  78. resize(c, nx, ny, nw - (2*c->bw), nh - (2*c->bw), False);
  79. }
  80. }
  81. static void
  82. dwindle(Monitor *m)
  83. {
  84. fibonacci(m, 1);
  85. }
  86. static void
  87. spiral(Monitor *m)
  88. {
  89. fibonacci(m, 0);
  90. }