summaryrefslogtreecommitdiffstats
path: root/ui/ncurses/nc-config.c
diff options
context:
space:
mode:
authorSamuel Mendoza-Jonas <sam.mj@au1.ibm.com>2015-09-02 15:43:39 +1000
committerSamuel Mendoza-Jonas <sam.mj@au1.ibm.com>2015-09-07 16:55:52 +1000
commit9384b0ab3b9bec1744c19c64ac5431db99110b04 (patch)
treeb5fed2d89b6a3cc20a10e9cbc007913dae09b1e8 /ui/ncurses/nc-config.c
parent72148c718113a17d80fd1da3c8dd82b471bed07a (diff)
downloadtalos-petitboot-9384b0ab3b9bec1744c19c64ac5431db99110b04.tar.gz
talos-petitboot-9384b0ab3b9bec1744c19c64ac5431db99110b04.zip
ui/ncurses: Improve update handling in nested screens
Several screens in petitboot-nc require an update if a config or sysinfo update is received. However if those screens exist but are not the current screen they will incorrectly try to draw to the screen. Where the currently active screen is a textscreen (eg. a help screen) the update is delayed until after the screen is exited. In the particular case of nc-config where the current screen can be an nc-subset screen, the nc-subset screen is exited immediately so the update can be performed, since the nc-subset screen depends on the information in the previous screen. Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
Diffstat (limited to 'ui/ncurses/nc-config.c')
-rw-r--r--ui/ncurses/nc-config.c45
1 files changed, 30 insertions, 15 deletions
diff --git a/ui/ncurses/nc-config.c b/ui/ncurses/nc-config.c
index b257076..7c02250 100644
--- a/ui/ncurses/nc-config.c
+++ b/ui/ncurses/nc-config.c
@@ -53,6 +53,7 @@ struct config_screen {
bool show_help;
bool show_subset;
bool need_redraw;
+ bool need_update;
void (*on_exit)(struct cui *);
@@ -170,21 +171,6 @@ static void config_screen_resize(struct nc_scr *scr)
(void)screen;
}
-static int config_screen_post(struct nc_scr *scr)
-{
- struct config_screen *screen = config_screen_from_scr(scr);
- screen->show_subset = false;
- widgetset_post(screen->widgetset);
- nc_scr_frame_draw(scr);
- if (screen->need_redraw) {
- redrawwin(scr->main_ncw);
- screen->need_redraw = false;
- }
- wrefresh(screen->scr.main_ncw);
- pad_refresh(screen);
- return 0;
-}
-
static int config_screen_unpost(struct nc_scr *scr)
{
struct config_screen *screen = config_screen_from_scr(scr);
@@ -1014,10 +1000,38 @@ void config_screen_update(struct config_screen *screen,
const struct config *config,
const struct system_info *sysinfo)
{
+ if (screen->cui->current != config_screen_scr(screen)) {
+ screen->need_update = true;
+ return;
+ }
+
config_screen_draw(screen, config, sysinfo);
pad_refresh(screen);
}
+static int config_screen_post(struct nc_scr *scr)
+{
+ struct config_screen *screen = config_screen_from_scr(scr);
+ screen->show_subset = false;
+
+ if (screen->need_update) {
+ config_screen_draw(screen, screen->cui->config,
+ screen->cui->sysinfo);
+ screen->need_update = false;
+ } else {
+ widgetset_post(screen->widgetset);
+ }
+
+ nc_scr_frame_draw(scr);
+ if (screen->need_redraw) {
+ redrawwin(scr->main_ncw);
+ screen->need_redraw = false;
+ }
+ wrefresh(screen->scr.main_ncw);
+ pad_refresh(screen);
+ return 0;
+}
+
static int config_screen_destroy(void *arg)
{
struct config_screen *screen = arg;
@@ -1043,6 +1057,7 @@ struct config_screen *config_screen_init(struct cui *cui,
screen->cui = cui;
screen->on_exit = on_exit;
screen->need_redraw = false;
+ screen->need_update = false;
screen->label_x = 2;
screen->field_x = 17;
OpenPOWER on IntegriCloud