2020-09-26 10:42:56 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2019-10-10 21:33:04 +00:00
|
|
|
void
|
|
|
|
togglescratch(const Arg *arg)
|
|
|
|
{
|
2020-09-26 10:42:56 +00:00
|
|
|
Client *c = NULL, *next = NULL, *found = NULL;
|
2020-09-07 07:50:42 +00:00
|
|
|
Monitor *mon;
|
|
|
|
unsigned int scratchtag = SPTAG(arg->ui);
|
2020-09-26 10:42:56 +00:00
|
|
|
unsigned int newtagset = 0;
|
2020-09-14 11:23:59 +00:00
|
|
|
int nh = 0, nw = 0;
|
2020-09-07 07:50:42 +00:00
|
|
|
Arg sparg = {.v = scratchpads[arg->ui].cmd};
|
2019-10-10 21:33:04 +00:00
|
|
|
|
2020-09-26 10:42:56 +00:00
|
|
|
for (mon = mons; mon; mon = mon->next) {
|
|
|
|
for (c = mon->clients; c; c = next) {
|
|
|
|
next = c->next;
|
|
|
|
if (!(c->tags & scratchtag))
|
|
|
|
continue;
|
2020-09-07 07:50:42 +00:00
|
|
|
|
2020-09-26 10:42:56 +00:00
|
|
|
found = c;
|
2020-09-14 11:23:59 +00:00
|
|
|
|
2020-09-26 10:42:56 +00:00
|
|
|
if (HIDDEN(c)) {
|
|
|
|
XMapWindow(dpy, c->win);
|
|
|
|
setclientstate(c, NormalState);
|
|
|
|
newtagset = 0;
|
|
|
|
} else
|
|
|
|
newtagset = selmon->tagset[selmon->seltags] ^ scratchtag;
|
2020-09-14 11:23:59 +00:00
|
|
|
|
2020-09-26 10:42:56 +00:00
|
|
|
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);
|
|
|
|
}
|
2020-09-07 07:50:42 +00:00
|
|
|
}
|
2020-09-26 10:42:56 +00:00
|
|
|
}
|
2020-09-07 07:50:42 +00:00
|
|
|
|
2020-09-26 10:42:56 +00:00
|
|
|
if (found) {
|
2020-09-07 07:50:42 +00:00
|
|
|
if (newtagset) {
|
|
|
|
selmon->tagset[selmon->seltags] = newtagset;
|
|
|
|
focus(NULL);
|
|
|
|
arrange(selmon);
|
|
|
|
}
|
2020-09-26 10:42:56 +00:00
|
|
|
if (ISVISIBLE(found)) {
|
|
|
|
focus(found);
|
2020-09-07 07:50:42 +00:00
|
|
|
restack(selmon);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
selmon->tagset[selmon->seltags] |= scratchtag;
|
|
|
|
spawn(&sparg);
|
|
|
|
}
|
2019-10-10 21:33:04 +00:00
|
|
|
}
|