rotatestack.c 776 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. void
  2. enqueue(Client *c)
  3. {
  4. Client *l;
  5. for (l = c->mon->clients; l && l->next; l = l->next);
  6. if (l) {
  7. l->next = c;
  8. c->next = NULL;
  9. }
  10. }
  11. void
  12. enqueuestack(Client *c)
  13. {
  14. Client *l;
  15. for (l = c->mon->stack; l && l->snext; l = l->snext);
  16. if (l) {
  17. l->snext = c;
  18. c->snext = NULL;
  19. }
  20. }
  21. void
  22. rotatestack(const Arg *arg)
  23. {
  24. Client *c = NULL, *f;
  25. if (!selmon->sel)
  26. return;
  27. f = selmon->sel;
  28. if (arg->i > 0) {
  29. for (c = nexttiled(selmon->clients); c && nexttiled(c->next); c = nexttiled(c->next));
  30. if (c){
  31. detach(c);
  32. attach(c);
  33. detachstack(c);
  34. attachstack(c);
  35. }
  36. } else {
  37. if ((c = nexttiled(selmon->clients))){
  38. detach(c);
  39. enqueue(c);
  40. detachstack(c);
  41. enqueuestack(c);
  42. }
  43. }
  44. if (c){
  45. arrange(selmon);
  46. focus(f);
  47. restack(selmon);
  48. }
  49. }