]> git.ozlabs.org Git - petitboot/blobdiff - ui/ncurses/nc-config.c
ui/ncurses: Allow text wrapping in select widgets
[petitboot] / ui / ncurses / nc-config.c
index 17cc380172cb15394fb0b3bb73b84cfd270d8d4d..2750bbb7719189de934b9716e5eb952d7d09e06c 100644 (file)
 #include "nc-config.h"
 #include "nc-widgets.h"
 
-#define N_FIELDS       26
+#define N_FIELDS       34
 
 extern struct help_text config_help_text;
 
-enum autoboot_type {
-       AUTOBOOT_ANY,
-       AUTOBOOT_ONE,
-       AUTOBOOT_DISABLED,
-};
-
 enum net_conf_type {
        NET_CONF_TYPE_DHCP_ALL,
        NET_CONF_TYPE_DHCP_ONE,
@@ -57,6 +51,10 @@ struct config_screen {
 
        bool                    exit;
        bool                    show_help;
+       bool                    show_subset;
+       bool                    need_redraw;
+       bool                    need_update;
+
        void                    (*on_exit)(struct cui *);
 
        int                     scroll_y;
@@ -66,16 +64,25 @@ struct config_screen {
        int                     network_config_y;
 
        enum net_conf_type      net_conf_type;
-       enum autoboot_type      autoboot_type;
+
+       bool                    autoboot_enabled;
+       bool                    ipmi_override;
 
        struct {
-               struct nc_widget_select         *autoboot_f;
-               struct nc_widget_label          *autoboot_l;
-               struct nc_widget_select         *boot_device_f;
+               struct nc_widget_label          *boot_order_l;
+               struct nc_widget_subset         *boot_order_f;
+               struct nc_widget_label          *boot_empty_l;
+               struct nc_widget_button         *boot_add_b;
+               struct nc_widget_button         *boot_none_b;
+               struct nc_widget_button         *boot_any_b;
                struct nc_widget_textbox        *timeout_f;
                struct nc_widget_label          *timeout_l;
                struct nc_widget_label          *timeout_help_l;
 
+               struct nc_widget_label          *ipmi_type_l;
+               struct nc_widget_label          *ipmi_clear_l;
+               struct nc_widget_checkbox       *ipmi_clear_cb;
+
                struct nc_widget_label          *network_l;
                struct nc_widget_select         *network_f;
 
@@ -94,6 +101,9 @@ struct config_screen {
                struct nc_widget_label          *dns_dhcp_help_l;
                struct nc_widget_label          *dns_help_l;
 
+               struct nc_widget_label          *allow_write_l;
+               struct nc_widget_select         *allow_write_f;
+
                struct nc_widget_label          *safe_mode;
                struct nc_widget_button         *ok_b;
                struct nc_widget_button         *help_b;
@@ -146,10 +156,11 @@ static void config_screen_process_key(struct nc_scr *scr, int key)
 
        } else if (screen->show_help) {
                screen->show_help = false;
+               screen->need_redraw = true;
                cui_show_help(screen->cui, _("System Configuration"),
                                &config_help_text);
 
-       } else if (handled) {
+       } else if (handled && !screen->show_subset) {
                pad_refresh(screen);
        }
 }
@@ -160,17 +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);
-       widgetset_post(screen->widgetset);
-       nc_scr_frame_draw(scr);
-       redrawwin(scr->main_ncw);
-       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);
@@ -188,40 +188,49 @@ static int screen_process_form(struct config_screen *screen)
        const struct system_info *sysinfo = screen->cui->sysinfo;
        enum net_conf_type net_conf_type;
        struct interface_config *iface;
-       char *str, *end, *uuid;
+       char *str, *end;
        struct config *config;
-       int rc, idx;
+       int i, n_boot_opts, rc, idx;
+       unsigned int *order;
+       bool allow_write;
+       char mac[20];
 
        config = config_copy(screen, screen->cui->config);
 
-       screen->autoboot_type =
-               widget_select_get_value(screen->widgets.autoboot_f);
-
-       config->autoboot_enabled = screen->autoboot_type != AUTOBOOT_DISABLED;
-
-       uuid = NULL;
-       if (screen->autoboot_type == AUTOBOOT_ONE) {
-               char mac[20];
-
-               /* if idx is -1 here, we have an unknown UUID selected.
-                * Otherwise, it's a blockdev index (idx <= n_blockdevs) or an
-                * interface index.
-                */
-               idx = widget_select_get_value(screen->widgets.boot_device_f);
-               if (idx >= (int)sysinfo->n_blockdevs) {
-                       struct interface_info *info = sysinfo->
-                               interfaces[idx - sysinfo->n_blockdevs];
-                       mac_str(info->hwaddr, info->hwaddr_size,
-                                       mac, sizeof(mac));
-                       uuid = mac;
-               } else if (idx != -1) {
-                       uuid = sysinfo->blockdevs[idx]->uuid;
+       talloc_free(config->autoboot_opts);
+       config->n_autoboot_opts = 0;
+
+       n_boot_opts = widget_subset_get_order(config, &order,
+                                             screen->widgets.boot_order_f);
+
+       config->autoboot_enabled = n_boot_opts > 0;
+
+       config->n_autoboot_opts = n_boot_opts;
+       config->autoboot_opts = talloc_array(config, struct autoboot_option,
+                                            n_boot_opts);
+
+       for (i = 0; i < n_boot_opts; i++) {
+               if (order[i] < sysinfo->n_blockdevs) {
+                       /* disk uuid */
+                       config->autoboot_opts[i].boot_type = BOOT_DEVICE_UUID;
+                       config->autoboot_opts[i].uuid = talloc_strdup(config,
+                                                       sysinfo->blockdevs[order[i]]->uuid);
+               } else if(order[i] < (sysinfo->n_blockdevs + sysinfo->n_interfaces)) {
+                       /* net uuid */
+                       order[i] -= sysinfo->n_blockdevs;
+                       config->autoboot_opts[i].boot_type = BOOT_DEVICE_UUID;
+                       mac_str(sysinfo->interfaces[order[i]]->hwaddr,
+                               sysinfo->interfaces[order[i]]->hwaddr_size,
+                               mac, sizeof(mac));
+                       config->autoboot_opts[i].uuid = talloc_strdup(config, mac);
+               } else {
+                       /* device type */
+                       order[i] -= (sysinfo->n_blockdevs + sysinfo->n_interfaces);
+                       config->autoboot_opts[i].boot_type = BOOT_DEVICE_TYPE;
+                       config->autoboot_opts[i].type = order[i];
                }
        }
 
-       talloc_free(config->boot_device);
-       config->boot_device = uuid ? talloc_strdup(config, uuid) : NULL;
-
        str = widget_textbox_get_value(screen->widgets.timeout_f);
        if (str) {
                unsigned long x;
@@ -231,6 +240,11 @@ static int screen_process_form(struct config_screen *screen)
                        config->autoboot_timeout_sec = x;
        }
 
+       if (screen->ipmi_override)
+               if (widget_checkbox_get_value(screen->widgets.ipmi_clear_cb))
+                       config->ipmi_bootdev = IPMI_BOOTDEV_INVALID;
+
+
        net_conf_type = widget_select_get_value(screen->widgets.network_f);
 
        /* if we don't have any network interfaces, prevent per-interface
@@ -307,6 +321,10 @@ static int screen_process_form(struct config_screen *screen)
                }
        }
 
+       allow_write = widget_select_get_value(screen->widgets.allow_write_f);
+       if (allow_write != config->allow_writes)
+               config->allow_writes = allow_write;
+
        config->safe_mode = false;
        rc = cui_send_config(screen->cui, config);
        talloc_free(config);
@@ -359,40 +377,78 @@ static void config_screen_layout_widgets(struct config_screen *screen)
        bool show;
 
        y = 1;
+       /* currently, the longest label we have is the DNS-servers
+        * widget, so layout our screen based on that */
        help_x = screen->field_x + 2 +
                widget_width(widget_textbox_base(screen->widgets.dns_f));
 
-       y += layout_pair(screen, y, screen->widgets.autoboot_l,
-                       widget_select_base(screen->widgets.autoboot_f));
+       wl = widget_label_base(screen->widgets.boot_order_l);
+       widget_set_visible(wl, true);
+       widget_move(wl, y, screen->label_x);
+
+       wf = widget_subset_base(screen->widgets.boot_order_f);
+       widget_move(wf, y, screen->field_x);
+       wl = widget_label_base(screen->widgets.boot_empty_l);
+       widget_move(wl, y, screen->field_x);
 
-       wf = widget_select_base(screen->widgets.boot_device_f);
-       if (screen->autoboot_type == AUTOBOOT_ONE) {
+       if (widget_subset_height(screen->widgets.boot_order_f)) {
                widget_set_visible(wf, true);
-               widget_move(wf, y, screen->field_x + 3);
+               widget_set_visible(wl, false);
                y += widget_height(wf);
        } else {
+               widget_set_visible(wl, true);
                widget_set_visible(wf, false);
+               y += 1;
        }
 
        y += 1;
 
+       widget_move(widget_button_base(screen->widgets.boot_add_b),
+                       y++, screen->field_x);
+       widget_move(widget_button_base(screen->widgets.boot_any_b),
+                       y++, screen->field_x);
+       widget_move(widget_button_base(screen->widgets.boot_none_b),
+                       y, screen->field_x);
+
+       wf = widget_button_base(screen->widgets.boot_add_b);
+       if (widget_subset_n_inactive(screen->widgets.boot_order_f))
+               widget_set_visible(wf, true);
+       else
+               widget_set_visible(wf, false);
+
+       y += 2;
+
        wf = widget_textbox_base(screen->widgets.timeout_f);
        wl = widget_label_base(screen->widgets.timeout_l);
        wh = widget_label_base(screen->widgets.timeout_help_l);
-       if (screen->autoboot_type != AUTOBOOT_DISABLED) {
-               widget_set_visible(wl, true);
-               widget_set_visible(wf, true);
-               widget_set_visible(wh, true);
+       widget_set_visible(wl, screen->autoboot_enabled);
+       widget_set_visible(wf, screen->autoboot_enabled);
+       widget_set_visible(wh, screen->autoboot_enabled);
+       if (screen->autoboot_enabled) {
+               widget_set_visible(wh, screen->autoboot_enabled);
                widget_move(wl, y, screen->label_x);
                widget_move(wf, y, screen->field_x);
                widget_move(wh, y, screen->field_x + widget_width(wf) + 1);
                y += 2;
-       } else {
-               widget_set_visible(wl, false);
-               widget_set_visible(wf, false);
-               widget_set_visible(wh, false);
        }
 
+       if (screen->ipmi_override) {
+               wl = widget_label_base(screen->widgets.ipmi_type_l);
+               widget_set_visible(wl, true);
+               widget_move(wl, y, screen->label_x);
+               y += 1;
+
+               wl = widget_label_base(screen->widgets.ipmi_clear_l);
+               wf = widget_checkbox_base(screen->widgets.ipmi_clear_cb);
+               widget_set_visible(wl, true);
+               widget_set_visible(wf, true);
+               widget_move(wl, y, screen->label_x);
+               widget_move(wf, y, screen->field_x);
+               y += 1;
+       }
+
+       y += 1;
+
        y += layout_pair(screen, y, screen->widgets.network_l,
                        widget_select_base(screen->widgets.network_f));
 
@@ -478,12 +534,18 @@ static void config_screen_layout_widgets(struct config_screen *screen)
                y += 1;
        }
 
+       layout_pair(screen, y, screen->widgets.allow_write_l,
+                   widget_select_base(screen->widgets.allow_write_f));
+       y += widget_height(widget_select_base(screen->widgets.allow_write_f));
+
+       y += 1;
+
        widget_move(widget_button_base(screen->widgets.ok_b),
                        y, screen->field_x);
        widget_move(widget_button_base(screen->widgets.help_b),
-                       y, screen->field_x + 10);
+                       y, screen->field_x + 14);
        widget_move(widget_button_base(screen->widgets.cancel_b),
-                       y, screen->field_x + 24);
+                       y, screen->field_x + 28);
 }
 
 static void config_screen_network_change(void *arg, int value)
@@ -495,15 +557,69 @@ static void config_screen_network_change(void *arg, int value)
        widgetset_post(screen->widgetset);
 }
 
