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.

50 lines
1.2 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. void
  2. movestack(const Arg *arg)
  3. {
  4. Client *c = NULL, *p = NULL, *pc = NULL, *i;
  5. if (arg->i > 0) {
  6. if (!selmon->sel)
  7. return;
  8. /* find the client after selmon->sel */
  9. for (c = selmon->sel->next; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
  10. if (!c)
  11. for (c = selmon->clients; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
  12. }
  13. else {
  14. /* find the client before selmon->sel */
  15. for (i = selmon->clients; i != selmon->sel; i = i->next)
  16. if(ISVISIBLE(i) && !i->isfloating)
  17. c = i;
  18. if (!c)
  19. for (; i; i = i->next)
  20. if (ISVISIBLE(i) && !i->isfloating)
  21. c = i;
  22. }
  23. /* find the client before selmon->sel and c */
  24. for (i = selmon->clients; i && (!p || !pc); i = i->next) {
  25. if (i->next == selmon->sel)
  26. p = i;
  27. if (i->next == c)
  28. pc = i;
  29. }
  30. /* swap c and selmon->sel selmon->clients in the selmon->clients list */
  31. if (c && c != selmon->sel) {
  32. Client *temp = selmon->sel->next==c?selmon->sel:selmon->sel->next;
  33. selmon->sel->next = c->next==selmon->sel?c:c->next;
  34. c->next = temp;
  35. if (p && p != c)
  36. p->next = c;
  37. if (pc && pc != selmon->sel)
  38. pc->next = selmon->sel;
  39. if (selmon->sel == selmon->clients)
  40. selmon->clients = c;
  41. else if (c == selmon->clients)
  42. selmon->clients = selmon->sel;
  43. arrange(selmon);
  44. }
  45. }