sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

dwm-resizecorners-6.0.diff (2546B)


      1 diff -up dwm-6.0/dwm.c dwm-6.0-resizecorners/dwm.c
      2 --- dwm-6.0/dwm.c	2011-12-19 15:02:46.000000000 +0000
      3 +++ dwm-6.0-resizecorners/dwm.c	2015-05-12 23:31:10.803508011 +0000
      4 @@ -1364,20 +1364,35 @@ resizeclient(Client *c, int x, int y, in
      5  void
      6  resizemouse(const Arg *arg) {
      7  	int ocx, ocy;
      8 +	int ocx2, ocy2;
      9 +	int nx, ny;
     10  	int nw, nh;
     11  	Client *c;
     12  	Monitor *m;
     13  	XEvent ev;
     14 +	int horizcorner, vertcorner;
     15 +	int di;
     16 +	unsigned int dui;
     17 +	Window dummy;
     18  
     19  	if(!(c = selmon->sel))
     20  		return;
     21  	restack(selmon);
     22  	ocx = c->x;
     23  	ocy = c->y;
     24 +	ocx2 = c->x + c->w;
     25 +	ocy2 = c->y + c->h;
     26  	if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
     27  	                None, cursor[CurResize], CurrentTime) != GrabSuccess)
     28  		return;
     29 -	XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
     30 +	if (!XQueryPointer (dpy, c->win, &dummy, &dummy, &di, &di, &nx, &ny, &dui))
     31 +		return;
     32 +	horizcorner = nx < c->w / 2;
     33 +	vertcorner = ny < c->h / 2;
     34 +	XWarpPointer (dpy, None, c->win, 0, 0, 0, 0,
     35 +		      horizcorner ? (-c->bw) : (c->w + c->bw - 1),
     36 +		      vertcorner ? (-c->bw) : (c->h + c->bw - 1));
     37 +
     38  	do {
     39  		XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
     40  		switch(ev.type) {
     41 @@ -1387,8 +1402,10 @@ resizemouse(const Arg *arg) {
     42  			handler[ev.type](&ev);
     43  			break;
     44  		case MotionNotify:
     45 -			nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1);
     46 -			nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1);
     47 +			nx = horizcorner ? ev.xmotion.x : c->x;
     48 +			ny = vertcorner ? ev.xmotion.y : c->y;
     49 +			nw = MAX(horizcorner ? (ocx2 - nx) : (ev.xmotion.x - ocx - 2 * c->bw + 1), 1);
     50 +			nh = MAX(vertcorner ? (ocy2 - ny) : (ev.xmotion.y - ocy - 2 * c->bw + 1), 1);
     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 @@ -1397,11 +1414,13 @@ resizemouse(const Arg *arg) {
     55  					togglefloating(NULL);
     56  			}
     57  			if(!selmon->lt[selmon->sellt]->arrange || c->isfloating)
     58 -				resize(c, c->x, c->y, nw, nh, True);
     59 +				resize(c, nx, ny, nw, nh, True);
     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) {