[dwm] Add swallow rules

This commit is contained in:
dogeystamp 2022-04-30 23:14:12 -04:00 committed by dogeystamp
parent 9a8bf0cce8
commit 97747aae7c
2 changed files with 28 additions and 13 deletions

View File

@ -45,10 +45,9 @@ static const Rule rules[] = {
* WM_CLASS(STRING) = instance, class * WM_CLASS(STRING) = instance, class
* WM_NAME(STRING) = title * WM_NAME(STRING) = title
*/ */
/* class instance title tags mask isfloating isterminal noswallow monitor */ /* class instance title tags mask isfloating isterminal noswallow monitor swalresize */
{ "Firefox", NULL, NULL, 1 << 8, 0, 0, -1, -1 }, { NULL, NULL, "st", 0, 0, 1, 1, -1, 0},
{ NULL, NULL, "st", 0, 0, 1, 1, -1 }, { "mpv", NULL, NULL, 0, 0, 0, 0, -1, 1}, /* mpv */
{ NULL, NULL, "Event Tester", 0, 0, 0, 1, -1 }, /* xev */
}; };
/* layout(s) */ /* layout(s) */

View File

@ -100,7 +100,7 @@ struct Client {
int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid; int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid;
int bw, oldbw; int bw, oldbw;
unsigned int tags; unsigned int tags;
int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, isterminal, noswallow; int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, isterminal, noswallow, swalresize;
pid_t pid; pid_t pid;
Client *next; Client *next;
Client *snext; Client *snext;
@ -155,6 +155,7 @@ typedef struct {
int isterminal; int isterminal;
int noswallow; int noswallow;
int monitor; int monitor;
int swalresize;
} Rule; } Rule;
/* function declarations */ /* function declarations */
@ -339,6 +340,7 @@ applyrules(Client *c)
{ {
c->isterminal = r->isterminal; c->isterminal = r->isterminal;
c->noswallow = r->noswallow; c->noswallow = r->noswallow;
c->swalresize = r->swalresize;
c->isfloating = r->isfloating; c->isfloating = r->isfloating;
c->tags |= r->tags; c->tags |= r->tags;
for (m = mons; m && m->num != r->monitor; m = m->next); for (m = mons; m && m->num != r->monitor; m = m->next);
@ -465,13 +467,22 @@ swallow(Client *p, Client *c)
if (c->noswallow && !swallowfloating && c->isfloating) if (c->noswallow && !swallowfloating && c->isfloating)
return; return;
detach(p);
detachstack(p);
setclientstate(p, WithdrawnState); setclientstate(p, WithdrawnState);
XUnmapWindow(dpy, p->win); XUnmapWindow(dpy, p->win);
c->swallowing = p; if (c->swalresize) {
detach(p);
detachstack(p);
c->swallowing = p;
} else {
detach(c);
detachstack(c);
p->swallowing = c;
Window w = p->win;
p->win = c->win;
c->win = w;
}
c->mon = p->mon; c->mon = p->mon;
updatetitle(p); updatetitle(p);
@ -485,11 +496,16 @@ void
unswallow(Client *c) unswallow(Client *c)
{ {
Client old = *c; Client old = *c;
memcpy(c, c->swallowing, sizeof(Client));
c->next = old.next; if (c->swallowing->swalresize || c->swalresize) {
c->snext = old.snext; memcpy(c, c->swallowing, sizeof(Client));
c->mon = old.mon;
c->next = old.next;
c->snext = old.snext;
c->mon = old.mon;
}
else
c->win = c->swallowing->win;
free(old.swallowing); free(old.swallowing);
c->swallowing = NULL; c->swallowing = NULL;