[download]

config/dwm/resizecorners.patch

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