summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <c.bail@partner.samsung.com>2014-07-06 19:08:56 +0200
committerCedric BAIL <c.bail@partner.samsung.com>2014-07-06 19:08:56 +0200
commit97e1fb1f77a4517a6cde5724f67098ca5654ef76 (patch)
tree5432bb419e0a548cfae53b8d7f042aed7c632a5e
parentdd87d438cecdc3d65715770b772867f6b873b41a (diff)
widget: move some callback infrastructure tu use Eo directly.
This save some serious amount of memory quite easily.
-rw-r--r--src/lib/elm_widget.c226
1 files changed, 128 insertions, 98 deletions
diff --git a/src/lib/elm_widget.c b/src/lib/elm_widget.c
index 00a754df0..3a9e298bb 100644
--- a/src/lib/elm_widget.c
+++ b/src/lib/elm_widget.c
@@ -83,6 +83,62 @@ _elm_scrollable_is(const Evas_Object *obj)
83 eo_isa(obj, ELM_INTERFACE_SCROLLABLE_MIXIN); 83 eo_isa(obj, ELM_INTERFACE_SCROLLABLE_MIXIN);
84} 84}
85 85
86static Eina_Bool
87_on_sub_obj_del(void *data,
88 Eo *obj,
89 const Eo_Event_Description *desc,
90 void *event_info);
91static Eina_Bool
92_on_sub_obj_hide(void *data,
93 Eo *obj,
94 const Eo_Event_Description *desc,
95 void *event_info);
96static Eina_Bool
97_propagate_event(void *data,
98 Eo *obj,
99 const Eo_Event_Description *desc,
100 void *event_info);
101
102EO_CALLBACKS_ARRAY_DEFINE(elm_widget_subitems_callbacks,
103 { EVAS_OBJECT_EVENT_DEL, _on_sub_obj_del },
104 { EVAS_OBJECT_EVENT_HIDE, _on_sub_obj_hide });
105EO_CALLBACKS_ARRAY_DEFINE(efl_subitems_callbacks,
106 { EVAS_OBJECT_EVENT_DEL, _on_sub_obj_del });
107EO_CALLBACKS_ARRAY_DEFINE(focus_callbacks,
108 { EVAS_OBJECT_EVENT_KEY_DOWN, _propagate_event },
109 { EVAS_OBJECT_EVENT_KEY_UP, _propagate_event },
110 { EVAS_OBJECT_EVENT_MOUSE_WHEEL, _propagate_event });
111
112static inline void
113_callbacks_add(Eo *widget, void *data)
114{
115 if (_elm_widget_is(widget))
116 {
117 eo_do(widget,
118 eo_event_callback_array_add(elm_widget_subitems_callbacks(), data));
119 }
120 else
121 {
122 eo_do(widget,
123 eo_event_callback_array_add(efl_subitems_callbacks(), data));
124 }
125}
126
127static inline void
128_callbacks_del(Eo *widget, void *data)
129{
130 if (_elm_widget_is(widget))
131 {
132 eo_do(widget,
133 eo_event_callback_array_del(elm_widget_subitems_callbacks(), data));
134 }
135 else
136 {
137 eo_do(widget,
138 eo_event_callback_array_del(efl_subitems_callbacks(), data));
139 }
140}
141
86void 142void
87_elm_widget_item_highlight_in_theme(Evas_Object *obj, Elm_Object_Item *it) 143_elm_widget_item_highlight_in_theme(Evas_Object *obj, Elm_Object_Item *it)
88{ 144{
@@ -167,20 +223,21 @@ _parents_unfocus(Evas_Object *obj)
167 } 223 }
168} 224}
169 225
170static void 226static Eina_Bool
171_on_sub_obj_hide(void *data EINA_UNUSED, 227_on_sub_obj_hide(void *data EINA_UNUSED,
172 Evas *e EINA_UNUSED, 228 Eo *obj,
173 Evas_Object *obj, 229 const Eo_Event_Description *desc EINA_UNUSED,
174 void *event_info EINA_UNUSED) 230 void *event_info EINA_UNUSED)
175{ 231{
176 elm_widget_focus_hide_handle(obj); 232 elm_widget_focus_hide_handle(obj);
233 return EO_CALLBACK_CONTINUE;
177} 234}
178 235
179static void 236static Eina_Bool
180_on_sub_obj_del(void *data, 237_on_sub_obj_del(void *data,
181 Evas *e EINA_UNUSED, 238 Eo *obj,
182 Evas_Object *obj, 239 const Eo_Event_Description *desc EINA_UNUSED,
183 void *event_info EINA_UNUSED) 240 void *event_info EINA_UNUSED)
184{ 241{
185 ELM_WIDGET_DATA_GET(data, sd); 242 ELM_WIDGET_DATA_GET(data, sd);
186 243
@@ -192,18 +249,18 @@ _on_sub_obj_del(void *data,
192 { 249 {
193 /* already dels sub object */ 250 /* already dels sub object */
194 elm_widget_resize_object_set(sd->obj, NULL, EINA_TRUE); 251 elm_widget_resize_object_set(sd->obj, NULL, EINA_TRUE);
195 return;
196 } 252 }
197 else if (obj == sd->hover_obj) 253 else if (obj == sd->hover_obj)
198 { 254 {
199 sd->hover_obj = NULL; 255 sd->hover_obj = NULL;
200 return;
201 } 256 }
202 else 257 else
203 { 258 {
204 if (!elm_widget_sub_object_del(sd->obj, obj)) 259 if (!elm_widget_sub_object_del(sd->obj, obj))
205 ERR("failed to remove sub object %p from %p\n", obj, sd->obj); 260 ERR("failed to remove sub object %p from %p\n", obj, sd->obj);
206 } 261 }
262
263 return EO_CALLBACK_CONTINUE;
207} 264}
208 265
209static const Evas_Smart_Cb_Description _smart_callbacks[] = 266static const Evas_Smart_Cb_Description _smart_callbacks[] =
@@ -333,8 +390,7 @@ _elm_widget_evas_object_smart_del(Eo *obj, Elm_Widget_Smart_Data *sd)
333 if (sd->hover_obj) 390 if (sd->hover_obj)
334 { 391 {
335 /* detach it from us */ 392 /* detach it from us */
336 evas_object_event_callback_del_full 393 _callbacks_del(sd->hover_obj, obj);
337 (sd->hover_obj, EVAS_CALLBACK_DEL, _on_sub_obj_del, obj);
338 sd->hover_obj = NULL; 394 sd->hover_obj = NULL;
339 } 395 }
340 396
@@ -579,44 +635,40 @@ _propagate_y_drag_lock(Evas_Object *obj,
579 } 635 }
580} 636}
581 637
582static void 638static Eina_Bool
583_propagate_event(void *data, 639_propagate_event(void *data EINA_UNUSED,
584 Evas *e EINA_UNUSED, 640 Eo *obj,
585 Evas_Object *obj, 641 const Eo_Event_Description *desc,
586 void *event_info) 642 void *event_info)
587{ 643{
588 INTERNAL_ENTRY; 644 INTERNAL_ENTRY EO_CALLBACK_CONTINUE;
589 Evas_Callback_Type type = (Evas_Callback_Type)(uintptr_t)data; 645 Evas_Callback_Type type;
590 Evas_Event_Flags *event_flags = NULL; 646 Evas_Event_Flags *event_flags = NULL;
591 647
592 switch (type) 648 if (desc == EVAS_OBJECT_EVENT_KEY_DOWN)
593 { 649 {
594 case EVAS_CALLBACK_KEY_DOWN: 650 Evas_Event_Key_Down *ev = event_info;
595 { 651 event_flags = &(ev->event_flags);
596 Evas_Event_Key_Down *ev = event_info; 652 type = EVAS_CALLBACK_KEY_DOWN;
597 event_flags = &(ev->event_flags); 653 }
598 } 654 else if (desc == EVAS_OBJECT_EVENT_KEY_UP)
599 break; 655 {
600 656 Evas_Event_Key_Up *ev = event_info;
601 case EVAS_CALLBACK_KEY_UP: 657 event_flags = &(ev->event_flags);
602 { 658 type = EVAS_CALLBACK_KEY_UP;
603 Evas_Event_Key_Up *ev = event_info;
604 event_flags = &(ev->event_flags);
605 }
606 break;
607
608 case EVAS_CALLBACK_MOUSE_WHEEL:
609 {
610 Evas_Event_Mouse_Wheel *ev = event_info;
611 event_flags = &(ev->event_flags);
612 }
613 break;
614
615 default:
616 break;
617 } 659 }
660 else if (desc == EVAS_OBJECT_EVENT_MOUSE_WHEEL)
661 {
662 Evas_Event_Mouse_Wheel *ev = event_info;
663 event_flags = &(ev->event_flags);
664 type = EVAS_CALLBACK_MOUSE_WHEEL;
665 }
666 else
667 return EO_CALLBACK_CONTINUE;
618 668
619 elm_widget_event_propagate(obj, type, event_info, event_flags); 669 elm_widget_event_propagate(obj, type, event_info, event_flags);
670
671 return EO_CALLBACK_CONTINUE;
620} 672}
621 673
622/** 674/**
@@ -1033,8 +1085,8 @@ _elm_widget_sub_object_add(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Object *sobj
1033 } 1085 }
1034 sd->subobjs = eina_list_append(sd->subobjs, sobj); 1086 sd->subobjs = eina_list_append(sd->subobjs, sobj);
1035 evas_object_data_set(sobj, "elm-parent", obj); 1087 evas_object_data_set(sobj, "elm-parent", obj);
1036 evas_object_event_callback_add 1088
1037 (sobj, EVAS_CALLBACK_DEL, _on_sub_obj_del, obj); 1089 _callbacks_add(sobj, obj);
1038 if (_elm_widget_is(sobj)) 1090 if (_elm_widget_is(sobj))
1039 { 1091 {
1040 ELM_WIDGET_DATA_GET(sobj, sdc); 1092 ELM_WIDGET_DATA_GET(sobj, sdc);
@@ -1051,9 +1103,6 @@ _elm_widget_sub_object_add(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Object *sobj
1051 double scale, pscale = elm_widget_scale_get(sobj); 1103 double scale, pscale = elm_widget_scale_get(sobj);
1052 Elm_Theme *th, *pth = elm_widget_theme_get(sobj); 1104 Elm_Theme *th, *pth = elm_widget_theme_get(sobj);
1053 1105
1054 evas_object_event_callback_add
1055 (sobj, EVAS_CALLBACK_HIDE, _on_sub_obj_hide, NULL);
1056
1057 scale = elm_widget_scale_get(sobj); 1106 scale = elm_widget_scale_get(sobj);
1058 th = elm_widget_theme_get(sobj); 1107 th = elm_widget_theme_get(sobj);
1059 mirrored = elm_widget_mirrored_get(sobj); 1108 mirrored = elm_widget_mirrored_get(sobj);
@@ -1148,11 +1197,7 @@ _elm_widget_sub_object_del(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Object *sobj
1148 1197
1149 sd->subobjs = eina_list_remove(sd->subobjs, sobj); 1198 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
1150 1199
1151 evas_object_event_callback_del_full 1200 _callbacks_del(sobj, obj);
1152 (sobj, EVAS_CALLBACK_DEL, _on_sub_obj_del, obj);
1153 if (_elm_widget_is(sobj))
1154 evas_object_event_callback_del_full
1155 (sobj, EVAS_CALLBACK_HIDE, _on_sub_obj_hide, NULL);
1156 1201
1157 return EINA_TRUE; 1202 return EINA_TRUE;
1158} 1203}
@@ -1224,14 +1269,12 @@ _elm_widget_hover_object_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Eva
1224{ 1269{
1225 if (sd->hover_obj) 1270 if (sd->hover_obj)
1226 { 1271 {
1227 evas_object_event_callback_del_full(sd->hover_obj, EVAS_CALLBACK_DEL, 1272 _callbacks_del(sd->hover_obj, obj);
1228 _on_sub_obj_del, obj);
1229 } 1273 }
1230 sd->hover_obj = sobj; 1274 sd->hover_obj = sobj;
1231 if (sd->hover_obj) 1275 if (sd->hover_obj)
1232 { 1276 {
1233 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL, 1277 _callbacks_add(sobj, obj);
1234 _on_sub_obj_del, obj);
1235 _smart_reconfigure(sd); 1278 _smart_reconfigure(sd);
1236 } 1279 }
1237} 1280}
@@ -1257,24 +1300,11 @@ _elm_widget_can_focus_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool can_focu
1257 sd->child_can_focus = EINA_TRUE; 1300 sd->child_can_focus = EINA_TRUE;
1258 } 1301 }
1259 1302
1260 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_DOWN, 1303 eo_do(obj, eo_event_callback_array_add(focus_callbacks(), NULL));
1261 _propagate_event,
1262 (void *)(uintptr_t)EVAS_CALLBACK_KEY_DOWN);
1263 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_UP,
1264 _propagate_event,
1265 (void *)(uintptr_t)EVAS_CALLBACK_KEY_UP);
1266 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1267 _propagate_event,
1268 (void *)(uintptr_t)EVAS_CALLBACK_MOUSE_WHEEL);
1269 } 1304 }
1270 else 1305 else
1271 { 1306 {
1272 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_DOWN, 1307 eo_do(obj, eo_event_callback_array_del(focus_callbacks(), NULL));
1273 _propagate_event);
1274 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_UP,
1275 _propagate_event);
1276 evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1277 _propagate_event);
1278 } 1308 }
1279} 1309}
1280 1310
@@ -3945,17 +3975,32 @@ _track_obj_update(Evas_Object *track, Evas_Object *obj)
3945 else evas_object_hide(track); 3975 else evas_object_hide(track);
3946} 3976}
3947 3977
3948static void 3978static Eina_Bool
3949_track_obj_view_update(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, 3979_track_obj_view_update(void *data, Eo *obj,
3980 const Eo_Event_Description *desc EINA_UNUSED,
3950 void *event_info EINA_UNUSED) 3981 void *event_info EINA_UNUSED)
3951{ 3982{
3952 Evas_Object *track = data; 3983 Elm_Widget_Item *item = data;
3953 _track_obj_update(track, obj); 3984 _track_obj_update(item->track_obj, obj);
3985 return EO_CALLBACK_CONTINUE;
3954} 3986}
3955 3987
3956static void 3988static Eina_Bool
3957_track_obj_view_del(void *data, Evas *e EINA_UNUSED, 3989_track_obj_view_del(void *data, Eo *obj EINA_UNUSED,
3958 Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 3990 const Eo_Event_Description *desc EINA_UNUSED,
3991 void *event_info EINA_UNUSED);
3992
3993EO_CALLBACKS_ARRAY_DEFINE(tracker_callbacks,
3994 { EVAS_OBJECT_EVENT_RESIZE, _track_obj_view_update },
3995 { EVAS_OBJECT_EVENT_MOVE, _track_obj_view_update },
3996 { EVAS_OBJECT_EVENT_SHOW, _track_obj_view_update },
3997 { EVAS_OBJECT_EVENT_HIDE, _track_obj_view_update },
3998 { EVAS_OBJECT_EVENT_DEL, _track_obj_view_del });
3999
4000static Eina_Bool
4001_track_obj_view_del(void *data, Eo *obj EINA_UNUSED,
4002 const Eo_Event_Description *desc EINA_UNUSED,
4003 void *event_info EINA_UNUSED)
3959{ 4004{
3960 Elm_Widget_Item *item = data; 4005 Elm_Widget_Item *item = data;
3961 4006
@@ -3966,6 +4011,8 @@ _track_obj_view_del(void *data, Evas *e EINA_UNUSED,
3966 _track_obj_del); 4011 _track_obj_del);
3967 evas_object_del(item->track_obj); 4012 evas_object_del(item->track_obj);
3968 item->track_obj = NULL; 4013 item->track_obj = NULL;
4014
4015 return EO_CALLBACK_CONTINUE;
3969} 4016}
3970 4017
3971static void 4018static void
@@ -3977,16 +4024,7 @@ _track_obj_del(void *data, Evas *e EINA_UNUSED,
3977 4024
3978 if (!item->view) return; 4025 if (!item->view) return;
3979 4026
3980 evas_object_event_callback_del(item->view, EVAS_CALLBACK_RESIZE, 4027 eo_do(item->view, eo_event_callback_array_del(tracker_callbacks(), item));
3981 _track_obj_view_update);
3982 evas_object_event_callback_del(item->view, EVAS_CALLBACK_MOVE,
3983 _track_obj_view_update);
3984 evas_object_event_callback_del(item->view, EVAS_CALLBACK_SHOW,
3985 _track_obj_view_update);
3986 evas_object_event_callback_del(item->view, EVAS_CALLBACK_HIDE,
3987 _track_obj_view_update);
3988 evas_object_event_callback_del(item->view, EVAS_CALLBACK_DEL,
3989 _track_obj_view_del);
3990} 4028}
3991 4029
3992static void 4030static void
@@ -4512,16 +4550,8 @@ elm_widget_item_track(Elm_Widget_Item *item)
4512 evas_object_event_callback_add(track, EVAS_CALLBACK_DEL, _track_obj_del, 4550 evas_object_event_callback_add(track, EVAS_CALLBACK_DEL, _track_obj_del,
4513 item); 4551 item);
4514 4552
4515 evas_object_event_callback_add(item->view, EVAS_CALLBACK_RESIZE, 4553 eo_do(item->view,
4516 _track_obj_view_update, track); 4554 eo_event_callback_array_add(tracker_callbacks(), item));
4517 evas_object_event_callback_add(item->view, EVAS_CALLBACK_MOVE,
4518 _track_obj_view_update, track);
4519 evas_object_event_callback_add(item->view, EVAS_CALLBACK_SHOW,
4520 _track_obj_view_update, track);
4521 evas_object_event_callback_add(item->view, EVAS_CALLBACK_HIDE,
4522 _track_obj_view_update, track);
4523 evas_object_event_callback_add(item->view, EVAS_CALLBACK_DEL,
4524 _track_obj_view_del, item);
4525 4555
4526 evas_object_ref(track); 4556 evas_object_ref(track);
4527 4557