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.

75 lines
1.6 KiB

  1. void
  2. removescratch(const Arg *arg)
  3. {
  4. Client *c = selmon->sel;
  5. if (!c)
  6. return;
  7. unsigned int scratchtag = SPTAG(arg->ui);
  8. c->tags = c->mon->tagset[c->mon->seltags] ^ scratchtag;
  9. arrange(c->mon);
  10. }
  11. void
  12. setscratch(const Arg *arg)
  13. {
  14. Client *c = selmon->sel;
  15. if (!c)
  16. return;
  17. unsigned int scratchtag = SPTAG(arg->ui);
  18. c->tags = scratchtag;
  19. arrange(c->mon);
  20. }
  21. void
  22. togglescratch(const Arg *arg)
  23. {
  24. Client *c = NULL, *next = NULL, *found = NULL;
  25. Monitor *mon;
  26. unsigned int scratchtag = SPTAG(arg->ui);
  27. unsigned int newtagset = 0;
  28. int nh = 0, nw = 0;
  29. Arg sparg = {.v = scratchpads[arg->ui].cmd};
  30. for (mon = mons; mon; mon = mon->next) {
  31. for (c = mon->clients; c; c = next) {
  32. next = c->next;
  33. if (!(c->tags & scratchtag))
  34. continue;
  35. found = c;
  36. if (HIDDEN(c)) {
  37. XMapWindow(dpy, c->win);
  38. setclientstate(c, NormalState);
  39. newtagset = 0;
  40. } else
  41. newtagset = selmon->tagset[selmon->seltags] ^ scratchtag;
  42. if (c->mon != selmon) {
  43. if (c->mon->tagset[c->mon->seltags] & SPTAGMASK)
  44. c->mon->tagset[c->mon->seltags] ^= scratchtag;
  45. if (c->w > selmon->ww)
  46. nw = selmon->ww - c->bw * 2;
  47. if (c->h > selmon->wh)
  48. nh = selmon->wh - c->bw * 2;
  49. if (nw > 0 || nh > 0)
  50. resizeclient(c, c->x, c->y, nw ? nw : c->w, nh ? nh : c->h);
  51. sendmon(c, selmon);
  52. }
  53. }
  54. }
  55. if (found) {
  56. if (newtagset) {
  57. selmon->tagset[selmon->seltags] = newtagset;
  58. focus(NULL);
  59. arrange(selmon);
  60. }
  61. if (ISVISIBLE(found)) {
  62. focus(found);
  63. restack(selmon);
  64. }
  65. } else {
  66. selmon->tagset[selmon->seltags] |= scratchtag;
  67. spawn(&sparg);
  68. }
  69. }