[dwm] Make swallow use new window size

This commit is contained in:
dogeystamp 2022-04-30 14:17:15 -04:00 committed by dogeystamp
parent 6c01ce4dd8
commit 9a8bf0cce8
3 changed files with 20 additions and 42 deletions

View File

@ -9,7 +9,7 @@ alpha
warp
vanitygaps (customised to have 16:9 windows)
vanitygaps
## Installation
Clone the repo.

View File

@ -10,8 +10,6 @@ static const unsigned int gappih = 35; /* horiz inner gap between windo
static const unsigned int gappiv = 40; /* vert inner gap between windows */
static const unsigned int gappoh = 30; /* horiz outer gap between windows and screen edge */
static const unsigned int gappov = 40; /* vert outer gap between windows and screen edge */
static const unsigned int ratioa = 16; /* ratio to use for gap sizes instead of actual values */
static const unsigned int ratiob = 9; /* set to zero to disable */
static int smartgaps = 0; /* 1 means no outer gap when there is only one window */
static int passthrough = 0; /* 1 means to ignore most shortcuts */
static const int showbar = 1; /* 0 means no bar */

View File

@ -129,6 +129,10 @@ struct Monitor {
int by; /* bar geometry */
int mx, my, mw, mh; /* screen size */
int wx, wy, ww, wh; /* window area */
int gappih; /* horizontal gap between windows */
int gappiv; /* vertical gap between windows */
int gappoh; /* horizontal outer gaps */
int gappov; /* vertical outer gaps */
unsigned int seltags;
unsigned int sellt;
unsigned int tagset[2];
@ -220,7 +224,6 @@ static void showhide(Client *c);
static void spawn(const Arg *arg);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void tile(Monitor *m);
static void togglebar(const Arg *arg);
static void togglealtbar(const Arg *arg);
static void togglefloating(const Arg *arg);
@ -457,24 +460,20 @@ attachstack(Client *c)
void
swallow(Client *p, Client *c)
{
if (c->noswallow || c->isterminal)
return;
if (c->noswallow && !swallowfloating && c->isfloating)
return;
detach(c);
detachstack(c);
detach(p);
detachstack(p);
setclientstate(c, WithdrawnState);
setclientstate(p, WithdrawnState);
XUnmapWindow(dpy, p->win);
p->swallowing = c;
c->swallowing = p;
c->mon = p->mon;
Window w = p->win;
p->win = c->win;
c->win = w;
updatetitle(p);
XMoveResizeWindow(dpy, p->win, p->x, p->y, p->w, p->h);
arrange(p->mon);
@ -485,9 +484,14 @@ swallow(Client *p, Client *c)
void
unswallow(Client *c)
{
c->win = c->swallowing->win;
Client old = *c;
memcpy(c, c->swallowing, sizeof(Client));
free(c->swallowing);
c->next = old.next;
c->snext = old.snext;
c->mon = old.mon;
free(old.swallowing);
c->swallowing = NULL;
/* unfullscreen the client */
@ -723,6 +727,10 @@ createmon(void)
m->nmaster = nmaster;
m->showbar = showbar;
m->topbar = topbar;
m->gappih = gappih;
m->gappiv = gappiv;
m->gappoh = gappoh;
m->gappov = gappov;
m->lt[0] = &layouts[0];
m->lt[1] = &layouts[1 % LENGTH(layouts)];
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
@ -1781,34 +1789,6 @@ tagmon(const Arg *arg)
sendmon(selmon->sel, dirtomon(arg->i));
}
void
tile(Monitor *m)
{
unsigned int i, n, h, mw, my, ty;
Client *c;
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
if (n == 0)
return;
if (n > m->nmaster)
mw = m->nmaster ? m->ww * m->mfact : 0;
else
mw = m->ww;
for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
if (i < m->nmaster) {
h = (m->wh - my) / (MIN(n, m->nmaster) - i);
resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
if (my + HEIGHT(c) < m->wh)
my += HEIGHT(c);
} else {
h = (m->wh - ty) / (n - i);
resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
if (ty + HEIGHT(c) < m->wh)
ty += HEIGHT(c);
}
}
void
togglebar(const Arg *arg)
{