efl/src/lib/elementary/efl_ui_focus_layer.c

180 lines
5.5 KiB
C
Raw Normal View History

#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#define EFL_UI_WIDGET_FOCUS_MANAGER_PROTECTED
#define EFL_UI_FOCUS_LAYER_PROTECTED
#include <Elementary.h>
#include "elm_priv.h"
#define MY_CLASS EFL_UI_FOCUS_LAYER_MIXIN
typedef struct {
Efl_Ui_Focus_Object *old_focus;
Efl_Ui_Focus_Manager *registered_manager;
Efl_Ui_Focus_Manager *manager;
Eina_Bool cycle;
Eina_Bool enable_on_visible;
} Efl_Ui_Focus_Layer_Data;
EOLIAN static Efl_Ui_Focus_Manager*
_efl_ui_focus_layer_efl_ui_widget_focus_manager_focus_manager_create(Eo *obj, Efl_Ui_Focus_Layer_Data *pd EINA_UNUSED, Efl_Ui_Focus_Object *root)
{
pd->manager = efl_add(EFL_UI_FOCUS_MANAGER_ROOT_FOCUS_CLASS, obj, efl_ui_focus_manager_root_set(efl_added, root));
return pd->manager;
}
EOLIAN static void
_efl_ui_focus_layer_efl_gfx_entity_visible_set(Eo *obj, Efl_Ui_Focus_Layer_Data *pd, Eina_Bool v)
{
efl_gfx_entity_visible_set(efl_super(obj, MY_CLASS), v);
if (pd->enable_on_visible)
{
efl_ui_focus_layer_enable_set(obj, v);
}
}
EOLIAN static Efl_Ui_Focus_Object*
_efl_ui_focus_layer_efl_ui_focus_manager_move(Eo *obj, Efl_Ui_Focus_Layer_Data *pd, Efl_Ui_Focus_Direction direction)
{
Eo *ret = efl_ui_focus_manager_move(pd->manager, direction);
if (ret)
return ret;
//ret is NULL here, if we do not want to cycle return NULL, which will result in obj being unset
if (!pd->cycle)
return NULL;
if ((direction == EFL_UI_FOCUS_DIRECTION_PREVIOUS ) || (direction == EFL_UI_FOCUS_DIRECTION_NEXT))
efl_ui_focus_manager_focus_set(pd->manager, obj);
return efl_ui_focus_manager_focus_get(obj);
}
EOLIAN static void
_efl_ui_focus_layer_efl_object_invalidate(Eo *obj, Efl_Ui_Focus_Layer_Data *pd EINA_UNUSED)
{
efl_ui_focus_layer_enable_set(obj, EINA_FALSE);
efl_invalidate(efl_super(obj, MY_CLASS));
}
EOLIAN static Efl_Ui_Focus_Manager*
_efl_ui_focus_layer_efl_ui_focus_object_focus_manager_get(const Eo *obj EINA_UNUSED, Efl_Ui_Focus_Layer_Data *pd EINA_UNUSED)
{
if (pd->registered_manager)
return pd->registered_manager;
else
return NULL;
}
EOLIAN static Efl_Ui_Focus_Object*
_efl_ui_focus_layer_efl_ui_focus_object_focus_parent_get(const Eo *obj EINA_UNUSED, Efl_Ui_Focus_Layer_Data *pd)
{
if (pd->registered_manager)
return efl_ui_focus_manager_root_get(pd->registered_manager);
else
return NULL;
}
EOLIAN static Eina_Bool
_efl_ui_focus_layer_efl_ui_widget_focus_state_apply(Eo *obj EINA_UNUSED, Efl_Ui_Focus_Layer_Data *pd EINA_UNUSED, Efl_Ui_Widget_Focus_State current_state EINA_UNUSED, Efl_Ui_Widget_Focus_State *configured_state EINA_UNUSED, Efl_Ui_Widget *redirect EINA_UNUSED)
{
return EINA_FALSE;
}
EOLIAN static Efl_Object*
_efl_ui_focus_layer_efl_object_constructor(Eo *obj, Efl_Ui_Focus_Layer_Data *pd)
{
obj = efl_constructor(efl_super(obj, MY_CLASS));
pd->enable_on_visible = EINA_TRUE;
pd->cycle = EINA_TRUE;
return obj;
}
static void
_publish_state_change(Eo *obj, Efl_Ui_Focus_Manager *omanager, Efl_Ui_Focus_Object *oobj)
{
efl_event_callback_call(obj, EFL_UI_FOCUS_OBJECT_EVENT_FOCUS_MANAGER_CHANGED, omanager);
efl_event_callback_call(obj, EFL_UI_FOCUS_OBJECT_EVENT_FOCUS_PARENT_CHANGED, oobj);
}
EOLIAN static void
_efl_ui_focus_layer_enable_set(Eo *obj, Efl_Ui_Focus_Layer_Data *pd, Eina_Bool v)
{
if (!elm_object_tree_focus_allow_get(obj))
v = EINA_FALSE;
if (v)
{
Efl_Ui_Focus_Manager *manager;
pd->registered_manager = elm_widget_top_get(obj);
EINA_SAFETY_ON_FALSE_RETURN(efl_isa(pd->registered_manager, EFL_UI_WIN_CLASS));
manager = efl_ui_focus_util_active_manager(pd->registered_manager);
efl_ui_focus_manager_calc_register_logical(pd->registered_manager, obj, efl_ui_focus_manager_root_get(pd->registered_manager), obj);
_publish_state_change(obj, NULL, NULL);
pd->old_focus = efl_ui_focus_manager_focus_get(manager);
efl_ui_focus_manager_focus_set(pd->manager, obj);
}
else
{
Eina_Bool fallback = EINA_TRUE;
efl_ui_focus_layer: do not call on NULL objects This fixes the following backtrace #5 0x00007ffff4ee87d0 in efl_ui_focus_manager_root_get (obj=0x0) at lib/elementary/efl_ui_focus_manager.eo.c:17 #6 0x00007ffff4ef50cb in _efl_ui_focus_layer_enable_set (obj=0x40000004adfe, pd=0x12fde40, v=0 '\000') at lib/elementary/efl_ui_focus_layer.c:127 #7 0x00007ffff4ef52dd in efl_ui_focus_layer_enable_set (obj=0x40000004adfe, v=1 '\001') at lib/elementary/efl_ui_focus_layer.eo.c:4 #8 0x00007ffff4ef4df0 in _efl_ui_focus_layer_efl_gfx_entity_visible_set (obj=0x40000004adfe, pd=0x12fde40, v=1 '\001') at lib/elementary/efl_ui_focus_layer.c:35 #9 0x00007ffff0f366a3 in efl_gfx_entity_visible_set (obj=0x40000004adfe, v=1 '\001') at ../src/lib/efl/interfaces/efl_gfx_entity.eo.c:15 #10 0x00007ffff5d832bb in evas_object_show (eo_obj=0x40000004adfe) at lib/evas/canvas/evas_object_main.c:1917 #11 0x00007fffcc365c74 in _bar_icon_preview_show (data=0xfaa7e0) at ../src/modules/luncher/bar.c:906 #12 0x00007ffff6d4305a in _ecore_call_task_cb (func=0x7fffcc36549c <_bar_icon_preview_show>, data=0xfaa7e0) at lib/ecore/ecore_private.h:442 #13 0x00007ffff6d434d2 in _ecore_timer_legacy_tick (data=0x12ca950, event=0x7ffffffc57c0) at lib/ecore/ecore_timer.c:160 #14 0x00007ffff0d06e90 in _event_callback_call (obj_id=0x4000001f25b2, pd=0x923820, desc=0x7ffff6f673e0 <_EFL_LOOP_TIMER_EVENT_TICK>, event_info=0x0, legacy_compare=0 '\000') at lib/eo/eo_base_class.c:1671 #15 0x00007ffff0d07162 in _efl_object_event_callback_call (obj_id=0x4000001f25b2, pd=0x923820, desc=0x7ffff6f673e0 <_EFL_LOOP_TIMER_EVENT_TICK>, event_info=0x0) at lib/eo/eo_base_class.c:1755 #16 0x00007ffff0d07208 in efl_event_callback_call (obj=0x4000001f25b2, desc=0x7ffff6f673e0 <_EFL_LOOP_TIMER_EVENT_TICK>, event_info=0x0) at lib/eo/eo_base_class.c:1758 #17 0x00007ffff6d4478e in _efl_loop_timer_expired_call (obj=0x4000000003dc, pd=0x890bf0, when=333436.894054887) at lib/ecore/ecore_timer.c:634 #18 0x00007ffff6d445bd in _efl_loop_timer_expired_timers_call (obj=0x4000000003dc, pd=0x890bf0, when=333436.894054887) at lib/ecore/ecore_timer.c:587 #19 0x00007ffff6d0b423 in _ecore_main_loop_iterate_internal (obj=0x4000000003dc, pd=0x890bf0, once_only=0) at lib/ecore/ecore_main.c:2317 #20 0x00007ffff6d08e66 in _ecore_main_loop_begin (obj=0x4000000003dc, pd=0x890bf0) at lib/ecore/ecore_main.c:1175 #21 0x00007ffff6d11757 in _efl_loop_begin (obj=0x4000000003dc, pd=0x890bf0) at lib/ecore/efl_loop.c:83 #22 0x00007ffff6d13e6e in efl_loop_begin (obj=0x4000000003dc) at lib/ecore/efl_loop.eo.c:28 #23 0x00007ffff6d08fe0 in ecore_main_loop_begin () at lib/ecore/ecore_main.c:1248 #24 0x000000000054817c in main (argc=2, argv=0x7fffffffdc78) at ../src/bin/e_main.c:1090 fix T7034. Differential Revision: https://phab.enlightenment.org/D6492
2018-06-30 03:37:58 -07:00
Eo *oobj;
if (!pd->registered_manager) return;
efl_ui_focus_layer: do not call on NULL objects This fixes the following backtrace #5 0x00007ffff4ee87d0 in efl_ui_focus_manager_root_get (obj=0x0) at lib/elementary/efl_ui_focus_manager.eo.c:17 #6 0x00007ffff4ef50cb in _efl_ui_focus_layer_enable_set (obj=0x40000004adfe, pd=0x12fde40, v=0 '\000') at lib/elementary/efl_ui_focus_layer.c:127 #7 0x00007ffff4ef52dd in efl_ui_focus_layer_enable_set (obj=0x40000004adfe, v=1 '\001') at lib/elementary/efl_ui_focus_layer.eo.c:4 #8 0x00007ffff4ef4df0 in _efl_ui_focus_layer_efl_gfx_entity_visible_set (obj=0x40000004adfe, pd=0x12fde40, v=1 '\001') at lib/elementary/efl_ui_focus_layer.c:35 #9 0x00007ffff0f366a3 in efl_gfx_entity_visible_set (obj=0x40000004adfe, v=1 '\001') at ../src/lib/efl/interfaces/efl_gfx_entity.eo.c:15 #10 0x00007ffff5d832bb in evas_object_show (eo_obj=0x40000004adfe) at lib/evas/canvas/evas_object_main.c:1917 #11 0x00007fffcc365c74 in _bar_icon_preview_show (data=0xfaa7e0) at ../src/modules/luncher/bar.c:906 #12 0x00007ffff6d4305a in _ecore_call_task_cb (func=0x7fffcc36549c <_bar_icon_preview_show>, data=0xfaa7e0) at lib/ecore/ecore_private.h:442 #13 0x00007ffff6d434d2 in _ecore_timer_legacy_tick (data=0x12ca950, event=0x7ffffffc57c0) at lib/ecore/ecore_timer.c:160 #14 0x00007ffff0d06e90 in _event_callback_call (obj_id=0x4000001f25b2, pd=0x923820, desc=0x7ffff6f673e0 <_EFL_LOOP_TIMER_EVENT_TICK>, event_info=0x0, legacy_compare=0 '\000') at lib/eo/eo_base_class.c:1671 #15 0x00007ffff0d07162 in _efl_object_event_callback_call (obj_id=0x4000001f25b2, pd=0x923820, desc=0x7ffff6f673e0 <_EFL_LOOP_TIMER_EVENT_TICK>, event_info=0x0) at lib/eo/eo_base_class.c:1755 #16 0x00007ffff0d07208 in efl_event_callback_call (obj=0x4000001f25b2, desc=0x7ffff6f673e0 <_EFL_LOOP_TIMER_EVENT_TICK>, event_info=0x0) at lib/eo/eo_base_class.c:1758 #17 0x00007ffff6d4478e in _efl_loop_timer_expired_call (obj=0x4000000003dc, pd=0x890bf0, when=333436.894054887) at lib/ecore/ecore_timer.c:634 #18 0x00007ffff6d445bd in _efl_loop_timer_expired_timers_call (obj=0x4000000003dc, pd=0x890bf0, when=333436.894054887) at lib/ecore/ecore_timer.c:587 #19 0x00007ffff6d0b423 in _ecore_main_loop_iterate_internal (obj=0x4000000003dc, pd=0x890bf0, once_only=0) at lib/ecore/ecore_main.c:2317 #20 0x00007ffff6d08e66 in _ecore_main_loop_begin (obj=0x4000000003dc, pd=0x890bf0) at lib/ecore/ecore_main.c:1175 #21 0x00007ffff6d11757 in _efl_loop_begin (obj=0x4000000003dc, pd=0x890bf0) at lib/ecore/efl_loop.c:83 #22 0x00007ffff6d13e6e in efl_loop_begin (obj=0x4000000003dc) at lib/ecore/efl_loop.eo.c:28 #23 0x00007ffff6d08fe0 in ecore_main_loop_begin () at lib/ecore/ecore_main.c:1248 #24 0x000000000054817c in main (argc=2, argv=0x7fffffffdc78) at ../src/bin/e_main.c:1090 fix T7034. Differential Revision: https://phab.enlightenment.org/D6492
2018-06-30 03:37:58 -07:00
oobj = efl_ui_focus_manager_root_get(pd->registered_manager);
//restore old focus
if (pd->old_focus)
{
Efl_Ui_Focus_Manager *manager;
manager = efl_ui_focus_object_focus_manager_get(pd->old_focus);
if (manager)
{
efl_ui_focus_manager_focus_set(manager, pd->old_focus);
fallback = EINA_FALSE;
}
}
pd->old_focus = NULL;
if (fallback && efl_ui_focus_manager_redirect_get(pd->registered_manager) == obj)
efl_ui_focus_manager_redirect_set(pd->registered_manager, NULL);
efl_ui_focus_manager_calc_unregister(pd->registered_manager, obj);
pd->registered_manager = NULL;
efl_ui_focus_layer: do not call on NULL objects This fixes the following backtrace #5 0x00007ffff4ee87d0 in efl_ui_focus_manager_root_get (obj=0x0) at lib/elementary/efl_ui_focus_manager.eo.c:17 #6 0x00007ffff4ef50cb in _efl_ui_focus_layer_enable_set (obj=0x40000004adfe, pd=0x12fde40, v=0 '\000') at lib/elementary/efl_ui_focus_layer.c:127 #7 0x00007ffff4ef52dd in efl_ui_focus_layer_enable_set (obj=0x40000004adfe, v=1 '\001') at lib/elementary/efl_ui_focus_layer.eo.c:4 #8 0x00007ffff4ef4df0 in _efl_ui_focus_layer_efl_gfx_entity_visible_set (obj=0x40000004adfe, pd=0x12fde40, v=1 '\001') at lib/elementary/efl_ui_focus_layer.c:35 #9 0x00007ffff0f366a3 in efl_gfx_entity_visible_set (obj=0x40000004adfe, v=1 '\001') at ../src/lib/efl/interfaces/efl_gfx_entity.eo.c:15 #10 0x00007ffff5d832bb in evas_object_show (eo_obj=0x40000004adfe) at lib/evas/canvas/evas_object_main.c:1917 #11 0x00007fffcc365c74 in _bar_icon_preview_show (data=0xfaa7e0) at ../src/modules/luncher/bar.c:906 #12 0x00007ffff6d4305a in _ecore_call_task_cb (func=0x7fffcc36549c <_bar_icon_preview_show>, data=0xfaa7e0) at lib/ecore/ecore_private.h:442 #13 0x00007ffff6d434d2 in _ecore_timer_legacy_tick (data=0x12ca950, event=0x7ffffffc57c0) at lib/ecore/ecore_timer.c:160 #14 0x00007ffff0d06e90 in _event_callback_call (obj_id=0x4000001f25b2, pd=0x923820, desc=0x7ffff6f673e0 <_EFL_LOOP_TIMER_EVENT_TICK>, event_info=0x0, legacy_compare=0 '\000') at lib/eo/eo_base_class.c:1671 #15 0x00007ffff0d07162 in _efl_object_event_callback_call (obj_id=0x4000001f25b2, pd=0x923820, desc=0x7ffff6f673e0 <_EFL_LOOP_TIMER_EVENT_TICK>, event_info=0x0) at lib/eo/eo_base_class.c:1755 #16 0x00007ffff0d07208 in efl_event_callback_call (obj=0x4000001f25b2, desc=0x7ffff6f673e0 <_EFL_LOOP_TIMER_EVENT_TICK>, event_info=0x0) at lib/eo/eo_base_class.c:1758 #17 0x00007ffff6d4478e in _efl_loop_timer_expired_call (obj=0x4000000003dc, pd=0x890bf0, when=333436.894054887) at lib/ecore/ecore_timer.c:634 #18 0x00007ffff6d445bd in _efl_loop_timer_expired_timers_call (obj=0x4000000003dc, pd=0x890bf0, when=333436.894054887) at lib/ecore/ecore_timer.c:587 #19 0x00007ffff6d0b423 in _ecore_main_loop_iterate_internal (obj=0x4000000003dc, pd=0x890bf0, once_only=0) at lib/ecore/ecore_main.c:2317 #20 0x00007ffff6d08e66 in _ecore_main_loop_begin (obj=0x4000000003dc, pd=0x890bf0) at lib/ecore/ecore_main.c:1175 #21 0x00007ffff6d11757 in _efl_loop_begin (obj=0x4000000003dc, pd=0x890bf0) at lib/ecore/efl_loop.c:83 #22 0x00007ffff6d13e6e in efl_loop_begin (obj=0x4000000003dc) at lib/ecore/efl_loop.eo.c:28 #23 0x00007ffff6d08fe0 in ecore_main_loop_begin () at lib/ecore/ecore_main.c:1248 #24 0x000000000054817c in main (argc=2, argv=0x7fffffffdc78) at ../src/bin/e_main.c:1090 fix T7034. Differential Revision: https://phab.enlightenment.org/D6492
2018-06-30 03:37:58 -07:00
_publish_state_change(obj, pd->registered_manager, oobj);
}
}
EOLIAN static Eina_Bool
_efl_ui_focus_layer_enable_get(const Eo *obj, Efl_Ui_Focus_Layer_Data *pd)
{
if (!pd->registered_manager) return EINA_FALSE;
return (efl_ui_focus_manager_redirect_get(pd->registered_manager) == obj);
}
EOLIAN static void
_efl_ui_focus_layer_behaviour_set(Eo *obj EINA_UNUSED, Efl_Ui_Focus_Layer_Data *pd, Eina_Bool enable_on_visible, Eina_Bool cycle)
{
pd->enable_on_visible = enable_on_visible;
pd->cycle = cycle;
}
EOLIAN static void
_efl_ui_focus_layer_behaviour_get(const Eo *obj EINA_UNUSED, Efl_Ui_Focus_Layer_Data *pd, Eina_Bool *enable_on_visible, Eina_Bool *cycle)
{
*cycle = pd->cycle;
*enable_on_visible = pd->enable_on_visible;
}
#include "efl_ui_focus_layer.eo.c"