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.

91 lines
1.6 KiB

  1. static Client * scratchpad_last_showed = NULL;
  2. static void scratchpad_hide ()
  3. {
  4. if (selmon->sel)
  5. {
  6. selmon->sel->tags = SCRATCHPAD_MASK;
  7. focus(NULL);
  8. arrange(selmon);
  9. }
  10. }
  11. static _Bool scratchpad_last_showed_is_killed (void)
  12. {
  13. _Bool killed = 1;
  14. for (Client * c = selmon->clients; c != NULL; c = c->next)
  15. {
  16. if (c == scratchpad_last_showed)
  17. {
  18. killed = 0;
  19. break;
  20. }
  21. }
  22. return killed;
  23. }
  24. static void scratchpad_remove ()
  25. {
  26. if (selmon->sel && scratchpad_last_showed != NULL && selmon->sel == scratchpad_last_showed)
  27. scratchpad_last_showed = NULL;
  28. }
  29. static void scratchpad_show ()
  30. {
  31. if (scratchpad_last_showed == NULL || scratchpad_last_showed_is_killed ())
  32. scratchpad_show_first ();
  33. else
  34. {
  35. if (scratchpad_last_showed->tags != SCRATCHPAD_MASK)
  36. {
  37. scratchpad_last_showed->tags = SCRATCHPAD_MASK;
  38. focus(NULL);
  39. arrange(selmon);
  40. }
  41. else
  42. {
  43. _Bool found_current = 0;
  44. _Bool found_next = 0;
  45. for (Client * c = selmon->clients; c != NULL; c = c->next)
  46. {
  47. if (found_current == 0)
  48. {
  49. if (c == scratchpad_last_showed)
  50. {
  51. found_current = 1;
  52. continue;
  53. }
  54. }
  55. else
  56. {
  57. if (c->tags == SCRATCHPAD_MASK)
  58. {
  59. found_next = 1;
  60. scratchpad_show_client (c);
  61. break;
  62. }
  63. }
  64. }
  65. if (found_next == 0) scratchpad_show_first ();
  66. }
  67. }
  68. }
  69. static void scratchpad_show_client (Client * c)
  70. {
  71. scratchpad_last_showed = c;
  72. c->tags = selmon->tagset[selmon->seltags];
  73. focus(c);
  74. arrange(selmon);
  75. }
  76. static void scratchpad_show_first (void)
  77. {
  78. for (Client * c = selmon->clients; c != NULL; c = c->next)
  79. {
  80. if (c->tags == SCRATCHPAD_MASK)
  81. {
  82. scratchpad_show_client (c);
  83. break;
  84. }
  85. }
  86. }