diff --git a/legacy/ephysics/src/lib/EPhysics.h b/legacy/ephysics/src/lib/EPhysics.h index 53878c2374..ca3a8dc2c4 100644 --- a/legacy/ephysics/src/lib/EPhysics.h +++ b/legacy/ephysics/src/lib/EPhysics.h @@ -560,11 +560,35 @@ EAPI void ephysics_world_event_callback_add(EPhysics_World *world, EPhysics_Call * on error. * * @see ephysics_world_event_callback_add() for details. + * @see ephysics_world_event_callback_del_full() if you need to match data + * pointer. * * @ingroup EPhysics_World */ EAPI void *ephysics_world_event_callback_del(EPhysics_World *world, EPhysics_Callback_Type type, EPhysics_World_Event_Cb func); +/** + * @brief + * Unregister an ephysics world event callback matching data pointer. + * + * A previously added callback that match @p world, @p type, @p func + * and @p data will be deleted. + * + * @param world The physics world. + * @param type The type of callback to be unregistered. + * @param func The callback function to be unregistered. + * @param data The data pointer that was passed to the callback. + * @return The user data passed when the callback was registered, or @c NULL + * on error. + * + * @see ephysics_world_event_callback_add() for details. + * @see ephysics_world_event_callback_del() if you don't need to match data + * pointer. + * + * @ingroup EPhysics_World + */ +EAPI void *ephysics_world_event_callback_del_full(EPhysics_World *world, EPhysics_Callback_Type type, EPhysics_World_Event_Cb func, void *data); + /** * @brief * Set linear slop to be used by world. diff --git a/legacy/ephysics/src/lib/ephysics_world.cpp b/legacy/ephysics/src/lib/ephysics_world.cpp index 7159eecbf3..0eafe47b81 100644 --- a/legacy/ephysics/src/lib/ephysics_world.cpp +++ b/legacy/ephysics/src/lib/ephysics_world.cpp @@ -592,6 +592,32 @@ ephysics_world_event_callback_del(EPhysics_World *world, EPhysics_Callback_Type return NULL; } +EAPI void * +ephysics_world_event_callback_del_full(EPhysics_World *world, EPhysics_Callback_Type type, EPhysics_World_Event_Cb func, void *data) +{ + EPhysics_World_Callback *cb; + void *cb_data; + + if (!world) + { + ERR("Can't delete world event callback, world is null."); + return NULL; + } + + EINA_INLIST_FOREACH(world->callbacks, cb) + { + if ((cb->type == type) && (cb->func == func) && (cb->data == data)) { + cb_data = cb->data; + world->callbacks = eina_inlist_remove(world->callbacks, + EINA_INLIST_GET(cb)); + free(cb); + return cb_data; + } + } + + return NULL; +} + EAPI const Eina_List * ephysics_world_bodies_get(const EPhysics_World *world) {