comparison main.c @ 64:46d44d185464

removed a bottleneck
author Anselm R. Garbe <garbeam@wmii.de>
date Fri, 14 Jul 2006 13:27:01 +0200
parents db93644de522
children 4f7b232bd72d
comparison
equal deleted inserted replaced
63:f14858218641 64:46d44d185464
281 281
282 /* main event loop, reads status text from stdin as well */ 282 /* main event loop, reads status text from stdin as well */
283 Mainloop: 283 Mainloop:
284 while(running) { 284 while(running) {
285 FD_ZERO(&rd); 285 FD_ZERO(&rd);
286 FD_SET(0, &rd); 286 FD_SET(STDIN_FILENO, &rd);
287 FD_SET(ConnectionNumber(dpy), &rd); 287 FD_SET(ConnectionNumber(dpy), &rd);
288 288
289 i = select(ConnectionNumber(dpy) + 1, &rd, 0, 0, 0); 289 i = select(ConnectionNumber(dpy) + 1, &rd, 0, 0, 0);
290 if(i == -1 && errno == EINTR) 290 if(i == -1 && errno == EINTR)
291 continue; 291 continue;
292 if(i < 0) 292 if(i < 0)
293 error("select failed\n"); 293 error("select failed\n");
294 else if(i > 0) { 294 else if(i > 0) {
295 if(FD_ISSET(ConnectionNumber(dpy), &rd) && XPending(dpy) > 0) { 295 if(FD_ISSET(ConnectionNumber(dpy), &rd)) {
296 XNextEvent(dpy, &ev); 296 while(XPending(dpy)) {
297 if(handler[ev.type]) 297 XNextEvent(dpy, &ev);
298 (handler[ev.type])(&ev); /* call handler */ 298 if(handler[ev.type])
299 (handler[ev.type])(&ev); /* call handler */
300 }
299 } 301 }
300 if(FD_ISSET(0, &rd)) { 302 if(FD_ISSET(STDIN_FILENO, &rd)) {
301 i = n = 0; 303 i = n = 0;
302 for(;;) { 304 for(;;) {
303 if((i = getchar()) == EOF) { 305 if((i = getchar()) == EOF) {
304 stext[0] = 0; 306 stext[0] = 0;
305 goto Mainloop; 307 goto Mainloop;