aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-02-26 15:38:28 +0100
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-02-26 19:31:39 +0100
commitad3fc4a362b1f45af1f47b62528a8422d50d0647 (patch)
tree0823a76e421411164e3d7ea5610a8d23cd7ecf77
parentefl_ui_widget: child_can_focus is not needed anymore (diff)
downloadefl-devs/bu5hm4n/jommy_jommy_coder_code.tar.gz
efl_ui_widget: refactor sub_object handlingdevs/bu5hm4n/jommy_jommy_coder_code
efl_ui_widget has a property called widget_parent. The setter for this function is called is exactly once, and this is within the constructor, to a value which is not even set to the actaul field parent_obj. Which shows, that in the sitation right now, the setter of the property is a bit disconnected and lags some real aspects. As we are heading towards eo-api stabilization we should beat some sense into this setter, as people using our classes might overwrite the setter and except calls to it, whenever the widget_parent is changed, and implementation as in elm_menu show that this might makes sense sometime. In order to achive this, the sub_object registering code of elm is adjusted a bit. sub_object_add/del is now used to differenciate between evas objects and efl.ui.widget objects as subobject. In case of a widget, the widget_parent of this object is set, most of the widget specific code is then executed in the actaul setter. In case of an evas object, the parent reference is added. In the end both end up in the subobject children list. The later is also a requirement for widget_parent_set to be successfull. ref https://phab.enlightenment.org/T7553
-rw-r--r--src/lib/elementary/efl_ui_popup.c4
-rw-r--r--src/lib/elementary/efl_ui_widget.c188
-rw-r--r--src/lib/elementary/elc_ctxpopup.c1
-rw-r--r--src/lib/elementary/elc_hoversel.c1
-rw-r--r--src/lib/elementary/elc_popup.c2
-rw-r--r--src/lib/elementary/elm_conform.c1
-rw-r--r--src/lib/elementary/elm_hover.c3
-rw-r--r--src/lib/elementary/elm_inwin.c1
-rw-r--r--src/lib/elementary/elm_menu.c5
-rw-r--r--src/lib/elementary/elm_notify.c4
10 files changed, 106 insertions, 104 deletions
diff --git a/src/lib/elementary/efl_ui_popup.c b/src/lib/elementary/efl_ui_popup.c
index 43150df460..f261517149 100644
--- a/src/lib/elementary/efl_ui_popup.c
+++ b/src/lib/elementary/efl_ui_popup.c
@@ -96,8 +96,10 @@ _parent_geom_cb(void *data, const Efl_Event *ev EINA_UNUSED)
}
EOLIAN static void
-_efl_ui_popup_efl_ui_widget_widget_parent_set(Eo *obj, Efl_Ui_Popup_Data *pd EINA_UNUSED, Eo *parent EINA_UNUSED)
+_efl_ui_popup_efl_ui_widget_widget_parent_set(Eo *obj, Efl_Ui_Popup_Data *pd EINA_UNUSED, Eo *parent)
{
+ efl_ui_widget_parent_set(efl_super(obj, MY_CLASS), parent);
+
pd->win_parent = efl_provider_find(obj, EFL_UI_WIN_CLASS);
if (!pd->win_parent)
{
diff --git a/src/lib/elementary/efl_ui_widget.c b/src/lib/elementary/efl_ui_widget.c
index 85d48e241d..9d534294d7 100644
--- a/src/lib/elementary/efl_ui_widget.c
+++ b/src/lib/elementary/efl_ui_widget.c
@@ -1150,10 +1150,6 @@ elm_widget_focus_region_show(Eo *obj)
}
}
-EOLIAN static void
-_efl_ui_widget_widget_parent_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Evas_Object *parent EINA_UNUSED)
-{
-}
EAPI Eina_Bool
elm_widget_api_check(int ver)
@@ -1365,74 +1361,27 @@ elm_widget_sub_object_parent_add(Evas_Object *sobj)
return elm_widget_sub_object_add(parent, sobj);
}
-/*
- * @internal
- *
- * Add sobj to obj's sub object.
- *
- * What does elementary sub object mean? This is unique in elementary, it
- * handles overall elementary policies between parent and sub objects.
- * focus, access, deletion, theme, scale, mirror, scrollable child get,
- * translate, name find, display mode set, orientation set, tree dump
- * AUTOMATICALLY.
- *
- * @see elm_widget_sub_object_parent_add()
- */
-EOLIAN static Eina_Bool
-_efl_ui_widget_widget_sub_object_add(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Object *sobj)
+EOLIAN static void
+_efl_ui_widget_widget_parent_set(Eo *obj, Elm_Widget_Smart_Data *pd, Efl_Ui_Widget *parent)
{
Eina_Bool mirrored, pmirrored = efl_ui_mirrored_get(obj);
- Elm_Widget_Smart_Data *sdc = NULL;
-
- EINA_SAFETY_ON_TRUE_RETURN_VAL(obj == sobj, EINA_FALSE);
-
- if (_elm_widget_is(sobj))
- sdc = efl_data_scope_get(sobj, MY_CLASS);
-
- if (sobj == sd->parent_obj)
+ Efl_Ui_Widget *old_parent;
+ //check if we are in the subobject list of parents
+ if (parent)
{
- /* in this case, sobj must be an elm widget, or something
- * very wrong is happening */
- if (!sdc) return EINA_FALSE;
-
- if (!elm_widget_sub_object_del(sobj, obj)) return EINA_FALSE;
- WRN("You passed a parent object of obj = %p as the sub object = %p!",
- obj, sobj);
+ ELM_WIDGET_DATA_GET_OR_RETURN(parent, ppd);
+ EINA_SAFETY_ON_FALSE_RETURN(eina_list_data_find(ppd->subobjs, obj));
}
- if (sdc)
- {
- if (sdc->parent_obj == obj) goto end;
- if (sdc->parent_obj)
- {
- if (!elm_widget_sub_object_del(sdc->parent_obj, sobj))
- return EINA_FALSE;
- }
- sdc->parent_obj = obj;
+ old_parent = pd->parent_obj;
+ pd->parent_obj = parent;
- _full_eval(sobj, sdc);
- efl_ui_widget_disabled_set(sobj, efl_ui_widget_disabled_get(obj));
+ // now lets sync up all states
- _elm_widget_top_win_focused_set(sobj, sd->top_win_focused);
- }
- else
- {
- void *data = evas_object_data_get(sobj, "elm-parent");
-
- if (data)
- {
- if (data == obj) goto end;
- if (!elm_widget_sub_object_del(data, sobj)) return EINA_FALSE;
- }
- }
- sd->subobjs = eina_list_append(sd->subobjs, sobj);
- evas_object_data_set(sobj, "elm-parent", obj);
-
- _callbacks_add(sobj, obj);
- if (sdc)
+ if (pd->parent_obj)
{
/* NOTE: In the following two lines, 'sobj' is correct. Do not change it.
- * Due to elementary's scale policy, scale and pscale can be different in
+ * Due to elementary's scale policy, scale and pscale can be different in
* some cases. This happens when sobj's previous parent and new parent have
* different scale value.
* For example, if sobj's previous parent's scale is 5 and new parent's scale
@@ -1440,33 +1389,85 @@ _efl_ui_widget_widget_sub_object_add(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Ob
* need to reset sobj's scale to 5.
* Note that each widget's scale is 0 by default.
*/
- double scale, pscale = efl_gfx_entity_scale_get(sobj);
- Elm_Theme *th, *pth = elm_widget_theme_get(sobj);
+ double scale, pscale = efl_gfx_entity_scale_get(obj);
+ Elm_Theme *th, *pth = elm_widget_theme_get(obj);
- scale = efl_gfx_entity_scale_get(sobj);
- th = elm_widget_theme_get(sobj);
- mirrored = efl_ui_mirrored_get(sobj);
+ scale = efl_gfx_entity_scale_get(obj);
+ th = elm_widget_theme_get(obj);
+ mirrored = efl_ui_mirrored_get(obj);
- if (!sdc->on_create)
+ if (!pd->on_create)
{
if ((scale != pscale) || (th != pth) || (pmirrored != mirrored))
- elm_widget_theme(sobj);
+ elm_widget_theme(obj);
}
+ if (_is_focused(obj)) _parents_focus(parent);
+ elm_widget_display_mode_set(obj, evas_object_size_hint_display_mode_get(parent));
+ elm_widget_disabled_set(obj, efl_ui_widget_disabled_get(parent));
+ _elm_widget_top_win_focused_set(obj, _elm_widget_top_win_focused_get(parent));
+ }
- if (_is_focused(sobj)) _parents_focus(obj);
+ _full_eval(obj, pd);
- elm_widget_display_mode_set(sobj,
- evas_object_size_hint_display_mode_get(obj));
- if (_elm_config->atspi_mode && !sd->on_create)
- {
- Efl_Access_Object *aparent;
- aparent = efl_provider_find(efl_parent_get(sobj), EFL_ACCESS_OBJECT_MIXIN);
- if (aparent)
- efl_access_children_changed_added_signal_emit(aparent, sobj);
- }
+ if (old_parent && _elm_config->atspi_mode)
+ {
+ Efl_Access_Object *aparent;
+ aparent = efl_provider_find(efl_parent_get(obj), EFL_ACCESS_OBJECT_MIXIN);
+ if (aparent)
+ efl_access_children_changed_del_signal_emit(aparent, obj);
+ }
+
+ if (pd->parent_obj && _elm_config->atspi_mode && efl_finalized_get(parent))
+ {
+ Efl_Access_Object *aparent;
+ aparent = efl_provider_find(efl_parent_get(obj), EFL_ACCESS_OBJECT_MIXIN);
+ if (aparent)
+ efl_access_children_changed_added_signal_emit(aparent, obj);
}
+}
+
+static void
+_widget_add_sub(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Object *sobj)
+{
+ sd->subobjs = eina_list_append(sd->subobjs, sobj);
+ evas_object_data_set(sobj, "elm-parent", obj);
+ _callbacks_add(sobj, obj);
+}
+
+static void
+_widget_del_sub(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Object *sobj)
+{
+ sd->subobjs = eina_list_remove(sd->subobjs, sobj);
+ evas_object_data_del(sobj, "elm-parent");
+ _callbacks_del(sobj, obj);
+}
+
+EOLIAN static Eina_Bool
+_efl_ui_widget_widget_sub_object_add(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Object *sobj)
+{
+ Efl_Ui_Widget *parent;
+
+ //first make sure that we unregister the sobj from the parent
+ if (elm_widget_is(sobj))
+ parent = efl_ui_widget_parent_get(sobj);
+ else
+ parent = evas_object_data_get(sobj, "elm-parent");
+ if (parent == obj) return EINA_TRUE;
+ if (parent)
+ {
+ if (!efl_ui_widget_sub_object_del(parent, sobj))
+ return EINA_FALSE;
+ }
+
+ //sobj does not have a parent here
+ //first add it to our own children list
+ _widget_add_sub(obj, sd, sobj);
+
+ //and if it is a widget, please set the correct parent on the widget itself
+ //the parent set method will take care of the property syncing etc.
+ if (elm_widget_is(sobj))
+ efl_ui_widget_parent_set(sobj, obj);
-end:
return EINA_TRUE;
}
@@ -1506,25 +1507,13 @@ _efl_ui_widget_widget_sub_object_del(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Ob
elm_widget_tree_unfocusable_set(sobj, EINA_TRUE);
elm_widget_tree_unfocusable_set(sobj, EINA_FALSE);
}
- if (_elm_config->atspi_mode && !sd->on_destroy)
- {
- Efl_Access_Object *aparent;
- aparent = efl_provider_find(efl_parent_get(sobj), EFL_ACCESS_OBJECT_MIXIN);
- if (aparent)
- efl_access_children_changed_del_signal_emit(aparent, sobj);
- }
- ELM_WIDGET_DATA_GET(sobj, sdc);
- sdc->parent_obj = NULL;
-
- _full_eval(sobj, sdc);
+ efl_ui_widget_parent_set(sobj, NULL);
}
if (sd->resize_obj == sobj) sd->resize_obj = NULL;
- sd->subobjs = eina_list_remove(sd->subobjs, sobj);
-
- _callbacks_del(sobj, obj);
+ _widget_del_sub(obj, sd, sobj);
return EINA_TRUE;
}
@@ -4980,16 +4969,17 @@ elm_widget_tree_dot_dump(const Evas_Object *top,
EOLIAN static Eo *
_efl_ui_widget_efl_object_constructor(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UNUSED)
{
- Eo *parent = NULL;
-
sd->on_create = EINA_TRUE;
_efl_ui_focus_event_redirector(obj, obj);
efl_canvas_group_clipped_set(obj, EINA_FALSE);
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);
- parent = efl_parent_get(obj);
- efl_ui_widget_parent_set(obj, parent);
+ if (!efl_isa(obj, EFL_UI_WIN_CLASS))
+ {
+ efl_ui_widget_sub_object_add(efl_parent_get(obj), obj);
+ }
+
sd->on_create = EINA_FALSE;
efl_access_object_role_set(obj, EFL_ACCESS_ROLE_UNKNOWN);
diff --git a/src/lib/elementary/elc_ctxpopup.c b/src/lib/elementary/elc_ctxpopup.c
index 1f6ed09737..98a2982c41 100644
--- a/src/lib/elementary/elc_ctxpopup.c
+++ b/src/lib/elementary/elc_ctxpopup.c
@@ -1104,6 +1104,7 @@ _elm_ctxpopup_efl_canvas_group_group_del(Eo *obj, Elm_Ctxpopup_Data *sd)
EOLIAN static void
_elm_ctxpopup_efl_ui_widget_widget_parent_set(Eo *obj, Elm_Ctxpopup_Data *_pd EINA_UNUSED, Evas_Object *parent)
{
+ efl_ui_widget_parent_set(efl_super(obj, MY_CLASS), parent);
//default parent is to be hover parent
elm_ctxpopup_hover_parent_set(obj, parent);
}
diff --git a/src/lib/elementary/elc_hoversel.c b/src/lib/elementary/elc_hoversel.c
index 07b251d1be..c425eaffa5 100644
--- a/src/lib/elementary/elc_hoversel.c
+++ b/src/lib/elementary/elc_hoversel.c
@@ -685,6 +685,7 @@ _elm_hoversel_efl_gfx_entity_visible_set(Eo *obj, Elm_Hoversel_Data *sd, Eina_Bo
EOLIAN static void
_elm_hoversel_efl_ui_widget_widget_parent_set(Eo *obj, Elm_Hoversel_Data *_pd EINA_UNUSED, Evas_Object *parent)
{
+ efl_ui_widget_parent_set(efl_super(obj, MY_CLASS), parent);
elm_hoversel_hover_parent_set(obj, parent);
}
diff --git a/src/lib/elementary/elc_popup.c b/src/lib/elementary/elc_popup.c
index 8c4684e0b3..a98b058c4a 100644
--- a/src/lib/elementary/elc_popup.c
+++ b/src/lib/elementary/elc_popup.c
@@ -1508,6 +1508,8 @@ EOLIAN static void
_elm_popup_efl_ui_widget_widget_parent_set(Eo *obj, Elm_Popup_Data *sd, Evas_Object *parent)
{
Evas_Coord x, y, w, h;
+
+ efl_ui_widget_parent_set(efl_super(obj, MY_CLASS), parent);
evas_object_geometry_get(parent, &x, &y, &w, &h);
if (efl_isa(parent, EFL_UI_WIN_CLASS))
diff --git a/src/lib/elementary/elm_conform.c b/src/lib/elementary/elm_conform.c
index 4c4035df3c..bcb5f8c622 100644
--- a/src/lib/elementary/elm_conform.c
+++ b/src/lib/elementary/elm_conform.c
@@ -968,6 +968,7 @@ _elm_conformant_efl_canvas_group_group_del(Eo *obj, Elm_Conformant_Data *sd)
EOLIAN static void
_elm_conformant_efl_ui_widget_widget_parent_set(Eo *obj, Elm_Conformant_Data *sd, Evas_Object *parent)
{
+ efl_ui_widget_parent_set(efl_super(obj, MY_CLASS), parent);
#ifdef HAVE_ELEMENTARY_X
Evas_Object *top = elm_widget_top_get(parent);
Ecore_X_Window xwin = elm_win_xwindow_get(parent);
diff --git a/src/lib/elementary/elm_hover.c b/src/lib/elementary/elm_hover.c
index c653b3651c..94d7f6d62d 100644
--- a/src/lib/elementary/elm_hover.c
+++ b/src/lib/elementary/elm_hover.c
@@ -735,12 +735,13 @@ elm_hover_parent_set(Evas_Object *obj,
Evas_Object *parent)
{
ELM_HOVER_CHECK(obj);
- efl_ui_widget_parent_set(obj, parent);
+ efl_ui_widget_sub_object_add(parent, obj);
}
EOLIAN static void
_elm_hover_efl_ui_widget_widget_parent_set(Eo *obj, Elm_Hover_Data *sd, Evas_Object *parent)
{
+ efl_ui_widget_parent_set(efl_super(obj, MY_CLASS), parent);
_elm_hover_parent_detach(obj);
sd->parent = parent;
diff --git a/src/lib/elementary/elm_inwin.c b/src/lib/elementary/elm_inwin.c
index 110a614575..7bb59f0737 100644
--- a/src/lib/elementary/elm_inwin.c
+++ b/src/lib/elementary/elm_inwin.c
@@ -60,6 +60,7 @@ _elm_inwin_efl_canvas_group_group_add(Eo *obj, Elm_Inwin_Data *pd EINA_UNUSED)
EOLIAN static void
_elm_inwin_efl_ui_widget_widget_parent_set(Eo *obj, Elm_Inwin_Data *pd EINA_UNUSED, Evas_Object *parent)
{
+ efl_ui_widget_parent_set(efl_super(obj, MY_CLASS), parent);
elm_win_resize_object_add(parent, obj);
elm_layout_sizing_eval(obj);
diff --git a/src/lib/elementary/elm_menu.c b/src/lib/elementary/elm_menu.c
index 19225b7287..114d9a5a57 100644
--- a/src/lib/elementary/elm_menu.c
+++ b/src/lib/elementary/elm_menu.c
@@ -690,7 +690,6 @@ EOLIAN static void
_elm_menu_efl_canvas_group_group_add(Eo *obj, Elm_Menu_Data *priv)
{
efl_canvas_group_add(efl_super(obj, MY_CLASS));
- elm_widget_sub_object_parent_add(obj);
elm_widget_can_focus_set(obj, EINA_FALSE);
@@ -858,7 +857,7 @@ elm_menu_parent_set(Evas_Object *obj,
Evas_Object *parent)
{
ELM_MENU_CHECK(obj);
- efl_ui_widget_parent_set(obj, parent);
+ efl_ui_widget_sub_object_add(parent, obj);
}
EOLIAN static void
@@ -867,6 +866,8 @@ _elm_menu_efl_ui_widget_widget_parent_set(Eo *obj, Elm_Menu_Data *sd, Evas_Objec
Eina_List *l, *_l, *_ll, *ll = NULL;
Elm_Object_Item *eo_item;
+ efl_ui_widget_parent_set(efl_super(obj, MY_CLASS), parent);
+
if (sd->parent == parent) return;
if (sd->parent)
{
diff --git a/src/lib/elementary/elm_notify.c b/src/lib/elementary/elm_notify.c
index 97e92acfcd..62244d566b 100644
--- a/src/lib/elementary/elm_notify.c
+++ b/src/lib/elementary/elm_notify.c
@@ -489,12 +489,14 @@ elm_notify_parent_set(Evas_Object *obj,
Evas_Object *parent)
{
ELM_NOTIFY_CHECK(obj);
- efl_ui_widget_parent_set(obj, parent);
+ efl_ui_widget_sub_object_add(parent, obj);
}
EOLIAN static void
_elm_notify_efl_ui_widget_widget_parent_set(Eo *obj, Elm_Notify_Data *sd, Evas_Object *parent)
{
+ efl_ui_widget_parent_set(efl_super(obj, MY_CLASS), parent);
+
if (sd->parent)
{
evas_object_event_callback_del_full