Xinqi Bao's Git
projects
/
st.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
Applying a shortening proposal for the run loop of k0ga.
[st.git]
/
st.c
diff --git
a/st.c
b/st.c
index
da6f17e
..
d5ecf61
100644
(file)
--- a/
st.c
+++ b/
st.c
@@
-2319,8
+2319,7
@@
resize(XEvent *e) {
row = (xw.h - 2*BORDER) / xw.ch;
if(col == term.col && row == term.row)
return;
row = (xw.h - 2*BORDER) / xw.ch;
if(col == term.col && row == term.row)
return;
- if(tresize(col, row))
- draw();
+ tresize(col, row);
xresize(col, row);
ttyresize(col, row);
}
xresize(col, row);
ttyresize(col, row);
}
@@
-2330,13
+2329,13
@@
run(void) {
XEvent ev;
fd_set rfd;
int xfd = XConnectionNumber(xw.dpy), i;
XEvent ev;
fd_set rfd;
int xfd = XConnectionNumber(xw.dpy), i;
- struct timeval drawtimeout;
+ struct timeval drawtimeout
, *tv = NULL
;
- for(
;;
) {
+ for(
i = 0;; i++
) {
FD_ZERO(&rfd);
FD_SET(cmdfd, &rfd);
FD_SET(xfd, &rfd);
FD_ZERO(&rfd);
FD_SET(cmdfd, &rfd);
FD_SET(xfd, &rfd);
- if(select(MAX(xfd, cmdfd)+1, &rfd, NULL, NULL,
NULL
) < 0) {
+ if(select(MAX(xfd, cmdfd)+1, &rfd, NULL, NULL,
tv
) < 0) {
if(errno == EINTR)
continue;
die("select failed: %s\n", SERRNO);
if(errno == EINTR)
continue;
die("select failed: %s\n", SERRNO);
@@
-2346,23
+2345,20
@@
run(void) {
* Stop after a certain number of reads so the user does not
* feel like the system is stuttering.
*/
* 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++
) {
+
if(i < 1000 && FD_ISSET(cmdfd, &rfd)
) {
ttyread();
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;
/*
* 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);
- }
+ tv = &drawtimeout;
+ continue;
}
}
+ i = 0;
+ tv = NULL;
while(XPending(xw.dpy)) {
XNextEvent(xw.dpy, &ev);
while(XPending(xw.dpy)) {
XNextEvent(xw.dpy, &ev);