-static void config_screen_autoboot_change(void *arg, int value)
+static void config_screen_boot_order_change(void *arg, int value)
+{
+       (void)value;
+       struct config_screen *screen = arg;
+       widgetset_unpost(screen->widgetset);
+       config_screen_layout_widgets(screen);
+       widgetset_post(screen->widgetset);
+}
+
+static void config_screen_add_device(void *arg)
+{
+       struct config_screen *screen = arg;
+
+       screen->show_subset = true;
+       cui_show_subset(screen->cui, _("Select a boot device to add"),
+                       screen->widgets.boot_order_f);
+}
+
+static void config_screen_autoboot_none(void *arg)
+{
+       struct config_screen *screen = arg;
+       struct nc_widget_subset *subset = screen->widgets.boot_order_f;
+
+       widget_subset_clear_active(subset);
+       screen->autoboot_enabled = false;
+
+       widgetset_unpost(screen->widgetset);
+       config_screen_layout_widgets(screen);
+       widgetset_post(screen->widgetset);
+}
+
+static void config_screen_autoboot_any(void *arg)
 {
        struct config_screen *screen = arg;
-       screen->autoboot_type = value;
+       const struct system_info *sysinfo = screen->cui->sysinfo;
+       struct nc_widget_subset *subset = screen->widgets.boot_order_f;
+       int idx;
+
+       widget_subset_clear_active(subset);
+
+       idx = sysinfo->n_blockdevs + sysinfo->n_interfaces + DEVICE_TYPE_ANY;
+
+       widget_subset_make_active(screen->widgets.boot_order_f, idx);
+
+       screen->autoboot_enabled = true;
+
        widgetset_unpost(screen->widgetset);
        config_screen_layout_widgets(screen);
        widgetset_post(screen->widgetset);
 }
 
