aboutsummaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
Diffstat (limited to 'st.c')
-rw-r--r--st.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/st.c b/st.c
index 12d6665..da6f17e 100644
--- a/st.c
+++ b/st.c
@@ -48,7 +48,7 @@
48#define ESC_ARG_SIZ 16 48#define ESC_ARG_SIZ 16
49#define STR_BUF_SIZ 256 49#define STR_BUF_SIZ 256
50#define STR_ARG_SIZ 16 50#define STR_ARG_SIZ 16
51#define DRAW_BUF_SIZ 1024 51#define DRAW_BUF_SIZ 20*1024
52#define UTF_SIZ 4 52#define UTF_SIZ 4
53#define XK_NO_MOD UINT_MAX 53#define XK_NO_MOD UINT_MAX
54#define XK_ANY_MOD 0 54#define XK_ANY_MOD 0
@@ -2329,7 +2329,8 @@ void
2329run(void) { 2329run(void) {
2330 XEvent ev; 2330 XEvent ev;
2331 fd_set rfd; 2331 fd_set rfd;
2332 int xfd = XConnectionNumber(xw.dpy); 2332 int xfd = XConnectionNumber(xw.dpy), i;
2333 struct timeval drawtimeout;
2333 2334
2334 for(;;) { 2335 for(;;) {
2335 FD_ZERO(&rfd); 2336 FD_ZERO(&rfd);
@@ -2340,9 +2341,29 @@ run(void) {
2340 continue; 2341 continue;
2341 die("select failed: %s\n", SERRNO); 2342 die("select failed: %s\n", SERRNO);
2342 } 2343 }
2343 if(FD_ISSET(cmdfd, &rfd)) 2344
2345 /*
2346 * Stop after a certain number of reads so the user does not
2347 * feel like the system is stuttering.
2348 */
2349 for(i = 0; i < 1000 && FD_ISSET(cmdfd, &rfd); i++) {
2344 ttyread(); 2350 ttyread();
2345 2351
2352 FD_ZERO(&rfd);
2353 FD_SET(cmdfd, &rfd);
2354 /*
2355 * Just wait a bit so it isn't disturbing the
2356 * user and the system is able to write something.
2357 */
2358 drawtimeout.tv_sec = 0;
2359 drawtimeout.tv_usec = 5;
2360 if(select(cmdfd+1, &rfd, NULL, NULL, &drawtimeout) < 0) {
2361 if(errno == EINTR)
2362 continue;
2363 die("select failed: %s\n", SERRNO);
2364 }
2365 }
2366
2346 while(XPending(xw.dpy)) { 2367 while(XPending(xw.dpy)) {
2347 XNextEvent(xw.dpy, &ev); 2368 XNextEvent(xw.dpy, &ev);
2348 if(XFilterEvent(&ev, xw.win)) 2369 if(XFilterEvent(&ev, xw.win))