diff options
Diffstat (limited to 'patch')
| -rw-r--r-- | patch/include.c | 3 | ||||
| -rw-r--r-- | patch/include.h | 3 | ||||
| -rw-r--r-- | patch/scratchpad_alt_1.c | 92 | ||||
| -rw-r--r-- | patch/scratchpad_alt_1.h | 6 |
4 files changed, 104 insertions, 0 deletions
diff --git a/patch/include.c b/patch/include.c index 78177b3..ef71088 100644 --- a/patch/include.c +++ b/patch/include.c @@ -84,6 +84,9 @@ #if SCRATCHPAD_PATCH #include "scratchpad.c" #endif +#if SCRATCHPAD_ALT_1_PATCH +#include "scratchpad_alt_1.c" +#endif #if SELFRESTART_PATCH #include "selfrestart.c" #endif diff --git a/patch/include.h b/patch/include.h index d728729..62ecd46 100644 --- a/patch/include.h +++ b/patch/include.h @@ -84,6 +84,9 @@ #if SCRATCHPAD_PATCH #include "scratchpad.h" #endif +#if SCRATCHPAD_ALT_1_PATCH +#include "scratchpad_alt_1.h" +#endif #if SELFRESTART_PATCH #include "selfrestart.h" #endif diff --git a/patch/scratchpad_alt_1.c b/patch/scratchpad_alt_1.c new file mode 100644 index 0000000..9d89ac9 --- /dev/null +++ b/patch/scratchpad_alt_1.c @@ -0,0 +1,92 @@ +static Client * scratchpad_last_showed = NULL; + +static void scratchpad_hide () +{ + if (selmon -> sel) + { + selmon -> sel -> tags = scratchpad_mask; + focus(NULL); + arrange(selmon); + } +} + +static _Bool scratchpad_last_showed_is_killed (void) +{ + _Bool killed = 1; + for (Client * c = selmon -> clients; c != NULL; c = c -> next) + { + if (c == scratchpad_last_showed) + { + killed = 0; + break; + } + } + return killed; +} + +static void scratchpad_remove () +{ + if (selmon -> sel && scratchpad_last_showed != NULL && selmon -> sel == scratchpad_last_showed) + scratchpad_last_showed = NULL; +} + +static void scratchpad_show () +{ + if (scratchpad_last_showed == NULL || scratchpad_last_showed_is_killed ()) + scratchpad_show_first (); + else + { + if (scratchpad_last_showed -> tags != scratchpad_mask) + { + scratchpad_last_showed -> tags = scratchpad_mask; + focus(NULL); + arrange(selmon); + } + else + { + _Bool found_current = 0; + _Bool found_next = 0; + for (Client * c = selmon -> clients; c != NULL; c = c -> next) + { + if (found_current == 0) + { + if (c == scratchpad_last_showed) + { + found_current = 1; + continue; + } + } + else + { + if (c -> tags == scratchpad_mask) + { + found_next = 1; + scratchpad_show_client (c); + break; + } + } + } + if (found_next == 0) scratchpad_show_first (); + } + } +} + +static void scratchpad_show_client (Client * c) +{ + scratchpad_last_showed = c; + c -> tags = selmon->tagset[selmon->seltags]; + focus(c); + arrange(selmon); +} + +static void scratchpad_show_first (void) +{ + for (Client * c = selmon -> clients; c != NULL; c = c -> next) + { + if (c -> tags == scratchpad_mask) + { + scratchpad_show_client (c); + break; + } + } +}
\ No newline at end of file diff --git a/patch/scratchpad_alt_1.h b/patch/scratchpad_alt_1.h new file mode 100644 index 0000000..4bbbf9b --- /dev/null +++ b/patch/scratchpad_alt_1.h @@ -0,0 +1,6 @@ +static void scratchpad_hide (); +static _Bool scratchpad_last_showed_is_killed (void); +static void scratchpad_remove (); +static void scratchpad_show (); +static void scratchpad_show_client (Client * c); +static void scratchpad_show_first (void);
\ No newline at end of file |
