Increment accuaracy in drawtime calculation
[st.git] / st.c
diff --git a/st.c b/st.c
index d22c605..dcb80ca 100644 (file)
--- a/st.c
+++ b/st.c
@@ -673,7 +673,8 @@ y2row(int y) {
        return LIMIT(y, 0, term.row-1);
 }
 
-int tlinelen(int y) {
+int
+tlinelen(int y) {
        int i = term.col;
 
        if(term.line[y][i - 1].mode & ATTR_WRAP)
@@ -3991,7 +3992,7 @@ run(void) {
 
                clock_gettime(CLOCK_MONOTONIC, &now);
                drawtimeout.tv_sec = 0;
-               drawtimeout.tv_nsec = (1000/xfps) * 1E6;
+               drawtimeout.tv_nsec =  (1000 * 1E6)/ xfps;
                tv = &drawtimeout;
 
                dodraw = 0;
@@ -4002,8 +4003,7 @@ run(void) {
                        dodraw = 1;
                }
                deltatime = TIMEDIFF(now, last);
-               if(deltatime > (xev? (1000/xfps) : (1000/actionfps))
-                               || deltatime < 0) {
+               if(deltatime > 1000 / (xev ? xfps : actionfps)) {
                        dodraw = 1;
                        last = now;
                }