elm: update widgets that have documented focus and unfocused events

this emits focus and unfocus on those widgets.

fixes T7386

Depends on D7124

Differential Revision: https://phab.enlightenment.org/D7103
This commit is contained in:
Marcel Hollerbach 2018-10-22 13:39:06 +02:00
parent 04c4bb5834
commit 9f758dc363
31 changed files with 126 additions and 54 deletions

View File

@ -417,6 +417,7 @@ EOLIAN static Eo *
_efl_ui_button_legacy_efl_object_constructor(Eo *obj, void *_pd EINA_UNUSED)
{
obj = efl_constructor(efl_super(obj, EFL_UI_BUTTON_LEGACY_CLASS));
legacy_object_focus_handle(obj);
efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
return obj;
}

View File

@ -466,6 +466,7 @@ _efl_ui_check_legacy_efl_object_constructor(Eo *obj, void *pd EINA_UNUSED)
{
obj = efl_constructor(efl_super(obj, EFL_UI_CHECK_LEGACY_CLASS));
efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
legacy_object_focus_handle(obj);
return obj;
}

View File

@ -1971,7 +1971,7 @@ _efl_ui_image_zoomable_efl_object_constructor(Eo *obj, Efl_Ui_Image_Zoomable_Dat
obj = efl_constructor(efl_super(obj, MY_CLASS));
evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
efl_access_object_role_set(obj, EFL_ACCESS_ROLE_IMAGE);
legacy_object_focus_handle(obj);
return obj;
}

View File

@ -795,6 +795,7 @@ _efl_ui_progressbar_legacy_efl_object_constructor(Eo *obj, void *pd EINA_UNUSED)
{
obj = efl_constructor(efl_super(obj, EFL_UI_PROGRESSBAR_LEGACY_CLASS));
efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
legacy_object_focus_handle(obj);
return obj;
}

View File

@ -391,6 +391,7 @@ _efl_ui_radio_legacy_efl_object_constructor(Eo *obj, void *_pd EINA_UNUSED)
{
obj = efl_constructor(efl_super(obj, EFL_UI_RADIO_LEGACY_CLASS));
efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
legacy_object_focus_handle(obj);
return obj;
}

View File

@ -439,6 +439,8 @@ _efl_ui_video_legacy_efl_object_constructor(Eo *obj, void *_pd EINA_UNUSED)
{
obj = efl_constructor(efl_super(obj, EFL_UI_VIDEO_LEGACY_CLASS));
efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
legacy_object_focus_handle(obj);
return obj;
}

View File

