]> git.ozlabs.org Git - petitboot/commitdiff
ui/ncurses: Properly set focus when updating subset
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>
Wed, 13 Jul 2016 06:43:22 +0000 (16:43 +1000)
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>
Wed, 13 Jul 2016 06:50:30 +0000 (16:50 +1000)
When a subset widget is made empty focus is switched to the first
visible field. It should actually be set to the first visible and active
field, otherwise we can try to focus an un-selectable label.

While we're here, also properly set the visibility for the autoboot
enable/disable widget.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
ui/ncurses/nc-config.c
ui/ncurses/nc-widgets.c

index 24aac2b6e8d6f7fc61e2e271104e9802b9225e6d..10d7eb6b49f84e2450f5d8e520468132cf816d90 100644 (file)
@@ -411,6 +411,7 @@ static void config_screen_layout_widgets(struct config_screen *screen)
        widget_move(wl, y, screen->label_x);
 
        wf = widget_select_base(screen->widgets.autoboot_f);
+       widget_set_visible(wf, true);
        widget_move(wf, y, screen->field_x);
        y += widget_height(wf);
 
index 50909ab6c4af459261cb681995ff4bfe35f1ee35..8f8816ecaa7c472b33fe9c52d0e0305556b6c621 100644 (file)
@@ -466,6 +466,7 @@ static void subset_delete_active(struct nc_widget_subset *subset, int idx)
        struct nc_widget *widget;
        size_t rem;
        int i, val;
+       uint32_t opts;
 
        /* Shift field focus to nearest active option or next visible field */
        if (subset->n_active > 1) {
@@ -477,8 +478,11 @@ static void subset_delete_active(struct nc_widget_subset *subset, int idx)
        } else {
                for (i = 0; i < set->n_fields; i++)
                        if (field_visible(set->fields[i])) {
-                               set->cur_field = set->fields[i];
-                               break;
+                               opts = field_opts(set->fields[i]);
+                               if ((opts & O_ACTIVE) == O_ACTIVE) {
+                                       set->cur_field = set->fields[i];
+                                       break;
+                               }
                        }
        }