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.

85 lines
1.5 KiB

4 years ago
  1. diff --git a/config.def.h b/config.def.h
  2. index cca37df..91b91aa 100644
  3. --- a/config.def.h
  4. +++ b/config.def.h
  5. @@ -29,1 +29,2 @@
  6. +#include "fibonacci.c"
  7. static const Layout layouts[] = {
  8. @@ -34,3 +35,5 @@
  9. + { "[@]", spiral },
  10. + { "[\\]", dwindle },
  11. };
  12. /* key definitions */
  13. diff --git a/fibonacci.c b/fibonacci.c
  14. new file mode 100644
  15. index 0000000..fce0a57
  16. --- /dev/null
  17. +++ b/fibonacci.c
  18. @@ -0,0 +1,66 @@
  19. +void
  20. +fibonacci(Monitor *mon, int s) {
  21. + unsigned int i, n, nx, ny, nw, nh;
  22. + Client *c;
  23. +
  24. + for(n = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next), n++);
  25. + if(n == 0)
  26. + return;
  27. +
  28. + nx = mon->wx;
  29. + ny = 0;
  30. + nw = mon->ww;
  31. + nh = mon->wh;
  32. +
  33. + for(i = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next)) {
  34. + if((i % 2 && nh / 2 > 2 * c->bw)
  35. + || (!(i % 2) && nw / 2 > 2 * c->bw)) {
  36. + if(i < n - 1) {
  37. + if(i % 2)
  38. + nh /= 2;
  39. + else
  40. + nw /= 2;
  41. + if((i % 4) == 2 && !s)
  42. + nx += nw;
  43. + else if((i % 4) == 3 && !s)
  44. + ny += nh;
  45. + }
  46. + if((i % 4) == 0) {
  47. + if(s)
  48. + ny += nh;
  49. + else
  50. + ny -= nh;
  51. + }
  52. + else if((i % 4) == 1)
  53. + nx += nw;
  54. + else if((i % 4) == 2)
  55. + ny += nh;
  56. + else if((i % 4) == 3) {
  57. + if(s)
  58. + nx += nw;
  59. + else
  60. + nx -= nw;
  61. + }
  62. + if(i == 0)
  63. + {
  64. + if(n != 1)
  65. + nw = mon->ww * mon->mfact;
  66. + ny = mon->wy;
  67. + }
  68. + else if(i == 1)
  69. + nw = mon->ww - nw;
  70. + i++;
  71. + }
  72. + resize(c, nx, ny, nw - 2 * c->bw, nh - 2 * c->bw, False);
  73. + }
  74. +}
  75. +
  76. +void
  77. +dwindle(Monitor *mon) {
  78. + fibonacci(mon, 1);
  79. +}
  80. +
  81. +void
  82. +spiral(Monitor *mon) {
  83. + fibonacci(mon, 0);
  84. +}