aewl

diff client.c @ 63:f14858218641

searching for a better way to discard enter notifies
author Anselm R. Garbe <garbeam@wmii.de>
date Fri, 14 Jul 2006 13:03:53 +0200
parents 0a4b066ce254
children 50450aa24a46
line diff
     1.1 --- a/client.c	Fri Jul 14 12:11:24 2006 +0200
     1.2 +++ b/client.c	Fri Jul 14 13:03:53 2006 +0200
     1.3 @@ -28,17 +28,19 @@
     1.4  void
     1.5  zoom(Arg *arg)
     1.6  {
     1.7 -	Client **l, *old;
     1.8 +	Client **l;
     1.9  
    1.10 -	if(!(old = sel))
    1.11 +	if(!sel)
    1.12  		return;
    1.13  
    1.14 +	if(sel == next(clients)) 
    1.15 +		sel = next(sel->next);
    1.16 +
    1.17  	for(l = &clients; *l && *l != sel; l = &(*l)->next);
    1.18  	*l = sel->next;
    1.19  
    1.20 -	old->next = clients; /* pop */
    1.21 -	clients = old;
    1.22 -	sel = old;
    1.23 +	sel->next = clients; /* pop */
    1.24 +	clients = sel;
    1.25  	arrange(NULL);
    1.26  	focus(sel);
    1.27  }
    1.28 @@ -54,7 +56,6 @@
    1.29  	sel->h = sh - 2 * sel->border - bh;
    1.30  	craise(sel);
    1.31  	resize(sel, False);
    1.32 -	discard_events(EnterWindowMask);
    1.33  }
    1.34  
    1.35  void
    1.36 @@ -65,9 +66,6 @@
    1.37  	tsel = arg->i;
    1.38  	arrange(NULL);
    1.39  
    1.40 -	if((c = next(clients)))
    1.41 -		focus(c);
    1.42 -
    1.43  	for(c = clients; c; c = next(c->next))
    1.44  		draw_client(c);
    1.45  	draw_bar();
    1.46 @@ -120,7 +118,6 @@
    1.47  			focus(sel);
    1.48  		}
    1.49  	}
    1.50 -	discard_events(EnterWindowMask);
    1.51  }
    1.52  
    1.53  void
    1.54 @@ -171,13 +168,12 @@
    1.55  		else
    1.56  			ban_client(c);
    1.57  	}
    1.58 -	if(sel && !sel->tags[tsel]) {
    1.59 +	if(!sel || (sel && !sel->tags[tsel])) {
    1.60  		if((sel = next(clients))) {
    1.61  			craise(sel);
    1.62  			focus(sel);
    1.63  		}
    1.64  	}
    1.65 -	discard_events(EnterWindowMask);
    1.66  }
    1.67  
    1.68  void
    1.69 @@ -323,14 +319,16 @@
    1.70  focus(Client *c)
    1.71  {
    1.72  	Client *old = sel;
    1.73 +	XEvent ev;
    1.74  
    1.75 +	XFlush(dpy);
    1.76  	sel = c;
    1.77  	if(old && old != c)
    1.78  		draw_client(old);
    1.79  	draw_client(c);
    1.80  	XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
    1.81  	XFlush(dpy);
    1.82 -	discard_events(EnterWindowMask);
    1.83 +	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
    1.84  }
    1.85  
    1.86  static void