removed a bottleneck 6475be92
Anselm R. Garbe · 2006-07-14 13:27 1 file(s) · +8 −6
main.c +8 −6
283 283
Mainloop:
284 284
	while(running) {
285 285
		FD_ZERO(&rd);
286 -
		FD_SET(0, &rd);
286 +
		FD_SET(STDIN_FILENO, &rd);
287 287
		FD_SET(ConnectionNumber(dpy), &rd);
288 288
289 289
		i = select(ConnectionNumber(dpy) + 1, &rd, 0, 0, 0);
292 292
		if(i < 0)
293 293
			error("select failed\n");
294 294
		else if(i > 0) {
295 -
			if(FD_ISSET(ConnectionNumber(dpy), &rd) && XPending(dpy) > 0) {
296 -
				XNextEvent(dpy, &ev);
297 -
				if(handler[ev.type])
298 -
					(handler[ev.type])(&ev); /* call handler */
295 +
			if(FD_ISSET(ConnectionNumber(dpy), &rd)) {
296 +
				while(XPending(dpy)) {
297 +
					XNextEvent(dpy, &ev);
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 303
				i = n = 0;
302 304
				for(;;) {
303 305
					if((i = getchar()) == EOF) {