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.

106 lines
2.6 KiB

  1. void
  2. focusstack(const Arg *arg)
  3. {
  4. int i = stackpos(arg);
  5. Client *c, *p;
  6. if (i < 0)
  7. return;
  8. #if ALWAYSFULLSCREEN_PATCH
  9. if (!selmon->sel || selmon->sel->isfullscreen)
  10. return;
  11. #endif // ALWAYSFULLSCREEN_PATCH
  12. #if BAR_WINTITLEACTIONS_PATCH
  13. for (p = NULL, c = selmon->clients; c && (i || !ISVISIBLE(c) || HIDDEN(c));
  14. i -= (ISVISIBLE(c) && !HIDDEN(c) ? 1 : 0), p = c, c = c->next);
  15. #else
  16. for (p = NULL, c = selmon->clients; c && (i || !ISVISIBLE(c));
  17. i -= (ISVISIBLE(c) ? 1 : 0), p = c, c = c->next);
  18. #endif // BAR_WINTITLEACTIONS_PATCH
  19. focus(c ? c : p);
  20. restack(selmon);
  21. }
  22. void
  23. pushstack(const Arg *arg)
  24. {
  25. int i = stackpos(arg);
  26. Client *sel = selmon->sel, *c, *p;
  27. if (i < 0)
  28. return;
  29. else if (i == 0) {
  30. detach(sel);
  31. attach(sel);
  32. }
  33. else {
  34. for (p = NULL, c = selmon->clients; c; p = c, c = c->next)
  35. #if BAR_WINTITLEACTIONS_PATCH
  36. if (!(i -= (ISVISIBLE(c) && !HIDDEN(c) && c != sel)))
  37. #else
  38. if (!(i -= (ISVISIBLE(c) && c != sel)))
  39. #endif // BAR_WINTITLEACTIONS_PATCH
  40. break;
  41. c = c ? c : p;
  42. detach(sel);
  43. sel->next = c->next;
  44. c->next = sel;
  45. }
  46. arrange(selmon);
  47. }
  48. int
  49. stackpos(const Arg *arg)
  50. {
  51. int n, i;
  52. Client *c, *l;
  53. if (!selmon->clients)
  54. return -1;
  55. #if BAR_WINTITLEACTIONS_PATCH
  56. if (arg->i == PREVSEL) {
  57. for (l = selmon->stack; l && (!ISVISIBLE(l) || HIDDEN(l) || l == selmon->sel); l = l->snext);
  58. if (!l)
  59. return -1;
  60. for (i = 0, c = selmon->clients; c != l; i += (ISVISIBLE(c) && !HIDDEN(c) ? 1 : 0), c = c->next);
  61. return i;
  62. }
  63. else if (ISINC(arg->i)) {
  64. if (!selmon->sel)
  65. return -1;
  66. for (i = 0, c = selmon->clients; c != selmon->sel; i += (ISVISIBLE(c) && !HIDDEN(c) ? 1 : 0), c = c->next);
  67. for (n = i; c; n += (ISVISIBLE(c) && !HIDDEN(c) ? 1 : 0), c = c->next);
  68. return MOD(i + GETINC(arg->i), n);
  69. }
  70. else if (arg->i < 0) {
  71. for (i = 0, c = selmon->clients; c; i += (ISVISIBLE(c) && !HIDDEN(c) ? 1 : 0), c = c->next);
  72. return MAX(i + arg->i, 0);
  73. }
  74. else
  75. return arg->i;
  76. #else // !BAR_WINTITLEACTIONS_PATCH
  77. if (arg->i == PREVSEL) {
  78. for (l = selmon->stack; l && (!ISVISIBLE(l) || l == selmon->sel); l = l->snext);
  79. if (!l)
  80. return -1;
  81. for (i = 0, c = selmon->clients; c != l; i += (ISVISIBLE(c) ? 1 : 0), c = c->next);
  82. return i;
  83. }
  84. else if (ISINC(arg->i)) {
  85. if (!selmon->sel)
  86. return -1;
  87. for (i = 0, c = selmon->clients; c != selmon->sel; i += (ISVISIBLE(c) ? 1 : 0), c = c->next);
  88. for (n = i; c; n += (ISVISIBLE(c) ? 1 : 0), c = c->next);
  89. return MOD(i + GETINC(arg->i), n);
  90. }
  91. else if (arg->i < 0) {
  92. for (i = 0, c = selmon->clients; c; i += (ISVISIBLE(c) ? 1 : 0), c = c->next);
  93. return MAX(i + arg->i, 0);
  94. }
  95. else
  96. return arg->i;
  97. #endif // BAR_WINTITLEACTIONS_PATCH
  98. }