aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeeyong Um <conr2d@gmail.com>2017-06-12 15:27:23 +0900
committerJeeyong Um <conr2d@gmail.com>2017-06-12 16:21:37 +0900
commit1270ddb3ed41ede70b49bb0034babcf1380efea3 (patch)
treea0019c14c17931775bc872357dfcd26c3f0a5259
parentefl.canvas: Add "seat" (by id) and "device" (by name) properties (diff)
downloadefl-1270ddb3ed41ede70b49bb0034babcf1380efea3.tar.gz
elm hoversel: Delay sizing_eval to prevent too frequent recalculations
-rw-r--r--src/lib/elementary/elc_hoversel.c35
-rw-r--r--src/lib/elementary/elm_widget_hoversel.h1
2 files changed, 23 insertions, 13 deletions
diff --git a/src/lib/elementary/elc_hoversel.c b/src/lib/elementary/elc_hoversel.c
index aaedfa5278..e73fdac6fa 100644
--- a/src/lib/elementary/elc_hoversel.c
+++ b/src/lib/elementary/elc_hoversel.c
@@ -235,8 +235,9 @@ _create_scroller(Evas_Object *obj, Elm_Hoversel_Data *sd)
}
static void
-_resizing_eval(Evas_Object *obj, Elm_Hoversel_Data *sd)
+_sizing_eval(void *data)
{
+ Evas_Object *obj = data;
const char *max_size_str;
int max_size = 0;
char buf[128];
@@ -244,6 +245,11 @@ _resizing_eval(Evas_Object *obj, Elm_Hoversel_Data *sd)
Evas_Coord x, y, w, h, xx, yy, ww, hh;
Evas_Coord obj_x, obj_y, obj_w;
+ ELM_HOVERSEL_DATA_GET(obj, sd);
+
+ if (sd->resize_job)
+ sd->resize_job = NULL;
+
if ((!sd->expanded) || (!sd->bx)) return;
elm_layout_signal_emit(sd->hover, "elm,state,align,default", "elm");
@@ -497,7 +503,9 @@ _activate(Evas_Object *obj)
_create_scroller(obj, sd);
elm_object_content_set(sd->scr, sd->bx);
- _resizing_eval(obj, sd);
+ if (sd->resize_job)
+ ELM_SAFE_FREE(sd->resize_job, ecore_job_del);
+ _sizing_eval(obj);
elm_object_part_content_set(sd->hover, sd->last_location, sd->tbl);
if (_elm_config->access_mode) _access_widget_item_register(sd);
@@ -602,26 +610,27 @@ _elm_hoversel_item_efl_object_destructor(Eo *eo_item, Elm_Hoversel_Item_Data *it
}
static void
-_on_move_resize(void * data,
- Evas *e EINA_UNUSED,
- Evas_Object *obj,
- void *event_info EINA_UNUSED)
+_on_geometry_changed(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
{
- Elm_Hoversel_Data *sd = data;
+ Elm_Hoversel_Data *pd = data;
- _resizing_eval(obj, sd);
+ if (pd->resize_job)
+ ELM_SAFE_FREE(pd->resize_job, ecore_job_del);
+
+ pd->resize_job = ecore_job_add(_sizing_eval, obj);
}
static void
_on_parent_resize(void *data, const Efl_Event *ev EINA_UNUSED)
{
Evas_Object *obj = (Evas_Object *)data;
- ELM_HOVERSEL_DATA_GET(obj, sd);
- _on_move_resize(sd, NULL, obj, NULL);
+ ELM_HOVERSEL_DATA_GET(obj, pd);
+
+ _on_geometry_changed(pd, NULL, obj, NULL);
}
EOLIAN static void
-_elm_hoversel_efl_canvas_group_group_add(Eo *obj, Elm_Hoversel_Data *priv)
+_elm_hoversel_efl_canvas_group_group_add(Eo *obj, Elm_Hoversel_Data *pd)
{
efl_canvas_group_add(efl_super(obj, MY_CLASS));
elm_widget_sub_object_parent_add(obj);
@@ -631,8 +640,8 @@ _elm_hoversel_efl_canvas_group_group_add(Eo *obj, Elm_Hoversel_Data *priv)
//What are you doing here?
elm_obj_widget_theme_apply(obj);
- evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _on_move_resize, priv);
- evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _on_move_resize, priv);
+ evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _on_geometry_changed, pd);
+ evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _on_geometry_changed, pd);
_elm_access_text_set
(_elm_access_info_get(obj), ELM_ACCESS_TYPE, E_("Hoversel"));
diff --git a/src/lib/elementary/elm_widget_hoversel.h b/src/lib/elementary/elm_widget_hoversel.h
index ccc1d7475b..f21ae34d42 100644
--- a/src/lib/elementary/elm_widget_hoversel.h
+++ b/src/lib/elementary/elm_widget_hoversel.h
@@ -39,6 +39,7 @@ struct _Elm_Hoversel_Data
const char *last_location;
Eina_List *items;
+ Ecore_Job *resize_job;
Eina_Bool horizontal : 1;
Eina_Bool expanded : 1;