summaryrefslogtreecommitdiffhomepage
path: root/patch
diff options
context:
space:
mode:
authorbakkeby <[email protected]>2020-09-07 09:50:42 +0200
committerbakkeby <[email protected]>2020-09-07 09:50:42 +0200
commitf4f5ecab75916eb6d11333dcaaaa50de22f8db19 (patch)
tree8bd83ec94987f2a28030f84913a7b34e046121c3 /patch
parentfce55dadcb6bf81550f16ebad7270b99d5d08c47 (diff)
downloaddwm-flexipatch-f4f5ecab75916eb6d11333dcaaaa50de22f8db19.tar.gz
dwm-flexipatch-f4f5ecab75916eb6d11333dcaaaa50de22f8db19.zip
Scratchpads improvement (multi-monitor support)
Diffstat (limited to 'patch')
-rw-r--r--patch/scratchpad.c49
1 files changed, 29 insertions, 20 deletions
diff --git a/patch/scratchpad.c b/patch/scratchpad.c
index 4edff52..c0c1873 100644
--- a/patch/scratchpad.c
+++ b/patch/scratchpad.c
@@ -1,25 +1,34 @@
void
togglescratch(const Arg *arg)
{
- Client *c;
- unsigned int found = 0;
- unsigned int scratchtag = SPTAG(arg->ui);
- Arg sparg = {.v = scratchpads[arg->ui].cmd};
+ Client *c = NULL;
+ Monitor *mon;
+ 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 {
- selmon->tagset[selmon->seltags] |= scratchtag;
- spawn(&sparg);
- }
+ for (mon = mons; mon && !found; mon = mon->next)
+ for (c = mon->clients; c && !(found = c->tags & scratchtag); c = c->next);
+
+ if (found) {
+ if (c->mon != selmon) {
+ if (c->mon->tagset[c->mon->seltags] & SPTAGMASK)
+ c->mon->tagset[c->mon->seltags] ^= scratchtag;
+ sendmon(c, selmon);
+ }
+
+ 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