summaryrefslogtreecommitdiffhomepage
path: root/patch/scratchpad_alt_1.c
diff options
context:
space:
mode:
authorbakkeby <[email protected]>2021-05-06 11:05:48 +0200
committerbakkeby <[email protected]>2021-05-06 11:05:48 +0200
commit9edce6b60686450a875f59a700df84aac377dbf6 (patch)
treed29bc5b32d7858d00c9ef3e5d776b138e0467858 /patch/scratchpad_alt_1.c
parentdf9533f1eb6cbfe289d6bcdb4874ac4e2dea8cd8 (diff)
downloaddwm-flexipatch-9edce6b60686450a875f59a700df84aac377dbf6.tar.gz
dwm-flexipatch-9edce6b60686450a875f59a700df84aac377dbf6.zip
scratchpad_alt_1: upgrading and simplifying patch ref. #124
Diffstat (limited to 'patch/scratchpad_alt_1.c')
-rw-r--r--patch/scratchpad_alt_1.c103
1 files changed, 41 insertions, 62 deletions
diff --git a/patch/scratchpad_alt_1.c b/patch/scratchpad_alt_1.c
index c1301c9..a8ba805 100644
--- a/patch/scratchpad_alt_1.c
+++ b/patch/scratchpad_alt_1.c
@@ -1,77 +1,59 @@
static Client * scratchpad_last_showed = NULL;
-static void scratchpad_hide ()
+void
+scratchpad_hide()
{
- if (selmon->sel)
- {
+ if (selmon->sel) {
selmon->sel->tags = SCRATCHPAD_MASK;
+ selmon->sel->isfloating = 1;
focus(NULL);
arrange(selmon);
}
}
-static _Bool scratchpad_last_showed_is_killed (void)
+_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;
+ Client *c;
+ for (c = selmon->clients; c && c != scratchpad_last_showed; c = c->next);
+ return (c == NULL);
}
-static void scratchpad_remove ()
+void
+scratchpad_remove()
{
if (selmon->sel && scratchpad_last_showed != NULL && selmon->sel == scratchpad_last_showed)
scratchpad_last_showed = NULL;
}
-static void scratchpad_show ()
+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 ();
- }
+ if (scratchpad_last_showed == NULL || scratchpad_last_showed_is_killed()) {
+ scratchpad_show_first();
+ return;
+ }
+
+ if (scratchpad_last_showed->tags != SCRATCHPAD_MASK) {
+ scratchpad_last_showed->tags = SCRATCHPAD_MASK;
+ focus(NULL);
+ arrange(selmon);
+ return;
}
+
+ Client *c;
+
+ for (c = selmon->clients; c && c != scratchpad_last_showed; c = c->next);
+ for (c = (c ? c->next : NULL); c && c->tags != SCRATCHPAD_MASK; c = c->next);
+
+ if (c)
+ scratchpad_show_client(c);
+ else
+ scratchpad_show_first();
}
-static void scratchpad_show_client (Client * c)
+void
+scratchpad_show_client(Client* c)
{
scratchpad_last_showed = c;
c->tags = selmon->tagset[selmon->seltags];
@@ -79,14 +61,11 @@ static void scratchpad_show_client (Client * c)
arrange(selmon);
}
-static void scratchpad_show_first (void)
+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;
- }
- }
+ Client *c;
+ for (c = selmon->clients; c && c->tags != SCRATCHPAD_MASK; c = c->next);
+ if (c)
+ scratchpad_show_client(c);
} \ No newline at end of file