summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorProsperousPotato <ProsperousPotato@users.noreply.github.com>2025-08-23 19:41:46 +0100
committerProsperousPotato <ProsperousPotato@users.noreply.github.com>2025-08-23 19:41:46 +0100
commit690bc98984f132346cc4dfb46a277e89c7e559a7 (patch)
tree629cb50a177396c8b862563c58182f8d34475a20
parent087c298adf198b3138148cae5981c0962e9fcba1 (diff)
add resizehere patch
-rw-r--r--config.h1
-rw-r--r--dwm.c24
2 files changed, 18 insertions, 7 deletions
diff --git a/config.h b/config.h
index 9df8a41..156ff33 100644
--- a/config.h
+++ b/config.h
@@ -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";
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 */