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
This commit is contained in:
Marcel Hollerbach 2018-08-09 10:38:27 +02:00
parent 65c6b158f9
commit 92bb03d7f5
3 changed files with 36 additions and 8 deletions

View File

@ -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]]

View File

@ -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);
}

View File

@ -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);