dwm-resizecorners-6.2.diff - sites - public wiki contents of suckless.org
HTML git clone git://git.suckless.org/sites
DIR Log
DIR Files
DIR Refs
---
dwm-resizecorners-6.2.diff (2383B)
---
1 diff -r -u a/dwm.c b/dwm.c
2 --- a/dwm.c 2019-02-02 07:55:28.000000000 -0500
3 +++ b/dwm.c 2022-01-17 22:38:33.614493243 -0500
4 @@ -1291,9 +1291,14 @@
5 resizemouse(const Arg *arg)
6 {
7 int ocx, ocy, nw, nh;
8 + int ocx2, ocy2, nx, ny;
9 Client *c;
10 Monitor *m;
11 XEvent ev;
12 + int horizcorner, vertcorner;
13 + int di;
14 + unsigned int dui;
15 + Window dummy;
16 Time lasttime = 0;
17
18 if (!(c = selmon->sel))
19 @@ -1303,10 +1308,18 @@
20 restack(selmon);
21 ocx = c->x;
22 ocy = c->y;
23 + ocx2 = c->x + c->w;
24 + ocy2 = c->y + c->h;
25 if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
26 None, cursor[CurResize]->cursor, CurrentTime) != GrabSuccess)
27 return;
28 - XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
29 + if (!XQueryPointer (dpy, c->win, &dummy, &dummy, &di, &di, &nx, &ny, &dui))
30 + return;
31 + horizcorner = nx < c->w / 2;
32 + vertcorner = ny < c->h / 2;
33 + XWarpPointer (dpy, None, c->win, 0, 0, 0, 0,
34 + horizcorner ? (-c->bw) : (c->w + c->bw -1),
35 + vertcorner ? (-c->bw) : (c->h + c->bw -1));
36 do {
37 XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
38 switch(ev.type) {
39 @@ -1320,8 +1333,11 @@
40 continue;
41 lasttime = ev.xmotion.time;
42
43 - nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1);
44 - nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1);
45 + nx = horizcorner ? ev.xmotion.x : c->x;
46 + ny = vertcorner ? ev.xmotion.y : c->y;
47 + nw = MAX(horizcorner ? (ocx2 - nx) : (ev.xmotion.x - ocx - 2 * c->bw + 1), 1);
48 + nh = MAX(vertcorner ? (ocy2 - ny) : (ev.xmotion.y - ocy - 2 * c->bw + 1), 1);
49 +
50 if (c->mon->wx + nw >= selmon->wx && c->mon->wx + nw <= selmon->wx + selmon->ww
51 && c->mon->wy + nh >= selmon->wy && c->mon->wy + nh <= selmon->wy + selmon->wh)
52 {
53 @@ -1330,11 +1346,13 @@
54 togglefloating(NULL);
55 }
56 if (!selmon->lt[selmon->sellt]->arrange || c->isfloating)
57 - resize(c, c->x, c->y, nw, nh, 1);
58 + resize(c, nx, ny, nw, nh, 1);
59 break;
60 }
61 } while (ev.type != ButtonRelease);
62 - XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
63 + XWarpPointer(dpy, None, c->win, 0, 0, 0, 0,
64 + horizcorner ? (-c->bw) : (c->w + c->bw - 1),
65 + vertcorner ? (-c->bw) : (c->h + c->bw - 1));
66 XUngrabPointer(dpy, CurrentTime);
67 while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
68 if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {