From 912dfe270ea57721ee0e091c3a30ee9e5d53a6dc Mon Sep 17 00:00:00 2001 From: Marcel Hollerbach Date: Tue, 6 Aug 2019 10:52:32 -0400 Subject: efl_ui_focus_manager_root_focus: perform focus switch delayed Summary: Delaying the unregistering here ensures that there is not focus set call while a object is beeing registered in the focus manager. ref T8081 Reviewers: zmike, cedric Reviewed By: zmike Subscribers: #reviewers, #committers Tags: #efl Maniphest Tasks: T8081 Differential Revision: https://phab.enlightenment.org/D9513 --- .../elementary/efl_ui_focus_manager_root_focus.c | 24 ++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/lib/elementary/efl_ui_focus_manager_root_focus.c b/src/lib/elementary/efl_ui_focus_manager_root_focus.c index f47fe3d3fe..29507001fb 100644 --- a/src/lib/elementary/efl_ui_focus_manager_root_focus.c +++ b/src/lib/elementary/efl_ui_focus_manager_root_focus.c @@ -19,8 +19,22 @@ typedef struct { Eina_Bool rect_registered; Eina_List *iterator_list; + Eina_Future *focus_transfer; } Efl_Ui_Focus_Manager_Root_Focus_Data; +static Eina_Value +_unregister_rect(Eo *obj, void *data EINA_UNUSED, const Eina_Value v EINA_UNUSED) +{ + Efl_Ui_Focus_Manager_Root_Focus_Data *pd = efl_data_scope_get(obj, MY_CLASS); + + efl_ui_focus_manager_calc_unregister(obj, pd->rect); + pd->rect_registered = EINA_FALSE; + efl_ui_focus_composition_adapter_focus_manager_parent_set(pd->rect, NULL); + efl_ui_focus_composition_adapter_focus_manager_object_set(pd->rect, NULL); + pd->focus_transfer = NULL; + return EINA_VALUE_EMPTY; +} + static Efl_Ui_Focus_Object* _trap(Efl_Ui_Focus_Manager_Root_Focus_Data *pd, Efl_Ui_Focus_Object *obj) { @@ -46,15 +60,17 @@ _state_eval(Eo *obj, Efl_Ui_Focus_Manager_Root_Focus_Data *pd) if (sub && pd->rect_registered) { - efl_ui_focus_manager_calc_unregister(obj, pd->rect); - pd->rect_registered = EINA_FALSE; - efl_ui_focus_composition_adapter_focus_manager_parent_set(pd->rect, NULL); - efl_ui_focus_composition_adapter_focus_manager_object_set(pd->rect, NULL); + pd->focus_transfer = efl_loop_job(efl_main_loop_get()); + efl_future_then(obj, pd->focus_transfer, _unregister_rect); } else if (!sub && !pd->rect_registered) { Efl_Ui_Focus_Object *root; + if (pd->focus_transfer) + eina_future_cancel(pd->focus_transfer); + pd->focus_transfer = NULL; + root = efl_ui_focus_manager_root_get(obj); efl_ui_focus_manager_calc_register(obj, pd->rect, root, NULL); efl_ui_focus_composition_adapter_focus_manager_parent_set(pd->rect, root); -- cgit v1.2.1