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.

52 lines
1.4 KiB

  1. void
  2. insertclient(Client *item, Client *insertItem, int after)
  3. {
  4. Client *c;
  5. if (item == NULL || insertItem == NULL || item == insertItem) return;
  6. detach(insertItem);
  7. if (!after && selmon->clients == item) {
  8. attach(insertItem);
  9. return;
  10. }
  11. if (after) {
  12. c = item;
  13. } else {
  14. for (c = selmon->clients; c; c = c->next) { if (c->next == item) break; }
  15. }
  16. insertItem->next = c->next;
  17. c->next = insertItem;
  18. }
  19. void
  20. inplacerotate(const Arg *arg)
  21. {
  22. if (!selmon->sel || (selmon->sel->isfloating && !arg->f)) return;
  23. unsigned int selidx = 0, i = 0;
  24. Client *c = NULL, *stail = NULL, *mhead = NULL, *mtail = NULL, *shead = NULL;
  25. // Shift client
  26. for (c = selmon->clients; c; c = c->next) {
  27. if (ISVISIBLE(c) && !(c->isfloating)) {
  28. if (selmon->sel == c) { selidx = i; }
  29. if (i == selmon->nmaster - 1) { mtail = c; }
  30. if (i == selmon->nmaster) { shead = c; }
  31. if (mhead == NULL) { mhead = c; }
  32. stail = c;
  33. i++;
  34. }
  35. }
  36. if (arg->i < 0 && selidx >= selmon->nmaster) insertclient(stail, shead, 1);
  37. if (arg->i > 0 && selidx >= selmon->nmaster) insertclient(shead, stail, 0);
  38. if (arg->i < 0 && selidx < selmon->nmaster) insertclient(mtail, mhead, 1);
  39. if (arg->i > 0 && selidx < selmon->nmaster) insertclient(mhead, mtail, 0);
  40. // Restore focus position
  41. i = 0;
  42. for (c = selmon->clients; c; c = c->next) {
  43. if (!ISVISIBLE(c) || (c->isfloating)) continue;
  44. if (i == selidx) { focus(c); break; }
  45. i++;
  46. }
  47. arrange(selmon);
  48. focus(c);
  49. }