widget: Fix legacy for focus_mouse_up_handle (EO)

This removes the special code in the legacy API for
elm_widget_focus_mouse_up_handle. Add an internal helper to find the
first widget parent. And mark as protected.
Apparently this functions is still required for the new focus manager.

Ref T5363
This commit is contained in:
Jean-Philippe Andre 2017-08-31 11:27:49 +09:00
parent b6bab481aa
commit 94d671c971
4 changed files with 12 additions and 19 deletions

View File

@ -2726,7 +2726,7 @@ _win_img_mouse_up(void *data,
{
Evas_Event_Mouse_Up *ev = event_info;
if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD))
elm_widget_focus_mouse_up_handle(data);
elm_widget_focus_mouse_up_handle(evas_object_widget_parent_find(data));
}
static void

View File

@ -575,7 +575,7 @@ _obj_mouse_up(void *data,
if (sd->still_in && (ev->flags == EVAS_BUTTON_NONE) &&
(sd->focus_move_policy == ELM_FOCUS_MOVE_POLICY_CLICK))
elm_widget_focus_mouse_up_handle(obj);
elm_widget_focus_mouse_up_handle(evas_object_widget_parent_find(obj));
sd->still_in = EINA_FALSE;
}
@ -588,7 +588,7 @@ _obj_mouse_in(void *data,
{
ELM_WIDGET_DATA_GET(data, sd);
if (sd->focus_move_policy == ELM_FOCUS_MOVE_POLICY_IN)
elm_widget_focus_mouse_up_handle(obj);
elm_widget_focus_mouse_up_handle(evas_object_widget_parent_find(obj));
}
EOLIAN static void
@ -4261,24 +4261,9 @@ _elm_widget_focus_hide_handle(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
_if_focused_revert(obj, EINA_TRUE);
}
EAPI void
elm_widget_focus_mouse_up_handle(Evas_Object *obj)
{
Evas_Object *o = obj;
do
{
if (_elm_widget_is(o)) break;
o = evas_object_smart_parent_get(o);
}
while (o);
elm_obj_widget_focus_mouse_up_handle(o);
}
EOLIAN static void
_elm_widget_focus_mouse_up_handle(Eo *obj, Elm_Widget_Smart_Data *pd)
{
if (!obj) return;
if (!_is_focusable(obj)) return;
elm_obj_widget_focus_steal(obj, NULL);

View File

@ -409,7 +409,6 @@ abstract Elm.Widget (Efl.Canvas.Group, Elm.Interface.Atspi_Accessible,
/* FIXME: Needs better doc... maybe merge with widget_event? */
focus_mouse_up_handle {
[[Handle focus mouse up]]
legacy: null;
}
/* Scroll API. */

View File

@ -826,6 +826,15 @@ elm_widget_is_legacy(const Eo *obj)
return sd ? sd->legacy : EINA_FALSE;
}
/** Takes in any canvas object and returns the first smart parent that is a widget */
static inline Elm_Widget *
evas_object_widget_parent_find(Evas_Object *o)
{
while (o && !efl_isa(o, ELM_WIDGET_CLASS))
evas_object_smart_parent_get(o);
return o;
}
/* to be used by INTERNAL classes on Elementary, so that the widgets
* parsing script skips it */
#define ELM_INTERNAL_SMART_SUBCLASS_NEW EVAS_SMART_SUBCLASS_NEW