]> Sergey Matveev's repositories - st.git/commit
Render only once in each main loop iteration
authorRoberto E. Vargas Caballero <k0ga@shike2.com>
Sun, 16 Sep 2012 08:48:38 +0000 (10:48 +0200)
committerRoberto E. Vargas Caballero <k0ga@shike2.com>
Sun, 16 Sep 2012 08:48:38 +0000 (10:48 +0200)
commitc624bb570317bd93dadc8f9914e013ef94e27156
tree327a0f3e907db5dee0c7a678c5c701bc202e59fe
parentf3704e65537f0e86b9bcfbe998e6a82a1a59e611
Render only once in each main loop iteration
draw() runs over all lines of the screen and renders only the dirty lines,
this avoids render lines which are not modified since last draw() call. In
this moment the main loop is something like:

     - Wait something to read from file descriptors
     - Read from pseudo tty
     - Call draw() for rending
     - Read X events

This cause the problem that all the X events that have to update the screen
have to call draw() (because draw() is called before of X events handling),
so you can have multiples renderings in only one iteration, that will waste
a lot of resources.

This patch change the main loop to:

     - Wait something to read from file descriptors
     - Read from pseudo tty
     - Read X events
     - Call draw() for rending

So X events don't have to worry about rendering, because draw() is called
after them.

The only place where draw is called outside of the main loop is in redraw(),
but it is necessary for getting a good tput flash.
---
 st.c |   29 ++++++-----------------------
 1 file changed, 6 insertions(+), 23 deletions(-)
st.c