Adding resizepoint patch

pull/19/head
bakkeby 4 years ago
parent 736cb19ebc
commit f94e8757f6

@ -0,0 +1,75 @@
From d68243353a1f17af91bef4803b2f4b4dbed6ae54 Mon Sep 17 00:00:00 2001
From: bakkeby <bakkeby@gmail.com>
Date: Wed, 24 Jun 2020 14:16:27 +0200
Subject: [PATCH] resizepoint - Like resizecorners, but does not warp mouse
pointer
---
dwm.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/dwm.c b/dwm.c
index 4465af1..c94d4a4 100644
--- a/dwm.c
+++ b/dwm.c
@@ -1290,10 +1290,13 @@ resizeclient(Client *c, int x, int y, int w, int h)
void
resizemouse(const Arg *arg)
{
- int ocx, ocy, nw, nh;
+ int opx, opy, ocx, ocy, och, ocw, nx, ny, nw, nh;
Client *c;
Monitor *m;
XEvent ev;
+ int horizcorner, vertcorner;
+ unsigned int dui;
+ Window dummy;
Time lasttime = 0;
if (!(c = selmon->sel))
@@ -1303,10 +1306,15 @@ resizemouse(const Arg *arg)
restack(selmon);
ocx = c->x;
ocy = c->y;
+ och = c->h;
+ ocw = c->w;
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 (!XQueryPointer(dpy, c->win, &dummy, &dummy, &opx, &opy, &nx, &ny, &dui))
+ return;
+ horizcorner = nx < c->w / 2;
+ vertcorner = ny < c->h / 2;
do {
XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
switch(ev.type) {
@@ -1320,8 +1328,10 @@ resizemouse(const Arg *arg)
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);
+ nx = horizcorner ? (ocx + ev.xmotion.x - opx) : c->x;
+ ny = vertcorner ? (ocy + ev.xmotion.y - opy) : c->y;
+ nw = MAX(horizcorner ? (ocx + ocw - nx) : (ocw + (ev.xmotion.x - opx)), 1);
+ nh = MAX(vertcorner ? (ocy + och - ny) : (och + (ev.xmotion.y - opy)), 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)
{
@@ -1330,11 +1340,10 @@ resizemouse(const Arg *arg)
togglefloating(NULL);
}
if (!selmon->lt[selmon->sellt]->arrange || c->isfloating)
- resize(c, c->x, c->y, nw, nh, 1);
+ resizeclient(c, nx, ny, nw, nh);
break;
}
} while (ev.type != ButtonRelease);
- XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
XUngrabPointer(dpy, CurrentTime);
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {
--
2.19.1
Loading…
Cancel
Save