aewl

diff event.c @ 708:a2d568a5cdb8

applied Sanders all5.patch (thanks for your weekend session, Sander!)
author Anselm R. Garbe <arg@suckless.org>
date Mon, 22 Jan 2007 10:22:58 +0100
parents c3c57faef013
children 6c2fcf88dd9f
line diff
     1.1 --- a/event.c	Fri Jan 19 15:05:07 2007 +0100
     1.2 +++ b/event.c	Mon Jan 22 10:22:58 2007 +0100
     1.3 @@ -35,14 +35,16 @@
     1.4  	c->ismax = False;
     1.5  	XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
     1.6  	for(;;) {
     1.7 -		XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev);
     1.8 +		XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev);
     1.9  		switch (ev.type) {
    1.10  		case ButtonRelease:
    1.11 -			resize(c, True, TopLeft);
    1.12 +			resize(c, True);
    1.13  			XUngrabPointer(dpy, CurrentTime);
    1.14  			return;
    1.15 +		case ConfigureRequest:
    1.16  		case Expose:
    1.17 -			handler[Expose](&ev);
    1.18 +		case MapRequest:
    1.19 +			handler[ev.type](&ev);
    1.20  			break;
    1.21  		case MotionNotify:
    1.22  			XSync(dpy, False);
    1.23 @@ -50,13 +52,13 @@
    1.24  			c->y = ocy + (ev.xmotion.y - y1);
    1.25  			if(abs(wax + c->x) < SNAP)
    1.26  				c->x = wax;
    1.27 -			else if(abs((wax + waw) - (c->x + c->w)) < SNAP)
    1.28 -				c->x = wax + waw - c->w - 2 * BORDERPX;
    1.29 +			else if(abs((wax + waw) - (c->x + c->w + 2 * c->border)) < SNAP)
    1.30 +				c->x = wax + waw - c->w - 2 * c->border;
    1.31  			if(abs(way - c->y) < SNAP)
    1.32  				c->y = way;
    1.33 -			else if(abs((way + wah) - (c->y + c->h)) < SNAP)
    1.34 -				c->y = way + wah - c->h - 2 * BORDERPX;
    1.35 -			resize(c, False, TopLeft);
    1.36 +			else if(abs((way + wah) - (c->y + c->h + 2 * c->border)) < SNAP)
    1.37 +				c->y = way + wah - c->h - 2 * c->border;
    1.38 +			resize(c, False);
    1.39  			break;
    1.40  		}
    1.41  	}
    1.42 @@ -66,7 +68,6 @@
    1.43  resizemouse(Client *c) {
    1.44  	int ocx, ocy;
    1.45  	int nw, nh;
    1.46 -	Corner sticky;
    1.47  	XEvent ev;
    1.48  
    1.49  	ocx = c->x;
    1.50 @@ -75,30 +76,26 @@
    1.51  			None, cursor[CurResize], CurrentTime) != GrabSuccess)
    1.52  		return;
    1.53  	c->ismax = False;
    1.54 -	XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h);
    1.55 +	XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->border - 1, c->h + c->border - 1);
    1.56  	for(;;) {
    1.57 -		XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev);
    1.58 +		XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask , &ev);
    1.59  		switch(ev.type) {
    1.60  		case ButtonRelease:
    1.61 -			resize(c, True, TopLeft);
    1.62 +			resize(c, True);
    1.63  			XUngrabPointer(dpy, CurrentTime);
    1.64  			return;
    1.65 +		case ConfigureRequest:
    1.66  		case Expose:
    1.67 -			handler[Expose](&ev);
    1.68 +		case MapRequest:
    1.69 +			handler[ev.type](&ev);
    1.70  			break;
    1.71  		case MotionNotify:
    1.72  			XSync(dpy, False);
    1.73 -			if((nw = abs(ocx - ev.xmotion.x)))
    1.74 -				c->w = nw;
    1.75 -			if((nh = abs(ocy - ev.xmotion.y)))
    1.76 -				c->h = nh;
    1.77 -			c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w;
    1.78 -			c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h;
    1.79 -			if(ocx <= ev.xmotion.x)
    1.80 -				sticky = (ocy <= ev.xmotion.y) ? TopLeft : BotLeft;
    1.81 -			else
    1.82 -				sticky = (ocy <= ev.xmotion.y) ? TopRight : BotRight;
    1.83 -			resize(c, True, sticky);
    1.84 +			nw = ev.xmotion.x - ocx - 2 * c->border + 1;
    1.85 +			c->w = nw > 0 ? nw : 1;
    1.86 +			nh = ev.xmotion.y - ocy - 2 * c->border + 1;
    1.87 +			c->h = nh > 0 ? nh : 1;
    1.88 +			resize(c, True);
    1.89  			break;
    1.90  		}
    1.91  	}
    1.92 @@ -194,7 +191,7 @@
    1.93  			configure(c);
    1.94  		XSync(dpy, False);
    1.95  		if(c->isfloat) {
    1.96 -			resize(c, False, TopLeft);
    1.97 +			resize(c, False);
    1.98  			if(!isvisible(c))
    1.99  				XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
   1.100  		}
   1.101 @@ -234,7 +231,8 @@
   1.102  		focus(c);
   1.103  	else if(ev->window == root) {
   1.104  		issel = True;
   1.105 -		focus(sel);
   1.106 +		for(c = stack; c && !isvisible(c); c = c->snext);
   1.107 +		focus(c);
   1.108  	}
   1.109  }
   1.110