dwm-meillo
changeset 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 |
files | dwm.h event.c main.c |
diffstat | 3 files changed, 21 insertions(+), 10 deletions(-) [+] |
line diff
1.1 --- a/dwm.h Mon Aug 14 19:18:02 2006 +0200 1.2 +++ b/dwm.h Tue Aug 15 07:31:42 2006 +0200 1.3 @@ -108,6 +108,7 @@ 1.4 1.5 /* event.c */ 1.6 extern void grabkeys(); 1.7 +extern void procevent(); 1.8 1.9 /* main.c */ 1.10 extern int getproto(Window w);
2.1 --- a/event.c Mon Aug 14 19:18:02 2006 +0200 2.2 +++ b/event.c Tue Aug 15 07:31:42 2006 +0200 2.3 @@ -384,3 +384,16 @@ 2.4 GrabModeAsync, GrabModeAsync); 2.5 } 2.6 } 2.7 + 2.8 +void 2.9 +procevent() 2.10 +{ 2.11 + XEvent ev; 2.12 + 2.13 + while(XPending(dpy)) { 2.14 + XNextEvent(dpy, &ev); 2.15 + if(handler[ev.type]) 2.16 + (handler[ev.type])(&ev); /* call handler */ 2.17 + } 2.18 +} 2.19 +
3.1 --- a/main.c Mon Aug 14 19:18:02 2006 +0200 3.2 +++ b/main.c Tue Aug 15 07:31:42 2006 +0200 3.3 @@ -27,7 +27,9 @@ 3.4 resize(sel, True, TopLeft); 3.5 unmanage(sel); 3.6 } 3.7 + XUngrabKey(dpy, AnyKey, AnyModifier, root); 3.8 XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); 3.9 + XSync(dpy, False); 3.10 } 3.11 3.12 static void 3.13 @@ -37,6 +39,7 @@ 3.14 Window *wins, d1, d2; 3.15 XWindowAttributes wa; 3.16 3.17 + wins = NULL; 3.18 if(XQueryTree(dpy, root, &d1, &d2, &wins, &num)) { 3.19 for(i = 0; i < num; i++) { 3.20 if(!XGetWindowAttributes(dpy, wins[i], &wa)) 3.21 @@ -168,7 +171,6 @@ 3.22 fd_set rd; 3.23 Bool readin = True; 3.24 Window w; 3.25 - XEvent ev; 3.26 XModifierKeymap *modmap; 3.27 XSetWindowAttributes wa; 3.28 3.29 @@ -196,6 +198,7 @@ 3.30 if(otherwm) 3.31 eprint("dwm: another window manager is already running\n"); 3.32 3.33 + XSync(dpy, False); 3.34 XSetErrorHandler(NULL); 3.35 xerrorxlib = XSetErrorHandler(xerror); 3.36 XSync(dpy, False); 3.37 @@ -268,7 +271,7 @@ 3.38 3.39 /* main event loop, also reads status text from stdin */ 3.40 XSync(dpy, False); 3.41 - goto XLoop; 3.42 + procevent(); 3.43 while(running) { 3.44 FD_ZERO(&rd); 3.45 if(readin) 3.46 @@ -288,14 +291,8 @@ 3.47 strcpy(stext, "broken pipe"); 3.48 drawstatus(); 3.49 } 3.50 - if(FD_ISSET(xfd, &rd)) { 3.51 -XLoop: 3.52 - while(XPending(dpy)) { 3.53 - XNextEvent(dpy, &ev); 3.54 - if(handler[ev.type]) 3.55 - (handler[ev.type])(&ev); /* call handler */ 3.56 - } 3.57 - } 3.58 + if(FD_ISSET(xfd, &rd)) 3.59 + procevent(); 3.60 } 3.61 } 3.62 cleanup();