From 690bc98984f132346cc4dfb46a277e89c7e559a7 Mon Sep 17 00:00:00 2001 From: ProsperousPotato Date: Sat, 23 Aug 2025 19:41:46 +0100 Subject: add resizehere patch --- dwm.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'dwm.c') diff --git a/dwm.c b/dwm.c index 7c2dee2..07623a5 100644 --- a/dwm.c +++ b/dwm.c @@ -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 */ -- cgit v1.2.3