aewl

diff main.c @ 292:4aa632b6ba66

changed main event loop
author Anselm R.Garbe <arg@10ksloc.org>
date Tue, 15 Aug 2006 07:31:42 +0200
parents 8e6e0aa5e2ae
children 093744cc5353
line diff
     1.1 --- a/main.c	Mon Aug 14 19:18:02 2006 +0200
     1.2 +++ b/main.c	Tue Aug 15 07:31:42 2006 +0200
     1.3 @@ -27,7 +27,9 @@
     1.4  		resize(sel, True, TopLeft);
     1.5  		unmanage(sel);
     1.6  	}
     1.7 +	XUngrabKey(dpy, AnyKey, AnyModifier, root);
     1.8  	XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
     1.9 +	XSync(dpy, False);
    1.10  }
    1.11  
    1.12  static void
    1.13 @@ -37,6 +39,7 @@
    1.14  	Window *wins, d1, d2;
    1.15  	XWindowAttributes wa;
    1.16  
    1.17 +	wins = NULL;
    1.18  	if(XQueryTree(dpy, root, &d1, &d2, &wins, &num)) {
    1.19  		for(i = 0; i < num; i++) {
    1.20  			if(!XGetWindowAttributes(dpy, wins[i], &wa))
    1.21 @@ -168,7 +171,6 @@
    1.22  	fd_set rd;
    1.23  	Bool readin = True;
    1.24  	Window w;
    1.25 -	XEvent ev;
    1.26  	XModifierKeymap *modmap;
    1.27  	XSetWindowAttributes wa;
    1.28  
    1.29 @@ -196,6 +198,7 @@
    1.30  	if(otherwm)
    1.31  		eprint("dwm: another window manager is already running\n");
    1.32  
    1.33 +	XSync(dpy, False);
    1.34  	XSetErrorHandler(NULL);
    1.35  	xerrorxlib = XSetErrorHandler(xerror);
    1.36  	XSync(dpy, False);
    1.37 @@ -268,7 +271,7 @@
    1.38  
    1.39  	/* main event loop, also reads status text from stdin */
    1.40  	XSync(dpy, False);
    1.41 -	goto XLoop;
    1.42 +	procevent();
    1.43  	while(running) {
    1.44  		FD_ZERO(&rd);
    1.45  		if(readin)
    1.46 @@ -288,14 +291,8 @@
    1.47  					strcpy(stext, "broken pipe");
    1.48  				drawstatus();
    1.49  			}
    1.50 -			if(FD_ISSET(xfd, &rd)) {
    1.51 -XLoop:
    1.52 -				while(XPending(dpy)) {
    1.53 -					XNextEvent(dpy, &ev);
    1.54 -					if(handler[ev.type])
    1.55 -						(handler[ev.type])(&ev); /* call handler */
    1.56 -				}
    1.57 -			}
    1.58 +			if(FD_ISSET(xfd, &rd))
    1.59 +				procevent();
    1.60  		}
    1.61  	}
    1.62  	cleanup();