From a57d81237a94d51e9f1430ac66d823d58ecb0c3e Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Thu, 24 Jan 2008 19:14:49 +0100 Subject: [PATCH] stop waiting for events in queue --- awesome.c | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/awesome.c b/awesome.c index 0c8f79cba..6acb7c89a 100644 --- a/awesome.c +++ b/awesome.c @@ -389,31 +389,40 @@ main(int argc, char *argv[]) buf[r] = '\0'; parse_control(buf); } - + /* two level XPending: + * we need to first check we have XEvent to handle + * and if so, we handle them all in a round. + * Then when we have refresh()'ed stuff so maybe new XEvent + * are available and select() won't tell us, so let's check + * with XPending() again. + */ while(XPending(dpy)) { - XNextEvent(dpy, &ev); - if(handler[ev.type]) - handler[ev.type](&ev); /* call handler */ - - /* drop events requested to */ - if(globalconf.drop_events) + while(XPending(dpy)) { + XNextEvent(dpy, &ev); + if(handler[ev.type]) + handler[ev.type](&ev); /* call handler */ + + /* drop events requested to */ + if(globalconf.drop_events) + { + /* need to resync */ + XSync(dpy, False); + while(XCheckMaskEvent(dpy, globalconf.drop_events, &ev)); + globalconf.drop_events = NoEventMask; + } + /* need to resync */ XSync(dpy, False); - while(XCheckMaskEvent(dpy, globalconf.drop_events, &ev)); - globalconf.drop_events = NoEventMask; } - + + statusbar_refresh(); + layout_refresh(); + /* need to resync */ XSync(dpy, False); } - - statusbar_refresh(); - layout_refresh(); - - /* need to resync */ - XSync(dpy, False); } if(csfd > 0 && close(csfd))