From 97747aae7c28fa5bd73c2a34cd103c0a4d01fc0e Mon Sep 17 00:00:00 2001 From: DogeyStamp Date: Sat, 30 Apr 2022 23:14:12 -0400 Subject: [PATCH] [dwm] Add swallow rules --- suckless/dwm/config.def.h | 7 +++---- suckless/dwm/dwm.c | 34 +++++++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/suckless/dwm/config.def.h b/suckless/dwm/config.def.h index bade887..0aa1996 100644 --- a/suckless/dwm/config.def.h +++ b/suckless/dwm/config.def.h @@ -45,10 +45,9 @@ static const Rule rules[] = { * WM_CLASS(STRING) = instance, class * WM_NAME(STRING) = title */ - /* class instance title tags mask isfloating isterminal noswallow monitor */ - { "Firefox", NULL, NULL, 1 << 8, 0, 0, -1, -1 }, - { NULL, NULL, "st", 0, 0, 1, 1, -1 }, - { NULL, NULL, "Event Tester", 0, 0, 0, 1, -1 }, /* xev */ + /* class instance title tags mask isfloating isterminal noswallow monitor swalresize */ + { NULL, NULL, "st", 0, 0, 1, 1, -1, 0}, + { "mpv", NULL, NULL, 0, 0, 0, 0, -1, 1}, /* mpv */ }; /* layout(s) */ diff --git a/suckless/dwm/dwm.c b/suckless/dwm/dwm.c index 41ac4db..b54f160 100644 --- a/suckless/dwm/dwm.c +++ b/suckless/dwm/dwm.c @@ -100,7 +100,7 @@ struct Client { int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid; int bw, oldbw; 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; Client *next; Client *snext; @@ -155,6 +155,7 @@ typedef struct { int isterminal; int noswallow; int monitor; + int swalresize; } Rule; /* function declarations */ @@ -339,6 +340,7 @@ applyrules(Client *c) { c->isterminal = r->isterminal; c->noswallow = r->noswallow; + c->swalresize = r->swalresize; c->isfloating = r->isfloating; c->tags |= r->tags; 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) return; - detach(p); - detachstack(p); - setclientstate(p, WithdrawnState); 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; updatetitle(p); @@ -485,11 +496,16 @@ void unswallow(Client *c) { Client old = *c; - memcpy(c, c->swallowing, sizeof(Client)); - c->next = old.next; - c->snext = old.snext; - c->mon = old.mon; + if (c->swallowing->swalresize || c->swalresize) { + memcpy(c, c->swallowing, sizeof(Client)); + + c->next = old.next; + c->snext = old.snext; + c->mon = old.mon; + } + else + c->win = c->swallowing->win; free(old.swallowing); c->swallowing = NULL;