@ -5345,15 +5345,6 @@ elm_widget_tree_dot_dump(const Evas_Object *top,
#endif
}
static void
_focus_event_changed(void *data EINA_UNUSED, const Efl_Event *event)
{
if (efl_ui_focus_object_focus_get(event->object))
evas_object_smart_callback_call(event->object, "focused", NULL);
else
evas_object_smart_callback_call(event->object, "unfocused", NULL);
}
EOLIAN static Eo *
_efl_ui_widget_efl_object_constructor(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UNUSED)
{
@ -5370,8 +5361,6 @@ _efl_ui_widget_efl_object_constructor(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UN
efl_access_object_role_set(obj, EFL_ACCESS_ROLE_UNKNOWN);
efl_event_callback_add(obj, EFL_UI_FOCUS_OBJECT_EVENT_FOCUS_CHANGED, _focus_event_changed, NULL);
return obj;
}

View File

@ -1940,6 +1940,7 @@ EOLIAN static Eo *
_elm_fileselector_efl_object_constructor(Eo *obj, Elm_Fileselector_Data *sd)
{
obj = efl_constructor(efl_super(obj, MY_CLASS));
legacy_child_focus_handle(obj);
sd->obj = obj;
efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);

View File

@ -278,6 +278,7 @@ _elm_fileselector_button_efl_object_constructor(Eo *obj, Elm_Fileselector_Button
efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
efl_access_object_role_set(obj, EFL_ACCESS_ROLE_PUSH_BUTTON);
legacy_object_focus_handle(obj);
return obj;
}

View File

@ -308,6 +308,7 @@ _elm_fileselector_entry_efl_object_constructor(Eo *obj, Elm_Fileselector_Entry_D
efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
efl_access_object_role_set(obj, EFL_ACCESS_ROLE_GROUPING);
legacy_child_focus_handle(obj);
return obj;
}

View File

@ -707,6 +707,7 @@ _elm_hoversel_efl_object_constructor(Eo *obj, Elm_Hoversel_Data *_pd EINA_UNUSED
efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
efl_access_object_role_set(obj, EFL_ACCESS_ROLE_PUSH_BUTTON);
legacy_object_focus_handle(obj);
return obj;
}

View File

@ -1647,54 +1647,16 @@ elm_multibuttonentry_add(Evas_Object *parent)
return elm_legacy_add(MY_CLASS, parent);
}
static void
_legacy_focused(void *data, const Efl_Event *ev)
{
Efl_Ui_Focus_Object *new_focus;
Eina_Bool meaningful_focus_in = EINA_FALSE, meaningful_focus_out = EINA_FALSE;
ELM_MULTIBUTTONENTRY_DATA_GET(data, pd);
new_focus = efl_ui_focus_manager_focus_get(ev->object);
if (efl_isa(ev->info, EFL_UI_WIDGET_CLASS) && elm_widget_parent_get(ev->info) == pd->box)
{
meaningful_focus_out = EINA_TRUE;
}
if (efl_isa(new_focus, EFL_UI_WIDGET_CLASS) && elm_widget_parent_get(new_focus) == pd->box)
{
meaningful_focus_in = EINA_TRUE;
}
if (meaningful_focus_in && !meaningful_focus_out)
{
evas_object_smart_callback_call(data, "focused", NULL);
}
if (!meaningful_focus_in && meaningful_focus_out)
{
evas_object_smart_callback_call(data, "unfocused", NULL);
}
}
static void
_legacy_manager_changed_cb(void *data EINA_UNUSED, const Efl_Event *ev)
{
efl_event_callback_del(ev->info, EFL_UI_FOCUS_MANAGER_EVENT_FOCUS_CHANGED, _legacy_focused, ev->object);
efl_event_callback_add(efl_ui_focus_object_focus_manager_get(ev->object), EFL_UI_FOCUS_MANAGER_EVENT_FOCUS_CHANGED, _legacy_focused, ev->object);
}
EOLIAN static Eo *
_elm_multibuttonentry_efl_object_constructor(Eo *obj, Elm_Multibuttonentry_Data *sd EINA_UNUSED)
{
legacy_child_focus_handle(obj);
obj = efl_constructor(efl_super(obj, MY_CLASS));
efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
efl_access_object_role_set(obj, EFL_ACCESS_ROLE_PANEL);
//listen to manager changes here
efl_event_callback_add(obj, EFL_UI_FOCUS_OBJECT_EVENT_MANAGER_CHANGED, _legacy_manager_changed_cb, NULL);
return obj;
}

View File

@ -1608,6 +1608,7 @@ _elm_naviframe_efl_object_constructor(Eo *obj, Elm_Naviframe_Data *sd)
{
obj = efl_constructor(efl_super(obj, MY_CLASS));
sd->obj = obj;
legacy_child_focus_handle(obj);
efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
efl_access_object_role_set(obj, EFL_ACCESS_ROLE_PAGE_TAB_LIST);

View File

@ -1548,6 +1548,7 @@ _elm_popup_efl_object_constructor(Eo *obj, Elm_Popup_Data *_pd EINA_UNUSED)
efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
efl_access_object_role_set(obj, EFL_ACCESS_ROLE_DIALOG);
legacy_object_focus_handle(obj);
return obj;
}

View File

@ -808,6 +808,7 @@ _elm_clock_efl_object_constructor(Eo *obj, Elm_Clock_Data *_pd EINA_UNUSED)
efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
efl_access_object_role_set(obj, EFL_ACCESS_ROLE_TEXT);
legacy_child_focus_handle(obj);
return obj;
}

View File

