[PATCH] ui/ncurses: Periodically refresh display
Samuel Mendoza-Jonas
sam at mendozajonas.com
Tue Jul 11 15:19:08 AEST 2017
When connecting to IPMI or serial consoles quite often the user must hit
a key or exit and restart petitboot-nc to cause it to appear. This
occurs when the user connects after petitboot-nc has drawn the current
screen. This can be a little confusing to users, especially in text
screens where keys such as 'Enter' won't have an affect.
To add some user friendliness create a timer callback that every five
seconds re-draws the current screen automatically.
Signed-off-by: Samuel Mendoza-Jonas <sam at mendozajonas.com>
---
ui/ncurses/nc-cui.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/ui/ncurses/nc-cui.c b/ui/ncurses/nc-cui.c
index fbc02b9..6332585 100644
--- a/ui/ncurses/nc-cui.c
+++ b/ui/ncurses/nc-cui.c
@@ -499,6 +499,25 @@ static int cui_process_js(void *arg)
return 0;
}
+/*
+ * Refresh the current screen. This helps in cases where the user connects to a
+ * serial interface after the screen has already been drawn.
+ * Five seconds is a nice compromise between not having the user wait too long
+ * and over-stressing certain OEM's terrible IPMI implementations.
+ */
+static int cui_refresh_timeout(void *arg)
+{
+ struct cui *cui = cui_from_arg(arg);
+
+ nc_scr_unpost(cui->current);
+ nc_scr_post(cui->current);
+ redrawwin(cui->current->main_ncw);
+
+ waiter_register_timeout(cui->waitset, 5000, cui_refresh_timeout, cui);
+
+ return 0;
+}
+
/**
* cui_handle_resize - Handle the term resize.
*/
@@ -1104,6 +1123,8 @@ retry_start:
waiter_register_io(cui->waitset, STDIN_FILENO, WAIT_IN,
cui_process_key, cui);
+ waiter_register_timeout(cui->waitset, 5000, cui_refresh_timeout, cui);
+
if (js_map) {
cui->pjs = pjs_init(cui, js_map);
--
2.13.2
More information about the Petitboot
mailing list