aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2018-08-09 10:38:27 +0200
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2018-08-14 15:00:58 +0200
commit92bb03d7f582e2f4ee7ffd767d2c3f63386df388 (patch)
tree8913a92076caef4db04db30563ff6aeab63d55c2
parentefl-cxx: Add -Wno-shadow to disable huge warnings in C++ (diff)
downloadefl-92bb03d7f582e2f4ee7ffd767d2c3f63386df388.tar.gz
efl_ui_focus_manager: adjust pop history pop
It now searches for a element if the focus stack is empty. Differential Revision: https://phab.enlightenment.org/D6801
-rw-r--r--src/lib/elementary/efl_ui_focus_manager.eo5
-rw-r--r--src/lib/elementary/efl_ui_focus_manager_calc.c37
-rw-r--r--src/tests/elementary/elm_test_focus.c2
3 files changed, 36 insertions, 8 deletions
diff --git a/src/lib/elementary/efl_ui_focus_manager.eo b/src/lib/elementary/efl_ui_focus_manager.eo
index e5e91f3519..8b63d5bc1f 100644
--- a/src/lib/elementary/efl_ui_focus_manager.eo
+++ b/src/lib/elementary/efl_ui_focus_manager.eo
@@ -146,7 +146,10 @@ interface Efl.Ui.Focus.Manager {
]]
}
pop_history_stack {
- [[Removes the most upper history element, and gives the focus to the next one below]]
+ [[Removes the most upper history element, and move focus on.
+
+ If there is a element that was focused before, it will be taken. Otherwise, the best fitting element from the registered elements will be focused.
+ ]]
}
setup_on_first_touch {
[[Called when this manager is set as redirect]]
diff --git a/src/lib/elementary/efl_ui_focus_manager_calc.c b/src/lib/elementary/efl_ui_focus_manager_calc.c
index 076874f354..1c17863c59 100644
--- a/src/lib/elementary/efl_ui_focus_manager_calc.c
+++ b/src/lib/elementary/efl_ui_focus_manager_calc.c
@@ -1682,15 +1682,40 @@ EOLIAN static void
_efl_ui_focus_manager_calc_efl_ui_focus_manager_pop_history_stack(Eo *obj EINA_UNUSED, Efl_Ui_Focus_Manager_Calc_Data *pd)
{
Efl_Ui_Focus_Object *last_focusable;
- Node *last;
+ Node *last = NULL;
- if (!pd->focus_stack) return;
+ if (pd->redirect)
+ {
+ Eina_List *n;
- last_focusable = _focus_stack_unfocus_last(pd);
+ last_focusable = pd->redirect_entry;
+ n = eina_list_last(pd->focus_stack);
+
+ while (n && (eina_list_data_get(n) != last_focusable))
+ {
+ n = eina_list_prev(n);
+ }
+
+ last = eina_list_data_get(n);
+ }
+ else
+ {
+ last_focusable = _focus_stack_unfocus_last(pd);
+ //get now the highest, and unfocus that!
+ last = eina_list_last_data_get(pd->focus_stack);
+ }
+
+ if (last)
+ {
+ efl_ui_focus_object_focus_set(last->focusable, EINA_TRUE);
+ }
+ else
+ {
+ last = _request_subchild_except(pd->root, node_get(obj, pd, last_focusable));
+ if (last)
+ efl_ui_focus_manager_focus_set(obj, last->focusable);
+ }
- //get now the highest, and unfocus that!
- last = eina_list_last_data_get(pd->focus_stack);
- if (last) efl_ui_focus_object_focus_set(last->focusable, EINA_TRUE);
efl_event_callback_call(obj, EFL_UI_FOCUS_MANAGER_EVENT_FOCUSED, last_focusable);
}
diff --git a/src/tests/elementary/elm_test_focus.c b/src/tests/elementary/elm_test_focus.c
index 7c1d032c5f..24dd048167 100644
--- a/src/tests/elementary/elm_test_focus.c
+++ b/src/tests/elementary/elm_test_focus.c
@@ -864,7 +864,7 @@ EFL_START_TEST(test_pop_history_element)
ck_assert_int_eq(efl_ui_focus_object_focus_get(c2), EINA_TRUE);
efl_ui_focus_manager_pop_history_stack(m);
- ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), NULL);
+ ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), c1);
ck_assert_int_eq(efl_ui_focus_object_focus_get(c2), EINA_FALSE);
efl_ui_focus_manager_focus_set(m, c1);