@ -44,6 +44,8 @@ class Elm.Color.Item(Elm.Widget.Item, Efl.Ui.Focus.Object, Efl.Access.Widget.Act
Elm.Widget.Item.item_focus { get; set; }
Efl.Ui.Focus.Object.focus { set; }
Efl.Ui.Focus.Object.focus_geometry { get; }
Efl.Ui.Focus.Object.focus_parent { get; }
Efl.Ui.Focus.Object.focus_manager { get; }
Efl.Access.Object.state_set { get; }
Efl.Access.Object.i18n_name { get; }
Efl.Access.Widget.Action.elm_actions { get; }

View File

@ -1771,7 +1771,7 @@ _elm_color_item_efl_object_constructor(Eo *eo_item, Elm_Color_Item_Data *item)
Evas_Object *obj;
obj = efl_parent_get(eo_item);
WIDGET(item) = obj;
VIEW_SET(item, elm_layout_add(obj));
if (!elm_layout_theme_set
(VIEW(item), "colorselector", "item", elm_widget_style_get(obj)))
@ -2282,6 +2282,7 @@ _elm_colorselector_efl_object_constructor(Eo *obj, Elm_Colorselector_Data *_pd E
efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
efl_access_object_role_set(obj, EFL_ACCESS_ROLE_COLOR_CHOOSER);
legacy_child_focus_handle(obj);
return obj;
}
@ -2723,6 +2724,19 @@ _elm_color_item_efl_ui_focus_object_focus_set(Eo *obj, Elm_Color_Item_Data *pd,
elm_object_item_focus_set(obj, focus);
}
EOLIAN static Efl_Ui_Focus_Object*
_elm_color_item_efl_ui_focus_object_focus_parent_get(const Eo *obj EINA_UNUSED, Elm_Color_Item_Data *pd)
{
return WIDGET(pd);
}
EOLIAN static Efl_Ui_Focus_Manager*
_elm_color_item_efl_ui_focus_object_focus_manager_get(const Eo *obj, Elm_Color_Item_Data *pd)
{
return efl_ui_focus_object_focus_manager_get(WIDGET(pd));
}
/* Standard widget overrides */
ELM_WIDGET_KEY_DOWN_DEFAULT_IMPLEMENT(elm_colorselector, Elm_Colorselector_Data)

View File

@ -32,6 +32,7 @@ _efl_ui_clock_legacy_efl_object_constructor(Eo *obj, void *pd EINA_UNUSED)
{
obj = efl_constructor(efl_super(obj, EFL_UI_CLOCK_LEGACY_CLASS));
efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
legacy_child_focus_handle(obj);
return obj;
}

View File

@ -1417,6 +1417,7 @@ _elm_diskselector_efl_object_constructor(Eo *obj, Elm_Diskselector_Data *_pd EIN
efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
efl_access_object_role_set(obj, EFL_ACCESS_ROLE_LIST);
legacy_object_focus_handle(obj);
return obj;
}

View File

@ -4127,6 +4127,7 @@ _elm_entry_efl_object_constructor(Eo *obj, Elm_Entry_Data *_pd EINA_UNUSED)
efl_access_object_role_set(obj, EFL_ACCESS_ROLE_ENTRY);
efl_event_callback_add(obj, EFL_EVENT_CALLBACK_ADD, _cb_added, NULL);
efl_event_callback_add(obj, EFL_EVENT_CALLBACK_DEL, _cb_deleted, NULL);
legacy_object_focus_handle(obj);
return obj;
}

View File

@ -665,6 +665,7 @@ _elm_flipselector_efl_object_constructor(Eo *obj, Elm_Flipselector_Data *sd)
efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
efl_access_object_role_set(obj, EFL_ACCESS_ROLE_LIST);
legacy_object_focus_handle(obj);
return obj;
}

View File

@ -380,3 +380,60 @@ legacy_efl_ui_focus_manager_widget_legacy_signals(Efl_Ui_Focus_Manager *manager,
efl_event_callback_add(manager, EFL_UI_FOCUS_MANAGER_EVENT_FOCUS_CHANGED, _focus_manager_focused, state);
efl_event_callback_add(manager, EFL_EVENT_DEL, _focus_manager_del, state);
}
typedef struct {
Eina_Bool focused;
Efl_Ui_Focus_Manager *registered_manager;
Eo *emittee;
} Legacy_Object_Focus_State;
static void
_manager_focus_changed(void *data, const Efl_Event *ev EINA_UNUSED)
{
Legacy_Object_Focus_State *state = data;
Eina_Bool currently_focused = efl_ui_focus_object_child_focus_get(state->emittee);
if (currently_focused == state->focused) return;
if (currently_focused)
evas_object_smart_callback_call(state->emittee, "focused", NULL);
else
evas_object_smart_callback_call(state->emittee, "unfocused", NULL);
state->focused = currently_focused;
}
static void
_manager_focus_object_changed(void *data, const Efl_Event *ev EINA_UNUSED)
{
Legacy_Object_Focus_State *state = data;
if (state->registered_manager)
efl_event_callback_del(state->registered_manager, EFL_UI_FOCUS_MANAGER_EVENT_FOCUS_CHANGED, _manager_focus_changed, state);
state->registered_manager = efl_ui_focus_object_focus_manager_get(state->emittee);
if (state->registered_manager)
efl_event_callback_add(state->registered_manager, EFL_UI_FOCUS_MANAGER_EVENT_FOCUS_CHANGED, _manager_focus_changed, state);
}
void
legacy_child_focus_handle(Efl_Ui_Focus_Object *object)
{
Legacy_Object_Focus_State *state = calloc(1, sizeof(Legacy_Object_Focus_State));
state->emittee = object;
efl_event_callback_add(object, EFL_UI_FOCUS_OBJECT_EVENT_MANAGER_CHANGED, _manager_focus_object_changed, state);
efl_event_callback_add(object, EFL_EVENT_DEL, _focus_manager_del, state);
}
static void
_focus_event_changed(void *data EINA_UNUSED, const Efl_Event *event)
{
if (efl_ui_focus_object_focus_get(event->object))
evas_object_smart_callback_call(event->object, "focused", NULL);
else
evas_object_smart_callback_call(event->object, "unfocused", NULL);
}
void
legacy_object_focus_handle(Efl_Ui_Focus_Object *object)
{
efl_event_callback_add(object, EFL_UI_FOCUS_OBJECT_EVENT_FOCUS_CHANGED, _focus_event_changed, NULL);
}

