dwm-resizecorners-6.1.diff (2416B)
1 diff -r -u a/dwm.c b/dwm.c 2 --- a/dwm.c 2015-11-08 17:39:37.000000000 -0500 3 +++ b/dwm.c 2022-01-17 22:49:20.598478626 -0500 4 @@ -1308,9 +1308,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 @@ -1320,10 +1325,19 @@ 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 + 37 do { 38 XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev); 39 switch(ev.type) { 40 @@ -1337,8 +1351,11 @@ 41 continue; 42 lasttime = ev.xmotion.time; 43 44 - nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1); 45 - nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1); 46 + nx = horizcorner ? ev.xmotion.x : c->x; 47 + ny = vertcorner ? ev.xmotion.y : c->y; 48 + nw = MAX(horizcorner ? (ocx2 - nx) : (ev.xmotion.x - ocx - 2 * c->bw + 1), 1); 49 + nh = MAX(vertcorner ? (ocy2 - ny) : (ev.xmotion.y - ocy - 2 * c->bw + 1), 1); 50 + 51 if (c->mon->wx + nw >= selmon->wx && c->mon->wx + nw <= selmon->wx + selmon->ww 52 && c->mon->wy + nh >= selmon->wy && c->mon->wy + nh <= selmon->wy + selmon->wh) 53 { 54 @@ -1347,11 +1364,13 @@ 55 togglefloating(NULL); 56 } 57 if (!selmon->lt[selmon->sellt]->arrange || c->isfloating) 58 - resize(c, c->x, c->y, nw, nh, 1); 59 + resize(c, nx, ny, nw, nh, 1); 60 break; 61 } 62 } while (ev.type != ButtonRelease); 63 - XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1); 64 + XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, 65 + horizcorner ? (-c->bw) : (c->w + c->bw - 1), 66 + vertcorner ? (-c->bw) : (c->h + c->bw - 1)); 67 XUngrabPointer(dpy, CurrentTime); 68 while (XCheckMaskEvent(dpy, EnterWindowMask, &ev)); 69 if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {