From f26be579fe5843ef5a234394e9d08f1ec423e8e1 Mon Sep 17 00:00:00 2001
From: Andrew Borodin <aborodin@vmail.ru>
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 <aborodin@vmail.ru>
---
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 6dc6252..75f91ba 100644
a
|
b
|
add_widget_autopos (WDialog * h, void *w, widget_pos_flags_t pos_flags, const vo |
845 | 845 | { |
846 | 846 | Widget *wh = WIDGET (h); |
847 | 847 | Widget *widget; |
| 848 | GList *current; |
848 | 849 | |
849 | 850 | /* Don't accept 0 widgets */ |
850 | 851 | if (w == NULL) |
… |
… |
add_widget_autopos (WDialog * h, void *w, widget_pos_flags_t pos_flags, const vo |
867 | 868 | if (h->widgets == NULL || before == NULL) |
868 | 869 | { |
869 | 870 | h->widgets = g_list_append (h->widgets, widget); |
870 | | h->current = g_list_last (h->widgets); |
| 871 | current = g_list_last (h->widgets); |
871 | 872 | } |
872 | 873 | else |
873 | 874 | { |
… |
… |
add_widget_autopos (WDialog * h, void *w, widget_pos_flags_t pos_flags, const vo |
882 | 883 | b = g_list_next (b); |
883 | 884 | h->widgets = g_list_insert_before (h->widgets, b, widget); |
884 | 885 | if (b != NULL) |
885 | | h->current = g_list_previous (b); |
| 886 | current = g_list_previous (b); |
886 | 887 | else |
887 | | h->current = g_list_last (h->widgets); |
| 888 | current = g_list_last (h->widgets); |
888 | 889 | } |
889 | 890 | |
890 | | /* widget has been added in runtime */ |
| 891 | /* widget has been added at runtime */ |
891 | 892 | if (widget_get_state (wh, WST_ACTIVE)) |
892 | 893 | { |
893 | 894 | send_message (widget, NULL, MSG_INIT, 0, NULL); |
894 | | widget_set_state (widget, WST_FOCUSED, TRUE); |
| 895 | widget_select (widget); |
895 | 896 | } |
| 897 | else |
| 898 | h->current = current; |
896 | 899 | |
897 | 900 | return widget->id; |
898 | 901 | } |