JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
made arrange again like it was once
[dwm.git] / dwm.c
diff --git a/dwm.c b/dwm.c
index 0615978..3c5e6df 100644 (file)
--- a/dwm.c
+++ b/dwm.c
@@ -53,6 +53,7 @@
 #define MOUSEMASK       (BUTTONMASK|PointerMotionMask)
 #define TAGMASK         ((int)((1LL << LENGTH(tags)) - 1))
 #define TEXTW(x)        (textnw(x, strlen(x)) + dc.font.height)
+#define ISVISIBLE(x)    (x->tags & tagset[seltags])
 
 /* enums */
 enum { CurNormal, CurResize, CurMove, CurLast };        /* cursor */
@@ -89,7 +90,7 @@ struct Client {
        int basew, baseh, incw, inch, maxw, maxh, minw, minh;
        int bw, oldbw;
        uint tags;
-       Bool isbanned, isfixed, isfloating, isurgent;
+       Bool isfixed, isfloating, isurgent;
        Client *next;
        Client *snext;
        Window win;
@@ -273,14 +274,13 @@ arrange(void) {
        Client *c;
 
        for(c = clients; c; c = c->next)
-               if(c->tags & tagset[seltags]) { /* is visible */
+               if(ISVISIBLE(c)) {
+                       XMoveWindow(dpy, c->win, c->x, c->y);
                        if(!lt[sellt]->arrange || c->isfloating)
                                resize(c, c->x, c->y, c->w, c->h, True);
-                       c->isbanned = False;
                }
-               else if(!c->isbanned) {
+               else {
                        XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
-                       c->isbanned = True;
                }
 
        focus(NULL);
@@ -426,10 +426,9 @@ configurerequest(XEvent *e) {
                                c->x = sx + (sw / 2 - c->w / 2); /* center in x direction */
                        if((c->y - sy + c->h) > sh && c->isfloating)
                                c->y = sy + (sh / 2 - c->h / 2); /* center in y direction */
-                       if((ev->value_mask & (CWX|CWY))
-                       && !(ev->value_mask & (CWWidth|CWHeight)))
+                       if((ev->value_mask & (CWX|CWY)) && !(ev->value_mask & (CWWidth|CWHeight)))
                                configure(c);
-                       if(!c->isbanned)
+                       if(ISVISIBLE(c))
                                XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
                }
                else
@@ -482,19 +481,17 @@ detachstack(Client *c) {
 void
 drawbar(void) {
        int i, x;
-       Client *c;
 
        dc.x = 0;
-       for(c = stack; c && c->isbanned; c = c->snext);
        for(i = 0; i < LENGTH(tags); i++) {
                dc.w = TEXTW(tags[i]);
                if(tagset[seltags] & 1 << i) {
                        drawtext(tags[i], dc.sel, isurgent(i));
-                       drawsquare(c && c->tags & 1 << i, isoccupied(i), isurgent(i), dc.sel);
+                       drawsquare(sel && sel->tags & 1 << i, isoccupied(i), isurgent(i), dc.sel);
                }
                else {
                        drawtext(tags[i], dc.norm, isurgent(i));
-                       drawsquare(c && c->tags & 1 << i, isoccupied(i), isurgent(i), dc.norm);
+                       drawsquare(sel && sel->tags & 1 << i, isoccupied(i), isurgent(i), dc.norm);
                }
                dc.x += dc.w;
        }
@@ -514,9 +511,9 @@ drawbar(void) {
        drawtext(stext, dc.norm, False);
        if((dc.w = dc.x - x) > bh) {
                dc.x = x;
-               if(c) {
-                       drawtext(c->name, dc.sel, False);
-                       drawsquare(c->isfixed, c->isfloating, False, dc.sel);
+               if(sel) {
+                       drawtext(sel->name, dc.sel, False);
+                       drawsquare(sel->isfixed, sel->isfloating, False, dc.sel);
                }
                else
                        drawtext(NULL, dc.norm, False);
@@ -608,8 +605,8 @@ expose(XEvent *e) {
 
 void
 focus(Client *c) {
-       if(!c || c->isbanned)
-               for(c = stack; c && c->isbanned; c = c->snext);
+       if(!c || !ISVISIBLE(c))
+               for(c = stack; c && !ISVISIBLE(c); c = c->snext);
        if(sel && sel != c) {
                grabbuttons(sel, False);
                XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]);
@@ -642,17 +639,17 @@ focusstack(const Arg *arg) {
        if(!sel)
                return;
        if (arg->i > 0) {
-               for(c = sel->next; c && c->isbanned; c = c->next);
+               for(c = sel->next; c && !ISVISIBLE(c); c = c->next);
                if(!c)
-                       for(c = clients; c && c->isbanned; c = c->next);
+                       for(c = clients; c && !ISVISIBLE(c); c = c->next);
        }
        else {
                for(i = clients; i != sel; i = i->next)
-                       if (!i->isbanned)
+                       if(ISVISIBLE(i))
                                c = i;
                if(!c)
                        for(; i; i = i->next)
-                               if (!i->isbanned)
+                               if(ISVISIBLE(i))
                                        c = i;
        }
        if(c) {
@@ -1021,7 +1018,7 @@ movemouse(const Arg *arg) {
 
 Client *
 nexttiled(Client *c) {
-       for(; c && (c->isfloating || c->isbanned); c = c->next);
+       for(; c && (c->isfloating || !ISVISIBLE(c)); c = c->next);
        return c;
 }
 
@@ -1192,7 +1189,7 @@ restack(void) {
                wc.stack_mode = Below;
                wc.sibling = barwin;
                for(c = stack; c; c = c->snext)
-                       if(!c->isfloating && !c->isbanned) {
+                       if(!c->isfloating && ISVISIBLE(c)) {
                                XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc);
                                wc.sibling = c->win;
                        }