summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/eo/Eo.h14
-rw-r--r--src/lib/eo/eo_base.eo9
-rw-r--r--src/lib/eo/eo_base_class.c23
-rw-r--r--src/lib/eolian/database_type.c2
4 files changed, 29 insertions, 19 deletions
diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h
index d5274a9712..ec14715e3b 100644
--- a/src/lib/eo/Eo.h
+++ b/src/lib/eo/Eo.h
@@ -1048,20 +1048,6 @@ EAPI const Eo_Event_Description *eo_base_legacy_only_event_description_get(const
1048#define EO_CALLBACK_PRIORITY_AFTER 100 1048#define EO_CALLBACK_PRIORITY_AFTER 100
1049 1049
1050/** 1050/**
1051 * @def EO_CALLBACK_STOP
1052 * Stop calling callbacks for the even of which the callback was called for.
1053 * @see EO_CALLBACK_CONTINUE
1054 */
1055#define EO_CALLBACK_STOP EINA_FALSE
1056
1057/**
1058 * @def EO_CALLBACK_CONTINUE
1059 * Continue calling callbacks for the even of which the callback was called for.
1060 * @see EO_CALLBACK_STOP
1061 */
1062#define EO_CALLBACK_CONTINUE EINA_TRUE
1063
1064/**
1065 * Helper for creating global callback arrays. 1051 * Helper for creating global callback arrays.
1066 * The problem is on windows where you can't declare a static array with 1052 * The problem is on windows where you can't declare a static array with
1067 * external symbols in it, because the addresses are only known at runtime. 1053 * external symbols in it, because the addresses are only known at runtime.
diff --git a/src/lib/eo/eo_base.eo b/src/lib/eo/eo_base.eo
index 204c57bbee..d4e3bd655b 100644
--- a/src/lib/eo/eo_base.eo
+++ b/src/lib/eo/eo_base.eo
@@ -351,6 +351,15 @@ abstract Eo.Base ()
351 $true otherwise 351 $true otherwise
352 ]] 352 ]]
353 } 353 }
354 event_callback_stop {
355 [[Stop the current callback call.
356
357 This stops the current callback call. Any other callbacks for the
358 current event will not be called. This is useful when you want to
359 filter out events. You just add higher priority events and call this
360 on certain conditions to block a certain event.
361 ]]
362 }
354 event_callback_forwarder_add { 363 event_callback_forwarder_add {
355 [[Add an event callback forwarder for an event and an object.]] 364 [[Add an event callback forwarder for an event and an object.]]
356 params { 365 params {
diff --git a/src/lib/eo/eo_base_class.c b/src/lib/eo/eo_base_class.c
index e1865b3299..fe12067bd2 100644
--- a/src/lib/eo/eo_base_class.c
+++ b/src/lib/eo/eo_base_class.c
@@ -35,6 +35,7 @@ typedef struct
35 unsigned short walking_list; 35 unsigned short walking_list;
36 unsigned short event_freeze_count; 36 unsigned short event_freeze_count;
37 Eina_Bool deletions_waiting : 1; 37 Eina_Bool deletions_waiting : 1;
38 Eina_Bool callback_stopped : 1;
38} Eo_Base_Data; 39} Eo_Base_Data;
39 40
40typedef enum { 41typedef enum {
@@ -1042,6 +1043,7 @@ _eo_base_event_callback_call(Eo *obj_id, Eo_Base_Data *pd,
1042 const Eo_Event_Description *desc, 1043 const Eo_Event_Description *desc,
1043 void *event_info) 1044 void *event_info)
1044{ 1045{
1046 Eina_Bool callback_already_stopped = pd->callback_stopped;
1045 Eina_Bool ret = EINA_TRUE; 1047 Eina_Bool ret = EINA_TRUE;
1046 Eo_Callback_Description *cb; 1048 Eo_Callback_Description *cb;
1047 Eo_Current_Callback_Description *lookup = NULL; 1049 Eo_Current_Callback_Description *lookup = NULL;
@@ -1100,8 +1102,9 @@ _eo_base_event_callback_call(Eo *obj_id, Eo_Base_Data *pd,
1100 1102
1101 // Handle nested restart of walking list 1103 // Handle nested restart of walking list
1102 if (lookup) lookup->current = cb->next; 1104 if (lookup) lookup->current = cb->next;
1105 it->func((void *) cb->func_data, &ev);
1103 /* Abort callback calling if the func says so. */ 1106 /* Abort callback calling if the func says so. */
1104 if (!it->func((void *) cb->func_data, &ev)) 1107 if (pd->callback_stopped)
1105 { 1108 {
1106 ret = EINA_FALSE; 1109 ret = EINA_FALSE;
1107 goto end; 1110 goto end;
@@ -1122,8 +1125,9 @@ _eo_base_event_callback_call(Eo *obj_id, Eo_Base_Data *pd,
1122 1125
1123 // Handle nested restart of walking list 1126 // Handle nested restart of walking list
1124 if (lookup) lookup->current = cb->next; 1127 if (lookup) lookup->current = cb->next;
1128 cb->items.item.func((void *) cb->func_data, &ev);
1125 /* Abort callback calling if the func says so. */ 1129 /* Abort callback calling if the func says so. */
1126 if (!cb->items.item.func((void *) cb->func_data, &ev)) 1130 if (pd->callback_stopped)
1127 { 1131 {
1128 ret = EINA_FALSE; 1132 ret = EINA_FALSE;
1129 goto end; 1133 goto end;
@@ -1147,10 +1151,18 @@ end:
1147 pd->walking_list--; 1151 pd->walking_list--;
1148 _eo_callbacks_clear(pd); 1152 _eo_callbacks_clear(pd);
1149 1153
1154 pd->callback_stopped = callback_already_stopped;
1155
1150 return ret; 1156 return ret;
1151} 1157}
1152 1158
1153static Eina_Bool 1159EOLIAN static void
1160_eo_base_event_callback_stop(Eo *obj EINA_UNUSED, Eo_Base_Data *pd)
1161{
1162 pd->callback_stopped = EINA_TRUE;
1163}
1164
1165static void
1154_eo_event_forwarder_callback(void *data, const Eo_Event *event) 1166_eo_event_forwarder_callback(void *data, const Eo_Event *event)
1155{ 1167{
1156 Eo *new_obj = (Eo *) data; 1168 Eo *new_obj = (Eo *) data;
@@ -1158,7 +1170,10 @@ _eo_event_forwarder_callback(void *data, const Eo_Event *event)
1158 1170
1159 ret = eo_event_callback_call(new_obj, event->desc, event->info); 1171 ret = eo_event_callback_call(new_obj, event->desc, event->info);
1160 1172
1161 return ret; 1173 if (!ret)
1174 {
1175 eo_event_callback_stop(event->object);
1176 }
1162} 1177}
1163 1178
1164/* FIXME: Change default priority? Maybe call later? */ 1179/* FIXME: Change default priority? Maybe call later? */
diff --git a/src/lib/eolian/database_type.c b/src/lib/eolian/database_type.c
index c9cc654761..ee1f11477d 100644
--- a/src/lib/eolian/database_type.c
+++ b/src/lib/eolian/database_type.c
@@ -203,7 +203,7 @@ _atype_to_str(const Eolian_Typedecl *tp, Eina_Strbuf *buf)
203 if (tp->base_type->type == EOLIAN_TYPE_REGULAR && 203 if (tp->base_type->type == EOLIAN_TYPE_REGULAR &&
204 !strcmp(tp->base_type->name, "__builtin_event_cb")) 204 !strcmp(tp->base_type->name, "__builtin_event_cb"))
205 { 205 {
206 eina_strbuf_append(buf, "Eina_Bool (*"); 206 eina_strbuf_append(buf, "void (*");
207 _append_name(tp, buf); 207 _append_name(tp, buf);
208 eina_strbuf_append(buf, ")(void *data, const Eo_Event *event)"); 208 eina_strbuf_append(buf, ")(void *data, const Eo_Event *event)");
209 return; 209 return;