mirror of
https://github.com/mintycube/dwm.git
synced 2024-10-22 14:05:45 +02:00
scratchpads: enhancing scratchpad by allowing arbitrary clients to be added to (and removed from) each scratchpad area
This commit is contained in:
parent
da05d567a1
commit
6f5b1582d6
10
config.def.h
10
config.def.h
@ -305,13 +305,9 @@ static const char *const autostart[] = {
|
|||||||
|
|
||||||
#if SCRATCHPADS_PATCH
|
#if SCRATCHPADS_PATCH
|
||||||
const char *spcmd1[] = {"st", "-n", "spterm", "-g", "120x34", NULL };
|
const char *spcmd1[] = {"st", "-n", "spterm", "-g", "120x34", NULL };
|
||||||
const char *spcmd2[] = {"st", "-n", "spfm", "-g", "144x41", "-e", "ranger", NULL };
|
|
||||||
const char *spcmd3[] = {"keepassxc", NULL };
|
|
||||||
static Sp scratchpads[] = {
|
static Sp scratchpads[] = {
|
||||||
/* name cmd */
|
/* name cmd */
|
||||||
{"spterm", spcmd1},
|
{"spterm", spcmd1},
|
||||||
{"spranger", spcmd2},
|
|
||||||
{"keepassxc", spcmd3},
|
|
||||||
};
|
};
|
||||||
#endif // SCRATCHPADS_PATCH
|
#endif // SCRATCHPADS_PATCH
|
||||||
|
|
||||||
@ -395,8 +391,6 @@ static const Rule rules[] = {
|
|||||||
RULE(.class = "Firefox", .tags = 1 << 7)
|
RULE(.class = "Firefox", .tags = 1 << 7)
|
||||||
#if SCRATCHPADS_PATCH
|
#if SCRATCHPADS_PATCH
|
||||||
RULE(.instance = "spterm", .tags = SPTAG(0), .isfloating = 1)
|
RULE(.instance = "spterm", .tags = SPTAG(0), .isfloating = 1)
|
||||||
RULE(.instance = "spfm", .tags = SPTAG(1), .isfloating = 1)
|
|
||||||
RULE(.instance = "keepassxc", .tags = SPTAG(2))
|
|
||||||
#endif // SCRATCHPADS_PATCH
|
#endif // SCRATCHPADS_PATCH
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -903,8 +897,8 @@ static Key keys[] = {
|
|||||||
#endif // NO_MOD_BUTTONS_PATCH
|
#endif // NO_MOD_BUTTONS_PATCH
|
||||||
#if SCRATCHPADS_PATCH
|
#if SCRATCHPADS_PATCH
|
||||||
{ MODKEY, XK_grave, togglescratch, {.ui = 0 } },
|
{ MODKEY, XK_grave, togglescratch, {.ui = 0 } },
|
||||||
{ MODKEY|ControlMask, XK_grave, togglescratch, {.ui = 1 } },
|
{ MODKEY|ControlMask, XK_grave, setscratch, {.ui = 0 } },
|
||||||
{ MODKEY|ShiftMask, XK_grave, togglescratch, {.ui = 2 } },
|
{ MODKEY|ShiftMask, XK_grave, removescratch, {.ui = 0 } },
|
||||||
#endif // SCRATCHPADS_PATCH
|
#endif // SCRATCHPADS_PATCH
|
||||||
#if UNFLOATVISIBLE_PATCH
|
#if UNFLOATVISIBLE_PATCH
|
||||||
{ MODKEY|Mod4Mask, XK_space, unfloatvisible, {0} },
|
{ MODKEY|Mod4Mask, XK_space, unfloatvisible, {0} },
|
||||||
|
@ -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
|
void
|
||||||
togglescratch(const Arg *arg)
|
togglescratch(const Arg *arg)
|
||||||
{
|
{
|
||||||
Client *c = NULL;
|
Client *c = NULL, *next = NULL, *found = NULL;
|
||||||
Monitor *mon;
|
Monitor *mon;
|
||||||
unsigned int found = 0;
|
|
||||||
unsigned int scratchtag = SPTAG(arg->ui);
|
unsigned int scratchtag = SPTAG(arg->ui);
|
||||||
unsigned int newtagset;
|
unsigned int newtagset = 0;
|
||||||
int nh = 0, nw = 0;
|
int nh = 0, nw = 0;
|
||||||
Arg sparg = {.v = scratchpads[arg->ui].cmd};
|
Arg sparg = {.v = scratchpads[arg->ui].cmd};
|
||||||
|
|
||||||
for (mon = mons; mon && !found; mon = mon->next)
|
for (mon = mons; mon; mon = mon->next) {
|
||||||
for (c = mon->clients; c && !(found = c->tags & scratchtag); c = c->next);
|
for (c = mon->clients; c; c = next) {
|
||||||
|
next = c->next;
|
||||||
|
if (!(c->tags & scratchtag))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
found = c;
|
||||||
|
|
||||||
|
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 (found) {
|
if (found) {
|
||||||
|
|
||||||
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 (newtagset) {
|
if (newtagset) {
|
||||||
selmon->tagset[selmon->seltags] = newtagset;
|
selmon->tagset[selmon->seltags] = newtagset;
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
if (ISVISIBLE(c)) {
|
if (ISVISIBLE(found)) {
|
||||||
focus(c);
|
focus(found);
|
||||||
restack(selmon);
|
restack(selmon);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -3,4 +3,6 @@ typedef struct {
|
|||||||
const void *cmd;
|
const void *cmd;
|
||||||
} Sp;
|
} Sp;
|
||||||
|
|
||||||
|
static void removescratch(const Arg *arg);
|
||||||
|
static void setscratch(const Arg *arg);
|
||||||
static void togglescratch(const Arg *arg);
|
static void togglescratch(const Arg *arg);
|
Loading…
Reference in New Issue
Block a user