]> git.corax.cc Git - dwm/commitdiff
bookshelf, bookstack: Make sure applysizehints() does not mess with client dimensions...
authorMatthias Kruk <matthias.kruk@miraclelinux.com>
Wed, 5 Aug 2020 06:56:08 +0000 (15:56 +0900)
committerMatthias Kruk <matthias.kruk@miraclelinux.com>
Wed, 5 Aug 2020 06:56:08 +0000 (15:56 +0900)
dwm.c

diff --git a/dwm.c b/dwm.c
index a250fc17d5b6fbc5105d3e4bedb21f149a947086..56c01f5ccd8b387b0e1191ed69d46748414ff0bf 100755 (executable)
--- 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;