diff options
| author | bakkeby <[email protected]> | 2020-09-26 12:42:56 +0200 |
|---|---|---|
| committer | bakkeby <[email protected]> | 2020-09-26 12:42:56 +0200 |
| commit | 76292ba325278a38bf8a486b118468a7c6e151c2 (patch) | |
| tree | c9c833dba217ec1350d1104074290bd04455c84d /patch/scratchpad.c | |
| parent | d906aa7a24071750bc0c6bb94ef3b6c8f38db115 (diff) | |
| download | dwm-flexipatch-76292ba325278a38bf8a486b118468a7c6e151c2.tar.gz dwm-flexipatch-76292ba325278a38bf8a486b118468a7c6e151c2.zip | |
scratchpads: enhancing scratchpad by allowing arbitrary clients to be added to (and removed from) each scratchpad area
Diffstat (limited to 'patch/scratchpad.c')
| -rw-r--r-- | patch/scratchpad.c | 75 |
1 files changed, 51 insertions, 24 deletions
diff --git a/patch/scratchpad.c b/patch/scratchpad.c index 5813b6f..2034d0d 100644 --- a/patch/scratchpad.c +++ b/patch/scratchpad.c @@ -1,45 +1,72 @@ void +removescratch(const Arg *arg) +{ + Client *c = selmon->sel; + if (!c) + return; + unsigned int scratchtag = SPTAG(arg->ui); + c->tags = c->mon->tagset[c->mon->seltags] ^ scratchtag; + arrange(c->mon); +} + +void +setscratch(const Arg *arg) +{ + Client *c = selmon->sel; + if (!c) + return; + unsigned int scratchtag = SPTAG(arg->ui); + c->tags = scratchtag; + arrange(c->mon); +} + +void togglescratch(const Arg *arg) { - Client *c = NULL; + Client *c = NULL, *next = NULL, *found = NULL; Monitor *mon; - unsigned int found = 0; unsigned int scratchtag = SPTAG(arg->ui); - unsigned int newtagset; + unsigned int newtagset = 0; int nh = 0, nw = 0; Arg sparg = {.v = scratchpads[arg->ui].cmd}; - for (mon = mons; mon && !found; mon = mon->next) - for (c = mon->clients; c && !(found = c->tags & scratchtag); c = c->next); + for (mon = mons; mon; mon = mon->next) { + for (c = mon->clients; c; c = next) { + next = c->next; + if (!(c->tags & scratchtag)) + continue; - if (found) { + found = c; - if (HIDDEN(c)) { - XMapWindow(dpy, c->win); - setclientstate(c, NormalState); - newtagset = 0; - } else - newtagset = selmon->tagset[selmon->seltags] ^ scratchtag; + if (HIDDEN(c)) { + XMapWindow(dpy, c->win); + setclientstate(c, NormalState); + newtagset = 0; + } else + newtagset = selmon->tagset[selmon->seltags] ^ scratchtag; - if (c->mon != selmon) { - if (c->mon->tagset[c->mon->seltags] & SPTAGMASK) - c->mon->tagset[c->mon->seltags] ^= scratchtag; - if (c->w > selmon->ww) - nw = selmon->ww - c->bw * 2; - if (c->h > selmon->wh) - nh = selmon->wh - c->bw * 2; - if (nw > 0 || nh > 0) - resizeclient(c, c->x, c->y, nw ? nw : c->w, nh ? nh : c->h); - sendmon(c, selmon); + if (c->mon != selmon) { + if (c->mon->tagset[c->mon->seltags] & SPTAGMASK) + c->mon->tagset[c->mon->seltags] ^= scratchtag; + if (c->w > selmon->ww) + nw = selmon->ww - c->bw * 2; + if (c->h > selmon->wh) + nh = selmon->wh - c->bw * 2; + if (nw > 0 || nh > 0) + resizeclient(c, c->x, c->y, nw ? nw : c->w, nh ? nh : c->h); + sendmon(c, selmon); + } } + } + if (found) { if (newtagset) { selmon->tagset[selmon->seltags] = newtagset; focus(NULL); arrange(selmon); } - if (ISVISIBLE(c)) { - focus(c); + if (ISVISIBLE(found)) { + focus(found); restack(selmon); } } else { |
