cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=3aee9a96c03a018d9d509c244068e58a19ee8def

commit 3aee9a96c03a018d9d509c244068e58a19ee8def
Author: Mike Blumenkrantz <[email protected]>
Date:   Fri Aug 9 12:04:43 2019 -0400

    efl_ui/popup: optimize popup sizing calcs slightly
    
    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 <[email protected]>
    Differential Revision: https://phab.enlightenment.org/D9538
---
 src/lib/elementary/efl_ui_popup.c              | 13 +++++++++----
 src/lib/elementary/efl_ui_popup_private.h      |  1 +
 src/lib/elementary/efl_ui_scroll_alert_popup.c |  3 +++
 src/lib/elementary/efl_ui_text_alert_popup.c   |  3 +++
 4 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/lib/elementary/efl_ui_popup.c 
b/src/lib/elementary/efl_ui_popup.c
index eea29e7bdc..f38e27cb74 100644
--- a/src/lib/elementary/efl_ui_popup.c
+++ b/src/lib/elementary/efl_ui_popup.c
@@ -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);
diff --git a/src/lib/elementary/efl_ui_popup_private.h 
b/src/lib/elementary/efl_ui_popup_private.h
index 77b989af75..9472d63b87 100644
--- a/src/lib/elementary/efl_ui_popup_private.h
+++ b/src/lib/elementary/efl_ui_popup_private.h
@@ -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, ...) \
diff --git a/src/lib/elementary/efl_ui_scroll_alert_popup.c 
b/src/lib/elementary/efl_ui_scroll_alert_popup.c
index e8d50115f9..1bc757422a 100644
--- a/src/lib/elementary/efl_ui_scroll_alert_popup.c
+++ b/src/lib/elementary/efl_ui_scroll_alert_popup.c
@@ -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
diff --git a/src/lib/elementary/efl_ui_text_alert_popup.c 
b/src/lib/elementary/efl_ui_text_alert_popup.c
index abb9a0338b..ad0c222d5f 100644
--- a/src/lib/elementary/efl_ui_text_alert_popup.c
+++ b/src/lib/elementary/efl_ui_text_alert_popup.c
@@ -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

-- 


Reply via email to