From e83409b6d77a24b75e9d1d2f69ad96bc1c3d83f2 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Mon, 30 Jan 2017 22:06:13 +0300 Subject: [PATCH] Ticket #3766: add_widget_autopos() doesn't remove focus from the previously focused widget. Signed-off-by: Andrew Borodin --- lib/widget/dialog.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/widget/dialog.c b/lib/widget/dialog.c index 6dc625252..e9cc87418 100644 --- a/lib/widget/dialog.c +++ b/lib/widget/dialog.c @@ -845,6 +845,7 @@ add_widget_autopos (WDialog * h, void *w, widget_pos_flags_t pos_flags, const vo { Widget *wh = WIDGET (h); Widget *widget; + GList *new_current; /* Don't accept 0 widgets */ if (w == NULL) @@ -867,7 +868,7 @@ add_widget_autopos (WDialog * h, void *w, widget_pos_flags_t pos_flags, const vo if (h->widgets == NULL || before == NULL) { h->widgets = g_list_append (h->widgets, widget); - h->current = g_list_last (h->widgets); + new_current = g_list_last (h->widgets); } else { @@ -882,17 +883,19 @@ add_widget_autopos (WDialog * h, void *w, widget_pos_flags_t pos_flags, const vo b = g_list_next (b); h->widgets = g_list_insert_before (h->widgets, b, widget); if (b != NULL) - h->current = g_list_previous (b); + new_current = g_list_previous (b); else - h->current = g_list_last (h->widgets); + new_current = g_list_last (h->widgets); } - /* widget has been added in runtime */ + /* widget has been added at runtime */ if (widget_get_state (wh, WST_ACTIVE)) { send_message (widget, NULL, MSG_INIT, 0, NULL); - widget_set_state (widget, WST_FOCUSED, TRUE); + widget_select (widget); } + else + h->current = new_current; return widget->id; }