aboutsummaryrefslogtreecommitdiff
path: root/config.def.h
diff options
context:
space:
mode:
authorAvi Halachmi (:avih) <avihpit@yahoo.com>2019-02-26 22:37:49 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2020-05-09 13:53:50 +0200
commit1d590910652519268152eae6b97cf30ace4e90c0 (patch)
treeaec0e38e3864e42409023f75be2aa148b0fe1a80 /config.def.h
parentd6ea0a1a61853dd892029a7126e7fdb70c371878 (diff)
downloadst-1d590910652519268152eae6b97cf30ace4e90c0.tar.gz
st-1d590910652519268152eae6b97cf30ace4e90c0.tar.bz2
auto-sync: draw on idle to avoid flicker/tearing
st could easily tear/flicker with animation or other unattended output. This commit eliminates most of the tear/flicker. Before this commit, the display timing had two "modes": - Interactively, st was waiting fixed `1000/xfps` ms after forwarding the kb/mouse event to the application and before drawing. - Unattended, and specifically with animations, the draw frequency was throttled to `actionfps`. Animation at a higher rate would throttle and likely tear, and at lower rates it was tearing big frames (specifically, when one `read` didn't get a full "frame"). The interactive behavior was decent, but it was impossible to get good unattended-draw behavior even with carefully chosen configuration. This commit changes the behavior such that it draws on idle instead of using fixed latency/frequency. This means that it tries to draw only when it's very likely that the application has completed its output (or after some duration without idle), so it mostly succeeds to avoid tear, flicker, and partial drawing. The config values minlatency/maxlatency replace xfps/actionfps and define the range which the algorithm is allowed to wait from the initial draw-trigger until the actual draw. The range enables the flexibility to choose when to draw - when least likely to flicker. It also unifies the interactive and unattended behavior and config values, which makes the code simpler as well - without sacrificing latency during interactive use, because typically interactively idle arrives very quickly, so the wait is typically minlatency. While it only slighly improves interactive behavior, for animations and other unattended-drawing it improves greatly, as it effectively adapts to any [animation] output rate without tearing, throttling, redundant drawing, or unnecessary delays (sounds impossible, but it works).
Diffstat (limited to 'config.def.h')
-rw-r--r--config.def.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/config.def.h b/config.def.h
index 0895a1f..fdbacfd 100644
--- a/config.def.h
+++ b/config.def.h
@@ -43,9 +43,14 @@ static unsigned int tripleclicktimeout = 600;
/* alt screens */
int allowaltscreen = 1;
-/* frames per second st should at maximum draw to the screen */
-static unsigned int xfps = 120;
-static unsigned int actionfps = 30;
+/*
+ * draw latency range in ms - from new content/keypress/etc until drawing.
+ * within this range, st draws when content stops arriving (idle). mostly it's
+ * near minlatency, but it waits longer for slow updates to avoid partial draw.
+ * low minlatency will tear/flicker more, as it can "detect" idle too early.
+ */
+static double minlatency = 8;
+static double maxlatency = 33;
/*
* blinking timeout (set to 0 to disable blinking) for the terminal blinking