changed main event loop
Anselm R.Garbe arg@10ksloc.org
Tue, 15 Aug 2006 07:31:42 +0200
M
event.c
→
event.c
@@ -384,3 +384,16 @@ XGrabKey(dpy, code, key[i].mod | numlockmask | LockMask, root, True,
GrabModeAsync, GrabModeAsync); } } + +void +procevent() +{ + XEvent ev; + + while(XPending(dpy)) { + XNextEvent(dpy, &ev); + if(handler[ev.type]) + (handler[ev.type])(&ev); /* call handler */ + } +} +
M
main.c
→
main.c
@@ -27,7 +27,9 @@ while(sel) {
resize(sel, True, TopLeft); unmanage(sel); } + XUngrabKey(dpy, AnyKey, AnyModifier, root); XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); + XSync(dpy, False); } static void@@ -37,6 +39,7 @@ unsigned int i, num;
Window *wins, d1, d2; XWindowAttributes wa; + wins = NULL; if(XQueryTree(dpy, root, &d1, &d2, &wins, &num)) { for(i = 0; i < num; i++) { if(!XGetWindowAttributes(dpy, wins[i], &wa))@@ -168,7 +171,6 @@ unsigned int mask;
fd_set rd; Bool readin = True; Window w; - XEvent ev; XModifierKeymap *modmap; XSetWindowAttributes wa;@@ -196,6 +198,7 @@
if(otherwm) eprint("dwm: another window manager is already running\n"); + XSync(dpy, False); XSetErrorHandler(NULL); xerrorxlib = XSetErrorHandler(xerror); XSync(dpy, False);@@ -268,7 +271,7 @@ scan();
/* main event loop, also reads status text from stdin */ XSync(dpy, False); - goto XLoop; + procevent(); while(running) { FD_ZERO(&rd); if(readin)@@ -288,14 +291,8 @@ else
strcpy(stext, "broken pipe"); drawstatus(); } - if(FD_ISSET(xfd, &rd)) { -XLoop: - while(XPending(dpy)) { - XNextEvent(dpy, &ev); - if(handler[ev.type]) - (handler[ev.type])(&ev); /* call handler */ - } - } + if(FD_ISSET(xfd, &rd)) + procevent(); } } cleanup();