efl_ui_focus_manager_calc: do not restore focus when redirect is set

When there is a redirect there is no need to adjust the focus property
based on a unregister, so just continue and cleanup the history. When
the redirect is unset the focus is restored.

fix T6908
This commit is contained in:
Marcel Hollerbach 2018-05-06 18:14:11 +02:00
parent 790b17673f
commit fa9aff8f70
2 changed files with 36 additions and 1 deletions

View File

@ -733,7 +733,7 @@ _efl_ui_focus_manager_calc_unregister(Eo *obj EINA_UNUSED, Efl_Ui_Focus_Manager_
F_DBG("Manager: %p unregister %p", obj, child);
if (eina_list_last_data_get(pd->focus_stack) == node)
if (eina_list_last_data_get(pd->focus_stack) == node && !pd->redirect)
{
if (!efl_invalidated_get(pd->root->focusable))
{

View File

@ -930,6 +930,40 @@ EFL_START_TEST(test_request_move)
}
EFL_END_TEST
EFL_START_TEST(redirect_unregister_entrypoint)
{
Efl_Ui_Focus_Manager *m, *m2;
TEST_OBJ_NEW(root, 0, 20, 20, 20);
TEST_OBJ_NEW(root2, 0, 20, 20, 20);
TEST_OBJ_NEW(child, 0, 20, 20, 20);
TEST_OBJ_NEW(child2, 0, 20, 20, 20);
TEST_OBJ_NEW(child3, 0, 20, 20, 20);
m = efl_add(EFL_UI_FOCUS_MANAGER_CALC_CLASS, efl_main_loop_get(),
efl_ui_focus_manager_root_set(efl_added, root)
);
m2 = efl_add(EFL_UI_FOCUS_MANAGER_CALC_CLASS, efl_main_loop_get(),
efl_ui_focus_manager_root_set(efl_added, root2)
);
efl_ui_focus_manager_calc_register(m2, child3, root2, m2);
efl_ui_focus_manager_calc_register(m, child, root, m2);
efl_ui_focus_manager_calc_register(m, child2, root, NULL);
efl_ui_focus_manager_focus_set(m, child);
ck_assert_ptr_eq(efl_ui_focus_manager_redirect_get(m), m2);
efl_ui_focus_manager_calc_unregister(m, child);
ck_assert_ptr_eq(efl_ui_focus_manager_redirect_get(m), m2);
ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), NULL);
efl_del(m);
efl_del(m2);
}
EFL_END_TEST
void elm_test_focus(TCase *tc)
{
@ -960,4 +994,5 @@ void elm_test_focus(TCase *tc)
tcase_add_test(tc, test_unregister_last_focused_no_child);
tcase_add_test(tc, test_pop_history_element);
tcase_add_test(tc, test_request_move);
tcase_add_test(tc, redirect_unregister_entrypoint);
}