JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
applied dme's patch to prevent changing prevtags if nothing actually changed
[dwm.git] / dwm.c
diff --git a/dwm.c b/dwm.c
index 5814844..020adb3 100644 (file)
--- a/dwm.c
+++ b/dwm.c
@@ -368,23 +368,16 @@ buttonpress(XEvent *e) {
                if(CLEANMASK(ev->state) != MODKEY)
                        return;
                if(ev->button == Button1) {
-                       if((m->layout->arrange == floating) || c->isfloating)
-                               restack();
-                       else
-                               togglefloating(NULL);
+                       restack();
                        movemouse(c);
                }
                else if(ev->button == Button2) {
                        if((floating != m->layout->arrange) && c->isfloating)
                                togglefloating(NULL);
-                       else
-                               zoom(NULL);
+                       zoom(NULL);
                }
                else if(ev->button == Button3 && !c->isfixed) {
-                       if((floating == m->layout->arrange) || c->isfloating)
-                               restack();
-                       else
-                               togglefloating(NULL);
+                       restack();
                        resizemouse(c);
                }
        }
@@ -1195,7 +1188,10 @@ movemouse(Client *c) {
                                ny = m->way;
                        else if(abs((m->way + m->wah) - (ny + c->h + 2 * c->border)) < SNAP)
                                ny = m->way + m->wah - c->h - 2 * c->border;
-                       resize(c, nx, ny, c->w, c->h, False);
+                       if((monitors[selmonitor].layout->arrange != floating) && (abs(nx - c->x) > SNAP || abs(ny - c->y) > SNAP))
+                               togglefloating(NULL);
+                       if((monitors[selmonitor].layout->arrange == floating) || c->isfloating)
+                               resize(c, nx, ny, c->w, c->h, False);
                        memcpy(c->tags, monitors[monitorat()].seltags, sizeof initags);
                        break;
                }
@@ -1358,7 +1354,10 @@ resizemouse(Client *c) {
                                nw = 1;
                        if((nh = ev.xmotion.y - ocy - 2 * c->border + 1) <= 0)
                                nh = 1;
-                       resize(c, c->x, c->y, nw, nh, True);
+                       if((monitors[selmonitor].layout->arrange != floating) && (abs(nw - c->w) > SNAP || abs(nh - c->h) > SNAP))
+                               togglefloating(NULL);
+                       if((monitors[selmonitor].layout->arrange == floating) || c->isfloating)
+                               resize(c, c->x, c->y, nw, nh, True);
                        break;
                }
        }
@@ -1977,14 +1976,17 @@ xerrorstart(Display *dsply, XErrorEvent *ee) {
 void
 view(const char *arg) {
        unsigned int i;
-
+       Bool tmp[LENGTH(tags)];
        Monitor *m = &monitors[monitorat()];
 
-       memcpy(m->prevtags, m->seltags, sizeof initags);
        for(i = 0; i < LENGTH(tags); i++)
-               m->seltags[i] = (NULL == arg);
-       m->seltags[idxoftag(arg)] = True;
-       arrange();
+               tmp[i] = (NULL == arg);
+       tmp[idxoftag(arg)] = True;
+       if(memcmp(m->seltags, tmp, sizeof initags) != 0) {
+               memcpy(m->prevtags, m->seltags, sizeof initags);
+               memcpy(m->seltags, tmp, sizeof initags);
+               arrange();
+       }
 }
 
 void