]> git.armaanb.net Git - dwm.git/blobdiff - dwm.c
Don't restrict snap in mousemove
[dwm.git] / dwm.c
diff --git a/dwm.c b/dwm.c
index 3f80b632eca1fbc8b700d9334dde12b997f7dfad..7861512f87c7350669ce68c096e39e7ad508294c 100644 (file)
--- a/dwm.c
+++ b/dwm.c
@@ -446,6 +446,8 @@ buttonpress(XEvent *e)
                        click = ClkWinTitle;
        } else if ((c = wintoclient(ev->window))) {
                focus(c);
+               restack(selmon);
+               XAllowEvents(dpy, ReplayPointer, CurrentTime);
                click = ClkClientWin;
        }
        for (i = 0; i < LENGTH(buttons); i++)
@@ -932,17 +934,16 @@ grabbuttons(Client *c, int focused)
                unsigned int i, j;
                unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
                XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
-               if (focused) {
-                       for (i = 0; i < LENGTH(buttons); i++)
-                               if (buttons[i].click == ClkClientWin)
-                                       for (j = 0; j < LENGTH(modifiers); j++)
-                                               XGrabButton(dpy, buttons[i].button,
-                                                           buttons[i].mask | modifiers[j],
-                                                           c->win, False, BUTTONMASK,
-                                                           GrabModeAsync, GrabModeSync, None, None);
-               } else
+               if (!focused)
                        XGrabButton(dpy, AnyButton, AnyModifier, c->win, False,
-                                   BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
+                                   BUTTONMASK, GrabModeSync, GrabModeSync, None, None);
+               for (i = 0; i < LENGTH(buttons); i++)
+                       if (buttons[i].click == ClkClientWin)
+                               for (j = 0; j < LENGTH(modifiers); j++)
+                                       XGrabButton(dpy, buttons[i].button,
+                                                   buttons[i].mask | modifiers[j],
+                                                   c->win, False, BUTTONMASK,
+                                                   GrabModeAsync, GrabModeSync, None, None);
        }
 }
 
@@ -1169,20 +1170,17 @@ movemouse(const Arg *arg)
 
                        nx = ocx + (ev.xmotion.x - x);
                        ny = ocy + (ev.xmotion.y - y);
-                       if (nx >= selmon->wx && nx <= selmon->wx + selmon->ww
-                       && ny >= selmon->wy && ny <= selmon->wy + selmon->wh) {
-                               if (abs(selmon->wx - nx) < snap)
-                                       nx = selmon->wx;
-                               else if (abs((selmon->wx + selmon->ww) - (nx + WIDTH(c))) < snap)
-                                       nx = selmon->wx + selmon->ww - WIDTH(c);
-                               if (abs(selmon->wy - ny) < snap)
-                                       ny = selmon->wy;
-                               else if (abs((selmon->wy + selmon->wh) - (ny + HEIGHT(c))) < snap)
-                                       ny = selmon->wy + selmon->wh - HEIGHT(c);
-                               if (!c->isfloating && selmon->lt[selmon->sellt]->arrange
-                               && (abs(nx - c->x) > snap || abs(ny - c->y) > snap))
-                                       togglefloating(NULL);
-                       }
+                       if (abs(selmon->wx - nx) < snap)
+                               nx = selmon->wx;
+                       else if (abs((selmon->wx + selmon->ww) - (nx + WIDTH(c))) < snap)
+                               nx = selmon->wx + selmon->ww - WIDTH(c);
+                       if (abs(selmon->wy - ny) < snap)
+                               ny = selmon->wy;
+                       else if (abs((selmon->wy + selmon->wh) - (ny + HEIGHT(c))) < snap)
+                               ny = selmon->wy + selmon->wh - HEIGHT(c);
+                       if (!c->isfloating && selmon->lt[selmon->sellt]->arrange
+                       && (abs(nx - c->x) > snap || abs(ny - c->y) > snap))
+                               togglefloating(NULL);
                        if (!selmon->lt[selmon->sellt]->arrange || c->isfloating)
                                resize(c, nx, ny, c->w, c->h, 1);
                        break;