Merge branch '3766_add_widget_autopos'

* 3766_add_widget_autopos:
  Ticket #3766: add_widget_autopos() doesn't remove focus from the previously focused widget.
This commit is contained in:
Mooffie 2017-02-09 18:00:43 +02:00
commit 25b4096ace

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 *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;
}