JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
fixing two off-by-ones
[dwm.git] / view.c
diff --git a/view.c b/view.c
index 8f5ad64..c005a33 100644 (file)
--- a/view.c
+++ b/view.c
@@ -169,37 +169,42 @@ focusprev(Arg *arg)
        }
 }
 
+Bool
+isvisible(Client *c)
+{
+       unsigned int i;
+
+       for(i = 0; i < ntags; i++)
+               if(c->tags[i] && seltag[i])
+                       return True;
+       return False;
+}
+
 void
-growcol(Arg *arg)
+resizecol(Arg *arg)
 {
-       Client *c = getnext(clients);
+       unsigned int n;
+       Client *c;
 
-       if(!sel || !c || !getnext(c->next) || (arrange != dotile))
+       for(n = 0, c = clients; c; c = c->next)
+               if(isvisible(c) && !c->isfloat)
+                       n++;
+       if(!sel || sel->isfloat || n < 2 || (arrange != dotile) || maximized)
                return;
+
        if(sel == getnext(clients)) {
-               if(mw + arg->i > sw - 100)
+               if(mw + arg->i > sw - 100 || mw + arg->i < 100)
                        return;
                mw += arg->i;
        }
        else {
-               if(mw - arg->i < 100)
+               if(mw - arg->i > sw - 100 || mw - arg->i < 100)
                        return;
                mw -= arg->i;
        }
        arrange(NULL);
 }
 
-Bool
-isvisible(Client *c)
-{
-       unsigned int i;
-
-       for(i = 0; i < ntags; i++)
-               if(c->tags[i] && seltag[i])
-                       return True;
-       return False;
-}
-
 void
 restack()
 {
@@ -303,12 +308,16 @@ viewall(Arg *arg)
 void
 zoom(Arg *arg)
 {
-       Client *c = sel;
+       unsigned int n;
+       Client *c;
 
-       if(!c || (arrange != dotile) || c->isfloat || maximized)
+       for(n = 0, c = clients; c; c = c->next)
+               if(isvisible(c) && !c->isfloat)
+                       n++;
+       if(!sel || sel->isfloat || n < 2 || (arrange != dotile) || maximized)
                return;
 
-       if(c == getnext(clients))
+       if((c = sel)  == getnext(clients))
                if(!(c = getnext(c->next)))
                        return;
        detach(c);