From f21cf89a2fbe156a8ac3d33ecd481eb34bb2db28 Mon Sep 17 00:00:00 2001 From: Marcel Hollerbach Date: Thu, 9 Aug 2018 10:50:44 +0200 Subject: [PATCH] efl_ui_focus_manager_calc: fix unregistering the root of a redirect There is often a tree of elements registered in a manager that are having all the same redirect element. Unserting the redirect property just because the node has this redirect element is not helpfull as this would break basically elm_tests button search. However, if it is the container itself, then the redirect can be unset, as nothing else can ever reach again the redirect manager. ref D6800 Differential Revision: https://phab.enlightenment.org/D6802 --- .../elementary/efl_ui_focus_manager_calc.c | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/lib/elementary/efl_ui_focus_manager_calc.c b/src/lib/elementary/efl_ui_focus_manager_calc.c index 1c17863c59..fb44889662 100644 --- a/src/lib/elementary/efl_ui_focus_manager_calc.c +++ b/src/lib/elementary/efl_ui_focus_manager_calc.c @@ -739,18 +739,28 @@ _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 && !pd->redirect) + if (eina_list_last_data_get(pd->focus_stack) == node) { if (!efl_invalidated_get(pd->root->focusable)) { - Node *n; + Node *n = NULL; - n = eina_list_nth(pd->focus_stack, eina_list_count(pd->focus_stack) - 2); + // if there is no redirect manager, then try to recover the focus property to a different element + //allow the removal of the redirect when we are removing the child that is the redirect manager + if (!pd->redirect || pd->redirect == child) + { + n = eina_list_nth(pd->focus_stack, eina_list_count(pd->focus_stack) - 2); + if (!n) + n = _request_subchild_except(pd->root, node); + + if (n) + efl_ui_focus_manager_focus_set(obj, n->focusable); + } + // if there is a redirect manager, then remove the flag from the child if (!n) - n = _request_subchild_except(pd->root, node); - - if (n) - efl_ui_focus_manager_focus_set(obj, n->focusable); + { + efl_ui_focus_object_focus_set(child, EINA_FALSE); + } } }