dwm-meillo

changeset 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 46d44d185464
files client.c dwm.h event.c util.c
diffstat 4 files changed, 12 insertions(+), 54 deletions(-) [+]
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
     2.1 --- a/dwm.h	Fri Jul 14 12:11:24 2006 +0200
     2.2 +++ b/dwm.h	Fri Jul 14 13:03:53 2006 +0200
     2.3 @@ -137,9 +137,6 @@
     2.4  extern unsigned int textw(char *text);
     2.5  extern unsigned int texth(void);
     2.6  
     2.7 -/* event.c */
     2.8 -extern void discard_events(long even_mask);
     2.9 -
    2.10  /* dev.c */
    2.11  extern void update_keys(void);
    2.12  extern void keypress(XEvent *e);
    2.13 @@ -155,8 +152,5 @@
    2.14  /* util.c */
    2.15  extern void error(const char *errstr, ...);
    2.16  extern void *emallocz(unsigned int size);
    2.17 -extern void *emalloc(unsigned int size);
    2.18 -extern void *erealloc(void *ptr, unsigned int size);
    2.19 -extern char *estrdup(const char *str);
    2.20  extern void spawn(Arg *arg);
    2.21  extern void swap(void **p1, void **p2);
     3.1 --- a/event.c	Fri Jul 14 12:11:24 2006 +0200
     3.2 +++ b/event.c	Fri Jul 14 13:03:53 2006 +0200
     3.3 @@ -4,6 +4,7 @@
     3.4   */
     3.5  
     3.6  #include <fcntl.h>
     3.7 +#include <stdio.h>
     3.8  #include <stdlib.h>
     3.9  #include <string.h>
    3.10  #include <X11/keysym.h>
    3.11 @@ -37,13 +38,6 @@
    3.12  	[UnmapNotify] = unmapnotify
    3.13  };
    3.14  
    3.15 -void
    3.16 -discard_events(long even_mask)
    3.17 -{
    3.18 -	XEvent ev;
    3.19 -	while(XCheckMaskEvent(dpy, even_mask, &ev));
    3.20 -}
    3.21 -
    3.22  static void
    3.23  buttonpress(XEvent *e)
    3.24  {
     4.1 --- a/util.c	Fri Jul 14 12:11:24 2006 +0200
     4.2 +++ b/util.c	Fri Jul 14 13:03:53 2006 +0200
     4.3 @@ -6,7 +6,6 @@
     4.4  #include <stdarg.h>
     4.5  #include <stdio.h>
     4.6  #include <stdlib.h>
     4.7 -#include <string.h>
     4.8  #include <sys/types.h>
     4.9  #include <sys/wait.h>
    4.10  #include <unistd.h>
    4.11 @@ -39,33 +38,6 @@
    4.12  	return res;
    4.13  }
    4.14  
    4.15 -void *
    4.16 -emalloc(unsigned int size)
    4.17 -{
    4.18 -	void *res = malloc(size);
    4.19 -	if(!res)
    4.20 -		bad_malloc(size);
    4.21 -	return res;
    4.22 -}
    4.23 -
    4.24 -void *
    4.25 -erealloc(void *ptr, unsigned int size)
    4.26 -{
    4.27 -	void *res = realloc(ptr, size);
    4.28 -	if(!res)
    4.29 -		bad_malloc(size);
    4.30 -	return res;
    4.31 -}
    4.32 -
    4.33 -char *
    4.34 -estrdup(const char *str)
    4.35 -{
    4.36 -	char *res = strdup(str);
    4.37 -	if(!res)
    4.38 -		bad_malloc(strlen(str));
    4.39 -	return res;
    4.40 -}
    4.41 -
    4.42  void
    4.43  swap(void **p1, void **p2)
    4.44  {