|
|
@ -3166,12 +3166,12 @@ void
|
|
|
|
run(void) {
|
|
|
|
run(void) {
|
|
|
|
XEvent ev;
|
|
|
|
XEvent ev;
|
|
|
|
fd_set rfd;
|
|
|
|
fd_set rfd;
|
|
|
|
int xfd = XConnectionNumber(xw.dpy);
|
|
|
|
int xfd = XConnectionNumber(xw.dpy), xev;
|
|
|
|
struct timeval drawtimeout, *tv = NULL, now, last;
|
|
|
|
struct timeval drawtimeout, *tv = NULL, now, last;
|
|
|
|
|
|
|
|
|
|
|
|
gettimeofday(&last, NULL);
|
|
|
|
gettimeofday(&last, NULL);
|
|
|
|
|
|
|
|
|
|
|
|
for(;;) {
|
|
|
|
for(xev = actionfps;;) {
|
|
|
|
FD_ZERO(&rfd);
|
|
|
|
FD_ZERO(&rfd);
|
|
|
|
FD_SET(cmdfd, &rfd);
|
|
|
|
FD_SET(cmdfd, &rfd);
|
|
|
|
FD_SET(xfd, &rfd);
|
|
|
|
FD_SET(xfd, &rfd);
|
|
|
@ -3184,22 +3184,16 @@ run(void) {
|
|
|
|
gettimeofday(&now, NULL);
|
|
|
|
gettimeofday(&now, NULL);
|
|
|
|
/* usecs until (next) frame */
|
|
|
|
/* usecs until (next) frame */
|
|
|
|
drawtimeout.tv_sec = 0;
|
|
|
|
drawtimeout.tv_sec = 0;
|
|
|
|
drawtimeout.tv_usec = \
|
|
|
|
drawtimeout.tv_usec = (1000/xfps) * 1000;
|
|
|
|
((1000/framespersecond) - TIMEDIFF(now, last)) * 1000;
|
|
|
|
tv = &drawtimeout;
|
|
|
|
|
|
|
|
|
|
|
|
/* Let us draw a frame. */
|
|
|
|
|
|
|
|
if(drawtimeout.tv_usec <= 0) {
|
|
|
|
|
|
|
|
draw();
|
|
|
|
|
|
|
|
XFlush(xw.dpy);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
last = now;
|
|
|
|
|
|
|
|
tv = NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(FD_ISSET(cmdfd, &rfd))
|
|
|
|
if(FD_ISSET(cmdfd, &rfd))
|
|
|
|
ttyread();
|
|
|
|
ttyread();
|
|
|
|
|
|
|
|
|
|
|
|
if(FD_ISSET(xfd, &rfd)) {
|
|
|
|
if(FD_ISSET(xfd, &rfd))
|
|
|
|
|
|
|
|
xev = actionfps;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(TIMEDIFF(now, last) > (xev ? (1000/xfps) : (1000/actionfps))) {
|
|
|
|
while(XPending(xw.dpy)) {
|
|
|
|
while(XPending(xw.dpy)) {
|
|
|
|
XNextEvent(xw.dpy, &ev);
|
|
|
|
XNextEvent(xw.dpy, &ev);
|
|
|
|
if(XFilterEvent(&ev, None))
|
|
|
|
if(XFilterEvent(&ev, None))
|
|
|
@ -3208,16 +3202,14 @@ run(void) {
|
|
|
|
(handler[ev.type])(&ev);
|
|
|
|
(handler[ev.type])(&ev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(drawtimeout.tv_usec <= 0) {
|
|
|
|
|
|
|
|
draw();
|
|
|
|
draw();
|
|
|
|
XFlush(xw.dpy);
|
|
|
|
XFlush(xw.dpy);
|
|
|
|
}
|
|
|
|
last = now;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* There is still some time to wait until next frame. */
|
|
|
|
if(xev && !FD_ISSET(xfd, &rfd))
|
|
|
|
if(drawtimeout.tv_usec > 0) {
|
|
|
|
xev--;
|
|
|
|
tv = &drawtimeout;
|
|
|
|
if(!FD_ISSET(cmdfd, &rfd) && !FD_ISSET(xfd, &rfd))
|
|
|
|
continue;
|
|
|
|
tv = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|