forked from enlightenment/efl
efl_ui_focus_util: refactor the util for focusing objects
the previous code had the problem that we moved focus onto logical objects which were not having any children, thus we saw errors from the focus manager. Now we are checking if we are able to deliver focus onto a child of the passed user. Differential Revision: https://phab.enlightenment.org/D7009
This commit is contained in:
parent
14f1866f25
commit
0d506bf346
|
@ -15,6 +15,15 @@ _manager_changed(void *data, const Efl_Event *event EINA_UNUSED)
|
||||||
efl_ui_focus_util_focus(EFL_UI_FOCUS_UTIL_CLASS, data);
|
efl_ui_focus_util_focus(EFL_UI_FOCUS_UTIL_CLASS, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
_can_take_focus(Efl_Ui_Focus_Manager *m, Efl_Ui_Focus_Object *user)
|
||||||
|
{
|
||||||
|
if (efl_isa(user, EFL_UI_FOCUS_MANAGER_INTERFACE))
|
||||||
|
return !!efl_ui_focus_manager_request_subchild(user, efl_ui_focus_manager_root_get(user));
|
||||||
|
else
|
||||||
|
return !!efl_ui_focus_manager_request_subchild(m, user);
|
||||||
|
}
|
||||||
|
|
||||||
EOLIAN static void
|
EOLIAN static void
|
||||||
_efl_ui_focus_util_focus(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, Efl_Ui_Focus_Object *user)
|
_efl_ui_focus_util_focus(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, Efl_Ui_Focus_Object *user)
|
||||||
{
|
{
|
||||||
|
@ -31,32 +40,27 @@ _efl_ui_focus_util_focus(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, Efl_Ui_Focus
|
||||||
registered_manager = m = efl_ui_focus_object_focus_manager_get(user);
|
registered_manager = m = efl_ui_focus_object_focus_manager_get(user);
|
||||||
entry = user;
|
entry = user;
|
||||||
|
|
||||||
do
|
if (m && !efl_ui_widget_focus_allow_get(user) && !_can_take_focus(m, user))
|
||||||
{
|
return;
|
||||||
if (m)
|
|
||||||
{
|
|
||||||
//check if the root of a manager is the window root, set focus to this object in the manager than
|
|
||||||
entry = efl_ui_focus_manager_root_get(m);
|
|
||||||
if (efl_isa(m, EFL_UI_WIN_CLASS))
|
|
||||||
{
|
|
||||||
//we are at the root of the window, we can set the focus to the object
|
|
||||||
efl_ui_focus_manager_focus_set(registered_manager, user);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//if there is no manager yet, delay the focus setting until this entity gets registered for one chain
|
//move up the manager chain and see if we can end at a winow or a NULL m
|
||||||
|
while (m && !efl_isa(m, EFL_UI_WIN_CLASS))
|
||||||
|
{
|
||||||
|
entry = efl_ui_focus_manager_root_get(m);
|
||||||
m = efl_ui_focus_object_focus_manager_get(entry);
|
m = efl_ui_focus_object_focus_manager_get(entry);
|
||||||
if (!m)
|
}
|
||||||
{
|
|
||||||
//delayed focusung
|
if (!m)
|
||||||
efl_key_data_set(top, "__delayed_focus_set", entry);
|
{
|
||||||
efl_event_callback_add(entry,
|
efl_key_data_set(top, "__delayed_focus_set", entry);
|
||||||
EFL_UI_FOCUS_OBJECT_EVENT_MANAGER_CHANGED,
|
efl_event_callback_add(entry,
|
||||||
_manager_changed, user);
|
EFL_UI_FOCUS_OBJECT_EVENT_MANAGER_CHANGED,
|
||||||
return;
|
_manager_changed, user);
|
||||||
}
|
}
|
||||||
} while (m);
|
else if (efl_isa(m, EFL_UI_WIN_CLASS))
|
||||||
|
{
|
||||||
|
efl_ui_focus_manager_focus_set(registered_manager, user);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN static Efl_Ui_Focus_Manager*
|
EOLIAN static Efl_Ui_Focus_Manager*
|
||||||
|
|
Loading…
Reference in New Issue