diff options
| -rw-r--r-- | config.h | 1 | ||||
| -rw-r--r-- | dwm.c | 24 |
2 files changed, 18 insertions, 7 deletions
@@ -7,6 +7,7 @@ /* appearance */ static const unsigned int borderpx = 3; /* border pixel of windows */ static const unsigned int snap = 12; /* snap pixel */ +static const int refreshrate = 120; static const int swallowfloating = 1; /* 1 means swallow floating windows by default */ static const int mouse_default = 0; /* 1 means enable mouse by default */ static const char col_gray1[] = "#000000"; @@ -1133,11 +1133,13 @@ movemouse(const Arg *arg) Client *c; Monitor *m; XEvent ev; + Time lasttime = 0; if (!(c = selmon->sel)) return; if (c->isfullscreen) return; + restack(selmon); ocx = c->x; ocy = c->y; @@ -1154,6 +1156,9 @@ movemouse(const Arg *arg) handler[ev.type](&ev); break; case MotionNotify: + if ((ev.xmotion.time - lasttime) <= (1000 / refreshrate)) + continue; + lasttime = ev.xmotion.time; nx = ocx + (ev.xmotion.x - x); ny = ocy + (ev.xmotion.y - y); @@ -1292,22 +1297,24 @@ resizeclient(Client *c, int x, int y, int w, int h) void resizemouse(const Arg *arg) { - int ocx, ocy, nw, nh; + int x, y, ocw, och, nw, nh; Client *c; Monitor *m; XEvent ev; + Time lasttime = 0; if (!(c = selmon->sel)) return; if (c->isfullscreen) return; restack(selmon); - ocx = c->x; - ocy = c->y; + ocw = c->w; + och = c->h; if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, None, cursor[CurResize]->cursor, CurrentTime) != GrabSuccess) return; - XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1); + if(!getrootptr(&x, &y)) + return; do { XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev); switch(ev.type) { @@ -1316,9 +1323,12 @@ resizemouse(const Arg *arg) handler[ev.type](&ev); break; case MotionNotify: + if ((ev.xmotion.time - lasttime) <= (1000 / refreshrate)) + continue; + lasttime = ev.xmotion.time; - nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1); - nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1); + nw = MAX(ocw + (ev.xmotion.x - x), 1); + nh = MAX(och + (ev.xmotion.y - y), 1); if (c->mon->wx + nw >= selmon->wx && c->mon->wx + nw <= selmon->wx + selmon->ww && c->mon->wy + nh >= selmon->wy && c->mon->wy + nh <= selmon->wy + selmon->wh) { @@ -1588,7 +1598,7 @@ setup(void) /* init mouse */ if (mouse_default == 0) { - togglemouse(0); + togglemouse(NULL); } /* supporting window for NetWMCheck */ |
