2017-11-16 08:09:46 -08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "elementary_config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <Elementary.h>
|
|
|
|
#include "elm_priv.h"
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
|
|
|
} Efl_Ui_Focus_Util_Data;
|
|
|
|
|
|
|
|
static void
|
|
|
|
_manager_changed(void *data, const Efl_Event *event EINA_UNUSED)
|
|
|
|
{
|
2019-02-09 09:45:27 -08:00
|
|
|
efl_ui_focus_util_focus(data);
|
2017-11-16 08:09:46 -08:00
|
|
|
}
|
|
|
|
|
2018-09-08 05:19:04 -07:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2017-11-16 08:09:46 -08:00
|
|
|
EOLIAN static void
|
2019-02-09 09:45:27 -08:00
|
|
|
_efl_ui_focus_util_focus(Efl_Ui_Focus_Object *user)
|
2017-11-16 08:09:46 -08:00
|
|
|
{
|
2018-04-07 14:59:47 -07:00
|
|
|
Efl_Ui_Focus_Object *entry;
|
2018-01-07 20:55:35 -08:00
|
|
|
Efl_Ui_Widget *top, *o;
|
2018-04-07 14:59:47 -07:00
|
|
|
Efl_Ui_Focus_Manager *m, *registered_manager;
|
2017-11-16 08:09:46 -08:00
|
|
|
|
|
|
|
top = elm_widget_top_get(user);
|
|
|
|
|
|
|
|
o = efl_key_data_get(top, "__delayed_focus_set");
|
2018-01-16 12:17:11 -08:00
|
|
|
if (o) efl_event_callback_del(o, EFL_UI_FOCUS_OBJECT_EVENT_MANAGER_CHANGED, _manager_changed, o);
|
2017-11-16 08:09:46 -08:00
|
|
|
efl_key_data_set(top, "__delayed_focus_set", NULL);
|
|
|
|
|
2018-04-07 14:59:47 -07:00
|
|
|
registered_manager = m = efl_ui_focus_object_focus_manager_get(user);
|
|
|
|
entry = user;
|
|
|
|
|
2018-09-08 05:19:04 -07:00
|
|
|
if (m && !efl_ui_widget_focus_allow_get(user) && !_can_take_focus(m, user))
|
|
|
|
return;
|
|
|
|
|
|
|
|
//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))
|
2018-09-06 06:21:55 -07:00
|
|
|
{
|
2018-09-08 05:19:04 -07:00
|
|
|
entry = efl_ui_focus_manager_root_get(m);
|
2018-09-06 06:21:55 -07:00
|
|
|
m = efl_ui_focus_object_focus_manager_get(entry);
|
2018-09-08 05:19:04 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!m)
|
|
|
|
{
|
|
|
|
efl_key_data_set(top, "__delayed_focus_set", entry);
|
|
|
|
efl_event_callback_add(entry,
|
|
|
|
EFL_UI_FOCUS_OBJECT_EVENT_MANAGER_CHANGED,
|
|
|
|
_manager_changed, user);
|
|
|
|
}
|
|
|
|
else if (efl_isa(m, EFL_UI_WIN_CLASS))
|
|
|
|
{
|
|
|
|
efl_ui_focus_manager_focus_set(registered_manager, user);
|
|
|
|
}
|
2017-11-16 08:09:46 -08:00
|
|
|
}
|
|
|
|
|
2018-04-12 09:04:18 -07:00
|
|
|
EOLIAN static Efl_Ui_Focus_Manager*
|
2019-02-09 09:45:27 -08:00
|
|
|
_efl_ui_focus_util_active_manager(Efl_Ui_Focus_Manager *manager)
|
2018-04-12 09:04:18 -07:00
|
|
|
{
|
|
|
|
while (efl_ui_focus_manager_redirect_get(manager))
|
|
|
|
manager = efl_ui_focus_manager_redirect_get(manager);
|
|
|
|
|
|
|
|
return manager;
|
|
|
|
}
|
|
|
|
|
2018-04-13 08:07:30 -07:00
|
|
|
EOLIAN static Efl_Ui_Focus_Direction
|
2019-02-09 09:45:27 -08:00
|
|
|
_efl_ui_focus_util_direction_complement(Efl_Ui_Focus_Direction dir)
|
2018-04-13 08:07:30 -07:00
|
|
|
{
|
|
|
|
#define COMP(a,b) \
|
|
|
|
if (dir == a) return b; \
|
|
|
|
if (dir == b) return a;
|
|
|
|
|
|
|
|
COMP(EFL_UI_FOCUS_DIRECTION_RIGHT, EFL_UI_FOCUS_DIRECTION_LEFT)
|
|
|
|
COMP(EFL_UI_FOCUS_DIRECTION_UP, EFL_UI_FOCUS_DIRECTION_DOWN)
|
|
|
|
COMP(EFL_UI_FOCUS_DIRECTION_PREVIOUS, EFL_UI_FOCUS_DIRECTION_NEXT)
|
|
|
|
|
|
|
|
#undef COMP
|
|
|
|
|
|
|
|
return EFL_UI_FOCUS_DIRECTION_LAST;
|
|
|
|
}
|
|
|
|
|
2018-04-12 09:04:18 -07:00
|
|
|
|
2017-11-16 08:09:46 -08:00
|
|
|
#include "efl_ui_focus_util.eo.c"
|