JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
removing NULL-terminating **tags definition in config.h
[dwm.git] / dwm.c
diff --git a/dwm.c b/dwm.c
index 90ba67b..c9495ec 100644 (file)
--- a/dwm.c
+++ b/dwm.c
  */
 #include <errno.h>
 #include <locale.h>
-#include <regex.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 #include <sys/select.h>
+#include <sys/types.h>
 #include <sys/wait.h>
+#include <regex.h>
 #include <X11/cursorfont.h>
 #include <X11/keysym.h>
 #include <X11/Xatom.h>
@@ -62,7 +63,7 @@ struct Client {
        int rx, ry, rw, rh; /* revert geometry */
        int basew, baseh, incw, inch, maxw, maxh, minw, minh;
        int minax, maxax, minay, maxay;
-       long flags; 
+       long flags;
        unsigned int border, oldborder;
        Bool isbanned, isfixed, ismax, isfloating, wasfloating;
        Bool *tags;
@@ -341,7 +342,7 @@ buttonpress(XEvent *e) {
                        movemouse(c);
                }
                else if(ev->button == Button2) {
-                       if(isarrange(tile) && !c->isfixed && c->isfloating)
+                       if(ISTILE && !c->isfixed && c->isfloating)
                                togglefloating(NULL);
                        else
                                zoom(NULL);
@@ -1161,7 +1162,7 @@ quit(const char *arg) {
 void
 resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
        double dx, dy, max, min, ratio;
-       XWindowChanges wc; 
+       XWindowChanges wc;
 
        if(sizehints) {
                if(c->minay > 0 && c->maxay > 0 && (h - c->baseh) > 0 && (w - c->basew) > 0) {
@@ -1398,7 +1399,7 @@ void
 setmwfact(const char *arg) {
        double delta;
 
-       if(isarrange(floating))
+       if(!ISTILE)
                return;
        /* arg handling, manipulate mwfact */
        if(arg == NULL)
@@ -1466,7 +1467,7 @@ setup(void) {
 
        /* init tags */
        compileregs();
-       for(ntags = 0; tags[ntags]; ntags++);
+       ntags = sizeof tags / sizeof tags[0];
        seltags = emallocz(sizeof(Bool) * ntags);
        seltags[0] = True;
 
@@ -1568,7 +1569,7 @@ textw(const char *text) {
 void
 tile(void) {
        unsigned int i, n, nx, ny, nw, nh, mw, th;
-       Client *c;
+       Client *c, *mc;
 
        for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
                n++;
@@ -1581,7 +1582,8 @@ tile(void) {
 
        nx = wax;
        ny = way;
-       for(i = 0, c = nexttiled(clients); c; c = nexttiled(c->next), i++) {
+       nw = 0; /* gcc stupidity requires this */
+       for(i = 0, c = mc = nexttiled(clients); c; c = nexttiled(c->next), i++) {
                c->ismax = False;
                if(i == 0) { /* master */
                        nw = mw - 2 * c->border;
@@ -1590,9 +1592,9 @@ tile(void) {
                else {  /* tile window */
                        if(i == 1) {
                                ny = way;
-                               nx += mw;
+                               nx += mc->w + 2 * mc->border;
+                               nw = waw - nx - 2 * c->border;
                        }
-                       nw = waw - mw - 2 * c->border;
                        if(i + 1 == n) /* remainder */
                                nh = (way + wah) - ny - 2 * c->border;
                        else
@@ -1600,7 +1602,7 @@ tile(void) {
                }
                resize(c, nx, ny, nw, nh, RESIZEHINTS);
                if(n > 1 && th != wah)
-                       ny += nh + 2 * c->border;
+                       ny = c->y + c->h + 2 * c->border;
        }
 }
 
@@ -1850,7 +1852,7 @@ void
 zoom(const char *arg) {
        Client *c;
 
-       if(!sel || isarrange(floating) || sel->isfloating)
+       if(!sel || !ISTILE || sel->isfloating)
                return;
        if((c = sel) == nexttiled(clients))
                if(!(c = nexttiled(c->next)))