[hackers] [st] Preliminary solution to the stuttering problem. || Christoph Lohmann
changeset: 308:482dc875b32c
tag: tip
user: Christoph Lohmann <20h_AT_r-36.net>
date: Sun Sep 16 13:22:23 2012 +0200
files: st.c
description:
Preliminary solution to the stuttering problem.
diff -r 159fbfc2e12f -r 482dc875b32c st.c
--- a/st.c Sun Sep 16 10:49:12 2012 +0200
+++ b/st.c Sun Sep 16 13:22:23 2012 +0200
_AT_@ -48,7 +48,7 @@
#define ESC_ARG_SIZ 16
#define STR_BUF_SIZ 256
#define STR_ARG_SIZ 16
-#define DRAW_BUF_SIZ 1024
+#define DRAW_BUF_SIZ 20*1024
#define UTF_SIZ 4
#define XK_NO_MOD UINT_MAX
#define XK_ANY_MOD 0
_AT_@ -2329,7 +2329,8 @@
run(void) {
XEvent ev;
fd_set rfd;
- int xfd = XConnectionNumber(xw.dpy);
+ int xfd = XConnectionNumber(xw.dpy), i;
+ struct timeval drawtimeout;
for(;;) {
FD_ZERO(&rfd);
_AT_@ -2340,9 +2341,29 @@
continue;
die("select failed: %s\n", SERRNO);
}
- if(FD_ISSET(cmdfd, &rfd))
+
+ /*
+ * Stop after a certain number of reads so the user does not
+ * feel like the system is stuttering.
+ */
+ for(i = 0; i < 1000 && FD_ISSET(cmdfd, &rfd); i++) {
ttyread();
+ FD_ZERO(&rfd);
+ FD_SET(cmdfd, &rfd);
+ /*
+ * Just wait a bit so it isn't disturbing the
+ * user and the system is able to write something.
+ */
+ drawtimeout.tv_sec = 0;
+ drawtimeout.tv_usec = 5;
+ if(select(cmdfd+1, &rfd, NULL, NULL, &drawtimeout) < 0) {
+ if(errno == EINTR)
+ continue;
+ die("select failed: %s\n", SERRNO);
+ }
+ }
+
while(XPending(xw.dpy)) {
XNextEvent(xw.dpy, &ev);
if(XFilterEvent(&ev, xw.win))
Received on Sun Sep 16 2012 - 13:24:31 CEST
This archive was generated by hypermail 2.3.0
: Sun Sep 16 2012 - 13:36:05 CEST