From 191abc6119491afbafc26057cb0f7ed33738b45e Mon Sep 17 00:00:00 2001 From: Matthias Kruk Date: Wed, 5 Aug 2020 15:56:08 +0900 Subject: [PATCH] bookshelf, bookstack: Make sure applysizehints() does not mess with client dimensions, increase size of first window if the screen size can't be divided evenly --- dwm.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/dwm.c b/dwm.c index a250fc1..56c01f5 100755 --- a/dwm.c +++ b/dwm.c @@ -435,9 +435,11 @@ applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact) { *w -= *w % c->incw; if(c->inch) *h -= *h % c->inch; + /* restore base dimensions */ *w = MAX(*w + c->basew, c->minw); *h = MAX(*h + c->baseh, c->minh); + if(c->maxw) *w = MIN(*w, c->maxw); if(c->maxh) @@ -1516,6 +1518,7 @@ resizeclient(Client *c, int x, int y, int w, int h) { c->oldw = c->w; c->w = wc.width = w; c->oldh = c->h; c->h = wc.height = h; wc.border_width = c->bw; + XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc); configure(c); XSync(dpy, False); @@ -1922,6 +1925,8 @@ tile(Monitor *m) { static void bookshelf(Monitor *m) { int n, w, x; + int extraw; + Client *c; /* count the clients on this monitor */ @@ -1944,15 +1949,22 @@ static void bookshelf(Monitor *m) w = m->ww / n; x = m->wx; + /* make the first window a bit larger if the width can't be divided evenly */ + extraw = m->ww - (w * n); + /* assign positions and sizes to all clients on this screen */ for(c = nexttiled(m->clients); c; c = nexttiled(c->next)) { - resize(c, x, m->wy, w - 2 * c->bw, m->wh - 2 * c->bw, False); + c->incw = 0; + c->inch = 0; + + resize(c, x, m->wy, w + extraw - 2 * c->bw, m->wh - 2 * c->bw, False); /* * Since all clients are horizontally aligned and the * same size, only the x coordinate changes. */ x += WIDTH(c); + extraw = 0; } return; @@ -1961,6 +1973,8 @@ static void bookshelf(Monitor *m) static void bookstack(Monitor *m) { int n, h, y; + int extrah; + Client *c; /* @@ -1977,10 +1991,15 @@ static void bookstack(Monitor *m) h = m->wh / n; y = m->wy; + extrah = m->wh - (h * n); for(c = nexttiled(m->clients); c; c = nexttiled(c->next)) { - resize(c, m->wx, y, m->ww - 2 * c->bw, h - 2 * c->bw, False); + c->incw = 0; + c->inch = 0; + + resize(c, m->wx, y, m->ww - 2 * c->bw, h + extrah - 2 * c->bw, False); y += HEIGHT(c); + extrah = 0; } return; -- 2.47.3