JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
take bar into account
[dwm.git] / tile.c
diff --git a/tile.c b/tile.c
index 3cdaf49..8269676 100644 (file)
--- a/tile.c
+++ b/tile.c
@@ -1,20 +1,17 @@
 /* See LICENSE file for copyright and license details. */
-double mfact = MFACT;
 int bx, by, bw, bh, blw, mx, my, mw, mh, tx, ty, tw, th, wx, wy, ww, wh;
 
 void setmfact(const char *arg);
 void tile(void);
-void tilegeom(void);
 void tileresize(Client *c, int x, int y, int w, int h);
+void updatetilegeom(void);
 
 void
 setmfact(const char *arg) {
        double d;
 
-       if(lt->arrange != tile)
+       if(!arg || lt->arrange != tile)
                return;
-       if(!arg)
-               mfact = MFACT;
        else {
                d = strtod(arg, NULL);
                if(arg[0] == '-' || arg[0] == '+')
@@ -23,13 +20,13 @@ setmfact(const char *arg) {
                        return;
                mfact = d;
        }
-       updategeom();
+       updatetilegeom();
        arrange();
 }
 
 void
 tile(void) {
-       int y, h;
+       int x, y, h, w;
        unsigned int i, n;
        Client *c;
 
@@ -49,40 +46,27 @@ tile(void) {
                return;
 
        /* tile stack */
+       x = (tx > c->x + c->w) ? c->x + c->w + 2 * c->bw : tw;
        y = ty;
+       w = (tx > c->x + c->w) ? wx + ww - x : tw;
        h = th / n;
        if(h < bh)
                h = th;
 
        for(i = 0, c = nextunfloating(c->next); c; c = nextunfloating(c->next), i++) {
                if(i + 1 == n) /* remainder */
-                       tileresize(c, tx, y, tw - 2 * c->bw, (ty + th) - y - 2 * c->bw);
+                       tileresize(c, x, y, w - 2 * c->bw, (ty + th) - y - 2 * c->bw);
                else
-                       tileresize(c, tx, y, tw - 2 * c->bw, h - 2 * c->bw);
+                       tileresize(c, x, y, w - 2 * c->bw, h - 2 * c->bw);
                if(h != th)
                        y = c->y + c->h + 2 * c->bw;
        }
 }
 
 void
-tilegeom(void) {
-       /* master area geometry */
-       mx = wx;
-       my = wy;
-       mw = mfact * ww;
-       mh = wh;
-
-       /* tile area geometry */
-       tx = mx + mw;
-       ty = wy;
-       tw = ww - mw;
-       th = wh;
-}
-
-void
 tileresize(Client *c, int x, int y, int w, int h) {
-       resize(c, x, y, w, h, RESIZEHINTS);
-       if((RESIZEHINTS) && ((c->h < bh) || (c->h > h) || (c->w < bh) || (c->w > w)))
+       resize(c, x, y, w, h, resizehints);
+       if(resizehints && ((c->h < bh) || (c->h > h) || (c->w < bh) || (c->w > w)))
                /* client doesn't accept size constraints */
                resize(c, x, y, w, h, False);
 }
@@ -101,3 +85,18 @@ zoom(const char *arg) {
        }
        arrange();
 }
+
+void
+updatetilegeom(void) {
+       /* master area geometry */
+       mx = wx;
+       my = wy;
+       mw = mfact * ww;
+       mh = wh;
+
+       /* tile area geometry */
+       tx = mx + mw;
+       ty = wy;
+       tw = ww - mw;
+       th = wh;
+}