summaryrefslogtreecommitdiffhomepage
path: root/patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch')
-rw-r--r--patch/scratchpad.c38
-rw-r--r--patch/scratchpad.h5
2 files changed, 25 insertions, 18 deletions
diff --git a/patch/scratchpad.c b/patch/scratchpad.c
index 7ba6366..4edff52 100644
--- a/patch/scratchpad.c
+++ b/patch/scratchpad.c
@@ -1,23 +1,25 @@
-static unsigned int scratchtag = 1 << LENGTH(tags);
-
void
togglescratch(const Arg *arg)
{
- Client *c;
- unsigned int found = 0;
+ Client *c;
+ unsigned int found = 0;
+ unsigned int scratchtag = SPTAG(arg->ui);
+ Arg sparg = {.v = scratchpads[arg->ui].cmd};
- for (c = selmon->clients; c && !(found = c->tags & scratchtag); c = c->next);
- if (found) {
- unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchtag;
- if (newtagset) {
- selmon->tagset[selmon->seltags] = newtagset;
- focus(NULL);
- arrange(selmon);
- }
- if (ISVISIBLE(c)) {
- focus(c);
- restack(selmon);
- }
- } else
- spawn(arg);
+ for (c = selmon->clients; c && !(found = c->tags & scratchtag); c = c->next);
+ if (found) {
+ unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchtag;
+ if (newtagset) {
+ selmon->tagset[selmon->seltags] = newtagset;
+ focus(NULL);
+ arrange(selmon);
+ }
+ if (ISVISIBLE(c)) {
+ focus(c);
+ restack(selmon);
+ }
+ } else {
+ selmon->tagset[selmon->seltags] |= scratchtag;
+ spawn(&sparg);
+ }
} \ No newline at end of file
diff --git a/patch/scratchpad.h b/patch/scratchpad.h
index be5c3a4..3142cdf 100644
--- a/patch/scratchpad.h
+++ b/patch/scratchpad.h
@@ -1 +1,6 @@
+typedef struct {
+ const char *name;
+ const void *cmd;
+} Sp;
+
static void togglescratch(const Arg *arg); \ No newline at end of file