efl_ui/popup: optimize popup sizing calcs slightly
authorMike Blumenkrantz <zmike@samsung.com>
Fri, 9 Aug 2019 16:04:43 +0000 (12:04 -0400)
committerJaehyun Cho <jae_hyun.cho@samsung.com>
Mon, 12 Aug 2019 07:35:52 +0000 (16:35 +0900)
ensure that scroll-based popups don't accidentally trigger a full
recalc and (wrong) size change during group_calc by hitting the base
popup size_set() implementation and setting the needs_calc flag or
by using the base popup calc code when it should not be used

this resolves a corner case sizing issue in the text_alert 2 popup
case in elm_test which seems to have been present for a long time

Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D9538

src/lib/elementary/efl_ui_popup.c
src/lib/elementary/efl_ui_popup_private.h
src/lib/elementary/efl_ui_scroll_alert_popup.c
src/lib/elementary/efl_ui_text_alert_popup.c

index eea29e7..f38e27c 100644 (file)
@@ -75,11 +75,12 @@ _calc_align(Eo *obj)
 }
 
 EOLIAN static void
-_efl_ui_popup_efl_gfx_entity_size_set(Eo *obj, Efl_Ui_Popup_Data *pd EINA_UNUSED, Eina_Size2D size)
+_efl_ui_popup_efl_gfx_entity_size_set(Eo *obj, Efl_Ui_Popup_Data *pd, Eina_Size2D size)
 {
    efl_gfx_entity_size_set(efl_super(obj, MY_CLASS), size);
 
-   efl_canvas_group_change(obj);
+   if (!pd->in_calc)
+     efl_canvas_group_change(obj);
 }
 
 static void
@@ -269,7 +270,6 @@ _sizing_eval(Eo *obj)
    new_size.w = (min.w > size.w ? min.w : size.w);
    new_size.h = (min.h > size.h ? min.h : size.h);
    efl_gfx_entity_size_set(obj, new_size);
-   efl_canvas_group_calculate(efl_super(obj, MY_CLASS));
 }
 
 EOLIAN static void
@@ -280,7 +280,12 @@ _efl_ui_popup_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_Popup_Data *pd)
     * The actual size calculation is done here when the object is rendered to
     * avoid duplicate size calculations. */
    efl_canvas_group_need_recalculate_set(obj, EINA_FALSE);
-    _sizing_eval(obj);
+   if (!pd->in_calc)
+     {
+        pd->in_calc = EINA_TRUE;
+        _sizing_eval(obj);
+        pd->in_calc = EINA_FALSE;
+     }
    _calc_align(obj);
 
    Eina_Rect p_geom = efl_gfx_entity_geometry_get(pd->win_parent);
index 77b989a..9472d63 100644 (file)
@@ -9,6 +9,7 @@ struct _Efl_Ui_Popup_Data
    Efl_Ui_Popup_Align align;
    Ecore_Timer       *timer;
    double             timeout;
+   Eina_Bool          in_calc : 1;
 };
 
 #define EFL_UI_POPUP_DATA_GET_OR_RETURN(o, ptr, ...) \
index e8d5011..1bc7574 100644 (file)
@@ -136,6 +136,8 @@ _sizing_eval(Eo *obj, Efl_Ui_Scroll_Alert_Popup_Data *pd)
 EOLIAN static void
 _efl_ui_scroll_alert_popup_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_Scroll_Alert_Popup_Data *pd)
 {
+   EFL_UI_POPUP_DATA_GET_OR_RETURN(obj, ppd);
+   ppd->in_calc = EINA_TRUE;
    /* When efl_canvas_group_change() is called, just flag is set instead of size
     * calculation.
     * The actual size calculation is done here when the object is rendered to
@@ -146,6 +148,7 @@ _efl_ui_scroll_alert_popup_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_Scro
 
    //Not to calculate size by super class
    efl_canvas_group_calculate(efl_super(obj, MY_CLASS));
+   ppd->in_calc = EINA_FALSE;
 }
 
 static Eina_Bool
index 048c2c5..393fb24 100644 (file)
@@ -158,6 +158,8 @@ _sizing_eval(Eo *obj, Efl_Ui_Text_Alert_Popup_Data *pd)
 EOLIAN static void
 _efl_ui_text_alert_popup_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_Text_Alert_Popup_Data *pd)
 {
+   EFL_UI_POPUP_DATA_GET_OR_RETURN(obj, ppd);
+   ppd->in_calc = EINA_TRUE;
    /* When efl_canvas_group_change() is called, just flag is set instead of size
     * calculation.
     * The actual size calculation is done here when the object is rendered to
@@ -167,6 +169,7 @@ _efl_ui_text_alert_popup_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_Text_A
    _sizing_eval(obj, pd);
 
    efl_canvas_group_calculate(efl_super(obj, MY_CLASS));
+   ppd->in_calc = EINA_FALSE;
 }
 
 static Eina_Bool