+static void config_screen_update_subset(void *arg,
+                       struct nc_widget_subset *subset, int idx)
+{
+       struct config_screen *screen = arg;
+
+       if (idx >= 0)
+               widget_subset_make_active(subset, idx);
+       if (!screen->autoboot_enabled)
+               screen->autoboot_enabled = true;
+       config_screen_layout_widgets(screen);
+}
+
 static struct interface_config *first_active_interface(
                const struct config *config)
 {
@@ -545,6 +661,31 @@ static void config_screen_setup_empty(struct config_screen *screen)
                        cancel_click, screen);
 }
 
+static int find_autoboot_idx(const struct system_info *sysinfo,
+               struct autoboot_option *opt)
+{
+       unsigned int i;
+
+       if (opt->boot_type == BOOT_DEVICE_TYPE)
+               return sysinfo->n_blockdevs + sysinfo->n_interfaces + opt->type;
+
+       for (i = 0; i < sysinfo->n_blockdevs; i++) {
+               if (!strcmp(sysinfo->blockdevs[i]->uuid, opt->uuid))
+                       return i;
+       }
+
+       for (i = 0; i < sysinfo->n_interfaces; i++) {
+               struct interface_info *info = sysinfo->interfaces[i];
+               char mac[20];
+
+               mac_str(info->hwaddr, info->hwaddr_size, mac, sizeof(mac));
+
+               if (!strcmp(mac, opt->uuid))
+                       return sysinfo->n_blockdevs + i;
+       }
+
+       return -1;
+}
 
 static void config_screen_setup_widgets(struct config_screen *screen,
                const struct config *config,
@@ -555,7 +696,7 @@ static void config_screen_setup_widgets(struct config_screen *screen,
        char *str, *ip, *mask, *gw;
        enum net_conf_type type;
        unsigned int i;
-       bool found;
+       int add_len, clear_len, any_len, min_len = 20;
 
        build_assert(sizeof(screen->widgets) / sizeof(struct widget *)
                        == N_FIELDS);
@@ -563,81 +704,88 @@ static void config_screen_setup_widgets(struct config_screen *screen,
        type = screen->net_conf_type;
        ifcfg = first_active_interface(config);
 
-       screen->widgets.autoboot_l = widget_new_label(set, 0, 0,
-                                       _("Autoboot:"));
-       screen->widgets.autoboot_f = widget_new_select(set, 0, 0, 55);
-
-       widget_select_on_change(screen->widgets.autoboot_f,
-                       config_screen_autoboot_change, screen);
-
-       screen->widgets.boot_device_f = widget_new_select(set, 0, 0, 55);
-
-       widget_select_add_option(screen->widgets.autoboot_f,
-                                       AUTOBOOT_DISABLED,
-                                       _("Don't autoboot"),
-                                       screen->autoboot_type ==
-                                               AUTOBOOT_DISABLED);
-       widget_select_add_option(screen->widgets.autoboot_f,
-                                       AUTOBOOT_ANY,
-                                       _("Autoboot from any "
-                                               "disk/network device"),
-                                       screen->autoboot_type ==
-                                               AUTOBOOT_ANY);
-       widget_select_add_option(screen->widgets.autoboot_f,
-                                       AUTOBOOT_ONE,
-                                       _("Only autoboot from a specific "
-                                               "disk/network device"),
-                                       screen->autoboot_type ==
-                                               AUTOBOOT_ONE);
-
-       found = false;
+       add_len = max(min_len, strncols(_("Add Device")));
+       clear_len = max(min_len, strncols(_("Clear")));
+       any_len = max(min_len, strncols(_("Clear & Boot Any")));
+
+       screen->widgets.boot_add_b = widget_new_button(set, 0, 0, add_len,
+                                       _("Add Device"),
+                                       config_screen_add_device, screen);
+
+       screen->widgets.boot_none_b = widget_new_button(set, 0, 0, clear_len,
+                                       _("Clear"),
+                                       config_screen_autoboot_none, screen);
+
+       screen->widgets.boot_any_b = widget_new_button(set, 0, 0, any_len,
+                                       _("Clear & Boot Any"),
+                                       config_screen_autoboot_any, screen);
+
+       screen->widgets.boot_order_l = widget_new_label(set, 0, 0,
+                                       _("Boot Order:"));
+       screen->widgets.boot_order_f = widget_new_subset(set, 0, 0,
+                                       COLS - screen->field_x,
+                                       config_screen_update_subset);
+       screen->widgets.boot_empty_l = widget_new_label(set, 0, 0,
+                                       _("(None)"));
+
+       widget_subset_on_change(screen->widgets.boot_order_f,
+                       config_screen_boot_order_change, screen);
 
        for (i = 0; i < sysinfo->n_blockdevs; i++) {
                struct blockdev_info *bd = sysinfo->blockdevs[i];
-               bool selected;
                char *label;
 
-               selected = config->boot_device &&
-                               !strcmp(config->boot_device, bd->uuid);
-               if (selected)
-                       found = true;
-
                label = talloc_asprintf(screen, _("disk: %s [uuid: %s]"),
                                bd->name, bd->uuid);
 
-               widget_select_add_option(screen->widgets.boot_device_f, i,
-                                       label, selected);
+               widget_subset_add_option(screen->widgets.boot_order_f, label);
        }
 
        for (i = 0; i < sysinfo->n_interfaces; i++) {
                struct interface_info *info = sysinfo->interfaces[i];
                char *label, mac[20];
-               bool selected;
 
                mac_str(info->hwaddr, info->hwaddr_size, mac, sizeof(mac));
-               selected = config->boot_device &&
-                               !strcmp(config->boot_device, mac);
-               if (selected)
-                       found = true;
 
                label = talloc_asprintf(screen, _("net:  %s [mac: %s]"),
                                info->name, mac);
 
-               widget_select_add_option(screen->widgets.boot_device_f,
-                                               i + sysinfo->n_blockdevs,
-                                               label, selected);
+               widget_subset_add_option(screen->widgets.boot_order_f, label);
        }
 
-       if (screen->autoboot_type == AUTOBOOT_ONE && !found) {
+       for (i = DEVICE_TYPE_NETWORK; i < DEVICE_TYPE_UNKNOWN; i++) {
                char *label;
 
-               label = talloc_asprintf(screen, _("Unknown UUID: %s"),
-                               config->boot_device);
+               if (i == DEVICE_TYPE_ANY)
+                       label = talloc_asprintf(screen, _("Any Device"));
+               else
+                       label = talloc_asprintf(screen, _("Any %s device"),
+                                               device_type_display_name(i));
 
-               widget_select_add_option(screen->widgets.boot_device_f, -1,
-                                               label, true);
+               widget_subset_add_option(screen->widgets.boot_order_f, label);
        }
 
+       screen->autoboot_enabled = config->n_autoboot_opts;
+       for (i = 0; i < config->n_autoboot_opts; i++) {
+               struct autoboot_option *opt = &config->autoboot_opts[i];
+               int idx;
+
+               idx = find_autoboot_idx(sysinfo, opt);
+
+               if (idx >= 0) {
+                       widget_subset_make_active(screen->widgets.boot_order_f,
+                                                 idx);
+               } else {
+                       if (opt->boot_type == BOOT_DEVICE_TYPE)
+                               pb_log("%s: Unknown autoboot option: %d\n",
+                                      __func__, opt->type);
+                       else
+                               pb_log("%s: Unknown autoboot UUID: %s\n",
+                                      __func__, opt->uuid);
+               }
+       }
+
+
        str = talloc_asprintf(screen, "%d", config->autoboot_timeout_sec);
        screen->widgets.timeout_l = widget_new_label(set, 0, 0, _("Timeout:"));
        screen->widgets.timeout_f = widget_new_textbox(set, 0, 0, 5, str);
@@ -647,8 +795,24 @@ static void config_screen_setup_widgets(struct config_screen *screen,
        widget_textbox_set_fixed_size(screen->widgets.timeout_f);
        widget_textbox_set_validator_integer(screen->widgets.timeout_f, 0, 999);
 
+       if (config->ipmi_bootdev) {
+               char *label = talloc_asprintf(screen,
+                               _("%s IPMI boot option: %s"),
+                               config->ipmi_bootdev_persistent ?
+                               "Persistent" : "Temporary",
+                               ipmi_bootdev_display_name(config->ipmi_bootdev));
+               screen->widgets.ipmi_type_l = widget_new_label(set, 0, 0,
+                                                       label);
+               screen->widgets.ipmi_clear_l = widget_new_label(set, 0, 0,
+                                                       _("Clear option:"));
+               screen->widgets.ipmi_clear_cb = widget_new_checkbox(set, 0, 0,
+                                                       false);
+               screen->ipmi_override = true;
+       }
+
        screen->widgets.network_l = widget_new_label(set, 0, 0, _("Network:"));
-       screen->widgets.network_f = widget_new_select(set, 0, 0, 50);
+       screen->widgets.network_f = widget_new_select(set, 0, 0,
+                                               COLS - screen->field_x - 1);
 
        widget_select_add_option(screen->widgets.network_f,
                                        NET_CONF_TYPE_DHCP_ALL,
@@ -742,7 +906,20 @@ static void config_screen_setup_widgets(struct config_screen *screen,
                screen->widgets.safe_mode = widget_new_label(set, 0, 0,
                         _("Selecting 'OK' will exit safe mode"));
 
-       screen->widgets.ok_b = widget_new_button(set, 0, 0, 6, _("OK"),
+       screen->widgets.allow_write_l = widget_new_label(set, 0, 0,
+                       _("Disk R/W:"));
+       screen->widgets.allow_write_f = widget_new_select(set, 0, 0,
+                                               COLS - screen->field_x - 1);
+
+       widget_select_add_option(screen->widgets.allow_write_f, 0,
+                               _("Prevent all writes to disk"),
+                               !config->allow_writes);
+
+       widget_select_add_option(screen->widgets.allow_write_f, 1,
+                               _("Allow bootloader scripts to modify disks"),
+                               config->allow_writes);
+
+       screen->widgets.ok_b = widget_new_button(set, 0, 0, 10, _("OK"),
                        ok_click, screen);
        screen->widgets.help_b = widget_new_button(set, 0, 0, 10, _("Help"),
                        help_click, screen);
@@ -813,12 +990,6 @@ static void config_screen_draw(struct config_screen *screen,
                config_screen_setup_empty(screen);
        } else {
                screen->net_conf_type = find_net_conf_type(config);
-               if (!config->autoboot_enabled)
-                       screen->autoboot_type = AUTOBOOT_DISABLED;
-               else
-                       screen->autoboot_type = config->boot_device ?
-                                       AUTOBOOT_ONE : AUTOBOOT_ANY;
-
                config_screen_setup_widgets(screen, config, sysinfo);
                config_screen_layout_widgets(screen);
        }
@@ -831,10 +1002,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;
@@ -859,9 +1058,14 @@ 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;
 
+       screen->ipmi_override = false;
+       screen->show_subset = false;
+
        screen->scr.frame.ltitle = talloc_strdup(screen,
                        _("Petitboot System Configuration"));
        screen->scr.frame.rtitle = NULL;