X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=event.c;h=e3bdea42fa30f6a9b564d3ac08dc43ea288adf46;hb=04b633ddf394fccf5a3125ea17239bad6997c8df;hp=e95991738919768a00d8664333bf47d7972e8ef3;hpb=6651dd7fd9e8e95cfc6c472f1adfeff41735d798;p=dwm.git diff --git a/event.c b/event.c index e959917..e3bdea4 100644 --- a/event.c +++ b/event.c @@ -18,6 +18,7 @@ typedef struct { KEYS #define CLEANMASK(mask) (mask & ~(numlockmask | LockMask)) +#define MOUSEMASK (BUTTONMASK | PointerMotionMask) static void movemouse(Client *c) { @@ -47,6 +48,14 @@ movemouse(Client *c) { XSync(dpy, False); c->x = ocx + (ev.xmotion.x - x1); c->y = ocy + (ev.xmotion.y - y1); + if(abs(sx + c->x) < SNAP) + c->x = sx; + else if(abs((sx + sw) - (c->x + c->w)) < SNAP) + c->x = sw - c->w - 2 * BORDERPX; + if(abs((sy + bh) - c->y) < SNAP) + c->y = sy + bh; + else if(abs((sy + sh) - (c->y + c->h)) < SNAP) + c->y = sh - c->h - 2 * BORDERPX; resize(c, False, TopLeft); break; } @@ -135,7 +144,8 @@ buttonpress(XEvent *e) { } else if(ev->button == Button2) zoom(NULL); - else if(ev->button == Button3 && (arrange == dofloat || c->isfloat)) { + else if(ev->button == Button3 && (arrange == dofloat || c->isfloat) && + !c->isfixed) { restack(); resizemouse(c); } @@ -179,7 +189,7 @@ configurerequest(XEvent *e) { ban(c); } else - arrange(NULL); + arrange(); } else { wc.x = ev->x; @@ -304,7 +314,7 @@ propertynotify(XEvent *e) { case XA_WM_TRANSIENT_FOR: XGetTransientForHint(dpy, c->win, &trans); if(!c->isfloat && (c->isfloat = (trans != 0))) - arrange(NULL); + arrange(); break; case XA_WM_NORMAL_HINTS: updatesize(c);