Skip to contentSkip to conversation

xentop.c: Change curses painting behavior to avoid flicker

PATCH Applied Jason McCarver 3 participants 6 messages Jul 4, 2012 – Sep 14, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xentop.c: Change curses painting behavior to avoid flicker

Currently, xentop calls clear() before drawing the screen and calling refresh(). This causes the entire screen to be repainted from scratch on each call to refresh(). It is inefficient and causes visible flicker when using xentop.

This patch fixes this by calling erase() instead of clear() which overwrites the current screen with blanks instead. The screen is then drawn as usual in the top() function and refresh() is called. This method allows curses to only repaint the characters that have changed since the last call to refresh(), thus avoiding the flicker and sending fewer characters to the terminal.

In the event the screen becomes corrupted, this patch accepts a CTRL-L keystroke from the user which will call clear() and force a repaint of the entire screen.

tools/xenstat/xentop/xentop.c +5 -1
diff -r 42f76d536b11 -r b1bf5533d565 tools/xenstat/xentop/xentop.c
@@ -57,6 +57,7 @@
 #endif
 
 #define KEY_ESCAPE '\x1B'
+#define KEY_REPAINT '\x0C'
 
 #ifdef HOST_SunOS
 /* Old curses library on Solaris takes non-const strings. Also, ERR interferes
@@ -383,6 +384,9 @@ static int handle_key(int ch)
 		case 'd': case 'D':
 			set_prompt("Delay(sec)", set_delay);
 			break;
+		case KEY_REPAINT:
+			clear();
+			break;
 		case 'q': case 'Q': case KEY_ESCAPE:
 			return 0;
 		}
@@ -1201,7 +1205,7 @@ int main(int argc, char **argv)
 		do {
 			gettimeofday(&curtime, NULL);
 			if(ch != ERR || (curtime.tv_sec - oldtime.tv_sec) >= delay) {
-				clear();
+				erase();
 				top();
 				oldtime = curtime;
 				refresh();
Acked-by on v1 1/1
#1 lore raw

Jason McCarver writes ("[PATCH] xentop.c: Change curses painting behavior to avoid flicker"):

Quoted 12 lines

Currently, xentop calls clear() before drawing the screen and calling refresh(). This causes the entire screen to be repainted from scratch on each call to refresh(). It is inefficient and causes visible flicker when using xentop.

This patch fixes this by calling erase() instead of clear() which overwrites the current screen with blanks instead. The screen is then drawn as usual in the top() function and refresh() is called. This method allows curses to only repaint the characters that have changed since the last call to refresh(), thus avoiding the flicker and sending fewer characters to the terminal.

Quoted 5 lines

In the event the screen becomes corrupted, this patch accepts a CTRL-L keystroke from the user which will call clear() and force a repaint of the entire screen.

However, I think this needs to wait for Xen 4.3. We are currently in the freeze for the 4.2 release.

Ian.

author
#2 lore raw
Quoted 17 lines · On Tue, 17 Jul 2012 14:24:22 +0100 Ian Jackson <[email protected]>…

Jason McCarver writes ("[PATCH] xentop.c: Change curses painting behavior to avoid flicker"):

Quoted 16 lines

Currently, xentop calls clear() before drawing the screen and calling refresh(). This causes the entire screen to be repainted from scratch on each call to refresh(). It is inefficient and causes visible flicker when using xentop.

This patch fixes this by calling erase() instead of clear() which overwrites the current screen with blanks instead. The screen is then drawn as usual in the top() function and refresh() is called. This method allows curses to only repaint the characters that have changed since the last call to refresh(), thus avoiding the flicker and sending fewer characters to the terminal.

In the event the screen becomes corrupted, this patch accepts a CTRL-L keystroke from the user which will call clear() and force a repaint of the entire screen.

Quoted 8 lines
Quoted 1 line

However, I think this needs to wait for Xen 4.3. We are currently in the freeze for the 4.2 release.

Ian.

I apologize in advance for the newb questions. Is there anything I need to do to help this patch make it into 4.3? Will I need to re-post it to the list again at a later date, or is my first post of this sufficient assuming the patch remains unchanged?

Jason

#3 lore raw
Quoted 27 lines · slam
Quoted 24 lines · On Tue, 17 Jul 2012 14:24:22 +0100 Ian Jackson <[email protected]>…

Jason McCarver writes ("[PATCH] xentop.c: Change curses painting behavior to avoid flicker"):

Quoted 12 lines

Currently, xentop calls clear() before drawing the screen and calling refresh(). This causes the entire screen to be repainted from scratch on each call to refresh(). It is inefficient and causes visible flicker when using xentop.

This patch fixes this by calling erase() instead of clear() which overwrites the current screen with blanks instead. The screen is then drawn as usual in the top() function and refresh() is called. This method allows curses to only repaint the characters that have changed since the last call to refresh(), thus avoiding the flicker and sending fewer characters to the terminal.

Quoted 5 lines

In the event the screen becomes corrupted, this patch accepts a CTRL-L keystroke from the user which will call clear() and force a repaint of the entire screen.

However, I think this needs to wait for Xen 4.3. We are currently in the freeze for the 4.2 release.

Quoted 6 lines
Quoted 1 line

Ian.

I apologize in advance for the newb questions. Is there anything I need to do to help this patch make it into 4.3? Will I need to re-post it to the list again at a later date, or is my first post of this sufficient assuming the patch remains unchanged?

I'd recommend reposting once 4.3 opens just to remind us.

Ian.

#4 lore raw
In reply to slam

slam writes ("Re: [PATCH] xentop.c: Change curses painting behavior to avoid flicker"):

Quoted 4 lines

I apologize in advance for the newb questions. Is there anything I need to do to help this patch make it into 4.3? Will I need to re-post it to the list again at a later date, or is my first post of this sufficient assuming the patch remains unchanged?

No need to apologise. In theory I'd hope we remember this but in practice we don't have any formal tracking.

So if you can, please do repost this after 4.2 is released.

Thanks,
Ian.

Applied
#5 lore raw
Quoted 10 lines · Ian Jackson

slam writes ("Re: [PATCH] xentop.c: Change curses painting behavior to avoid flicker"):

Quoted 4 lines

I apologize in advance for the newb questions. Is there anything I need to do to help this patch make it into 4.3? Will I need to re-post it to the list again at a later date, or is my first post of this sufficient assuming the patch remains unchanged?

No need to apologise. In theory I'd hope we remember this but in practice we don't have any formal tracking.

So if you can, please do repost this after 4.2 is released.

I've applied this to unstable (aka 4.3-pre) now.

Ian.