Ticket #3766: add_widget_autopos() doesn't remove focus from the previously focused widget.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2017-01-30 22:06:13 +03:00 committed by Mooffie
parent b39c1b9446
commit e83409b6d7

View File

@ -845,6 +845,7 @@ add_widget_autopos (WDialog * h, void *w, widget_pos_flags_t pos_flags, const vo
{ {
Widget *wh = WIDGET (h); Widget *wh = WIDGET (h);
Widget *widget; Widget *widget;
GList *new_current;
/* Don't accept 0 widgets */ /* Don't accept 0 widgets */
if (w == NULL) 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) if (h->widgets == NULL || before == NULL)
{ {
h->widgets = g_list_append (h->widgets, widget); h->widgets = g_list_append (h->widgets, widget);
h->current = g_list_last (h->widgets); new_current = g_list_last (h->widgets);
} }
else 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); b = g_list_next (b);
h->widgets = g_list_insert_before (h->widgets, b, widget); h->widgets = g_list_insert_before (h->widgets, b, widget);
if (b != NULL) if (b != NULL)
h->current = g_list_previous (b); new_current = g_list_previous (b);
else 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)) if (widget_get_state (wh, WST_ACTIVE))
{ {
send_message (widget, NULL, MSG_INIT, 0, NULL); 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; return widget->id;
} }