View File

@ -362,6 +362,13 @@ _elm_glview_version_constructor(Eo *obj, Elm_Glview_Data *sd,
efl_event_callback_add(obj, EFL_EVENT_CALLBACK_ADD, _cb_added, NULL);
}
EOLIAN static Efl_Object*
_elm_glview_efl_object_constructor(Eo *obj, Elm_Glview_Data *pd)
{
legacy_object_focus_handle(obj);
return efl_constructor(efl_super(obj, MY_CLASS));
}
EOLIAN static Eo *
_elm_glview_efl_object_finalize(Eo *obj, Elm_Glview_Data *sd)
{

View File

@ -188,6 +188,7 @@ class Elm.Glview (Efl.Ui.Widget, Efl.Gfx.View, Efl.Ui.Legacy)
}
implements {
class.constructor;
Efl.Object.constructor;
Efl.Object.finalize;
Efl.Gfx.Entity.size { set; }
Efl.Ui.Focus.Object.on_focus_update;

View File

@ -697,6 +697,7 @@ _elm_hover_efl_object_constructor(Eo *obj, Elm_Hover_Data *pd EINA_UNUSED)
efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
efl_access_object_role_set(obj, EFL_ACCESS_ROLE_POPUP_MENU);
legacy_child_focus_handle(obj);
return obj;
}

View File

@ -4300,6 +4300,7 @@ _elm_map_efl_object_constructor(Eo *obj, Elm_Map_Data *sd)
efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
efl_access_object_role_set(obj, EFL_ACCESS_ROLE_IMAGE_MAP);
legacy_object_focus_handle(obj);
return obj;
}

View File

@ -883,5 +883,22 @@ efl_ui_dir_is_horizontal(Efl_Ui_Dir dir, Eina_Bool def_val)
}
}
/**
* This function sets up handlers for emitting "unfocused" / "focused" events.
* Once the passed manager object is active, "focused" is emitted, if it gets inactive "unfocused" is emitted
*/
void legacy_efl_ui_focus_manager_widget_legacy_signals(Efl_Ui_Focus_Manager *manager, Efl_Ui_Focus_Manager *emittee);
/**
* This function sets up handlers for emitting "unfocused" / "focused" events.
* Once the children of the passed object are getting focus, "focused" will be emitted on the object, "unfocused" otherwise.
*/
void legacy_child_focus_handle(Efl_Ui_Focus_Object *object);
/**
* This function sets up handlers for emitting "unfocused" / "focused" events.
* Once the passed object is getting focus, "focused" will be emitted on the object, "unfocused" otherwise.
*/
void legacy_object_focus_handle(Efl_Ui_Focus_Object *object);
#endif

View File

@ -889,6 +889,8 @@ _elm_scroller_efl_object_constructor(Eo *obj, Elm_Scroller_Data *_pd EINA_UNUSED
evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
efl_access_object_role_set(obj, EFL_ACCESS_ROLE_SCROLL_PANE);
efl_event_callback_add(obj, EFL_UI_FOCUS_MANAGER_EVENT_FOCUS_CHANGED, _focused_element, obj);
legacy_efl_ui_focus_manager_widget_legacy_signals(obj, obj);
return obj;
}

View File

@ -377,6 +377,7 @@ _elm_slideshow_efl_object_constructor(Eo *obj, Elm_Slideshow_Data *_pd EINA_UNUS
efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
efl_access_object_role_set(obj, EFL_ACCESS_ROLE_DOCUMENT_PRESENTATION);
legacy_object_focus_handle(obj);
return obj;
}

View File

@ -1410,6 +1410,7 @@ EOLIAN static Eo *
_elm_spinner_efl_object_constructor(Eo *obj, Elm_Spinner_Data *_pd EINA_UNUSED)
{
obj = efl_constructor(efl_super(obj, MY_CLASS));
legacy_child_focus_handle(obj);
efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
efl_access_object_role_set(obj, EFL_ACCESS_ROLE_SPIN_BUTTON);

View File

@ -100,7 +100,7 @@ _elm_web_efl_object_constructor(Eo *obj, Elm_Web_Data *sd)
efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
evas_object_smart_callbacks_descriptions_set(obj, _elm_web_smart_callbacks);
efl_access_object_role_set(obj, EFL_ACCESS_ROLE_HTML_CONTAINER);
legacy_object_focus_handle(obj);
return obj;
}