From 45b4cdee1966c5638edbe4e35b143ee50ff50dbb Mon Sep 17 00:00:00 2001 From: Marcel Hollerbach Date: Mon, 16 Oct 2017 09:55:53 +0200 Subject: [PATCH] efl_ui_focus_manager_calc: maintain focus when focused element is unregistered this should fix T6216. --- src/lib/elementary/efl_ui_focus_manager_calc.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/lib/elementary/efl_ui_focus_manager_calc.c b/src/lib/elementary/efl_ui_focus_manager_calc.c index 5295934..88cdcf7 100644 --- a/src/lib/elementary/efl_ui_focus_manager_calc.c +++ b/src/lib/elementary/efl_ui_focus_manager_calc.c @@ -784,6 +784,7 @@ EOLIAN static void _efl_ui_focus_manager_calc_unregister(Eo *obj EINA_UNUSED, Efl_Ui_Focus_Manager_Calc_Data *pd, Efl_Ui_Focus_Object *child) { Node *node; + Eina_Bool refocus = EINA_FALSE; node = eina_hash_find(pd->node_hash, &child); @@ -791,6 +792,13 @@ _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) + { + //unfocus the current head + efl_ui_focus_object_focus_set(child, EINA_FALSE); + refocus = EINA_TRUE; + } + //remove the object from the stack if it hasn't done that until now //after this it's not at the top anymore @@ -798,6 +806,13 @@ _efl_ui_focus_manager_calc_unregister(Eo *obj EINA_UNUSED, Efl_Ui_Focus_Manager_ //delete again from the list, for the case it was not at the top pd->focus_stack = eina_list_remove(pd->focus_stack, node); + if (refocus) + { + Node *n = eina_list_last_data_get(pd->focus_stack); + if (n) + efl_ui_focus_object_focus_set(n->focusable, EINA_TRUE); + } + //add all neighbors of the node to the dirty list for(int i = EFL_UI_FOCUS_DIRECTION_UP; i < NODE_DIRECTIONS_COUNT; i++) { -- 2.7.4