JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
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)
commitc5a9b799d44be9c0fa4264dc34d9dd61321be795
tree327a0f3e907db5dee0c7a678c5c701bc202e59fe
parent85849ce72aa4e9cee307a031b97777e9eba2d453
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