efl/src/lib/evas/canvas/evas_callbacks.c

538 lines
16 KiB
C
Raw Normal View History

#include "evas_common_private.h"
2002-11-08 00:02:15 -08:00
#include "evas_private.h"
int _evas_event_counter = 0;
EVAS_MEMPOOL(_mp_pc);
extern Eina_Hash* signals_hash_table;
EAPI const Eo_Event_Description _EVAS_CANVAS_EVENT_RENDER_PRE =
EO_EVENT_DESCRIPTION("Render Pre", "Called just before rendering starts on the canvas target @since 1.2");
EAPI const Eo_Event_Description _EVAS_CANVAS_EVENT_RENDER_POST =
EO_EVENT_DESCRIPTION("Render Post", "Called just after rendering stops on the canvas target @since 1.2");
Expose device (e.g. pen) axis information to applications Summary: This patch set adds the necessary code to expose device axis state to applications. This was primarily written with graphics tablets in mind, which -- in addition to acting like a mouse -- also provide information about pen pressure, tilt, etc. Other devices could potentially benefit from this API as well: touchscreens, joysticks, knob controllers, "spaceballs", etc. Whenever an update to the device state is recieved, an "Axis update" event is synthesized. This event contains the updated information, typically scaled and normalized to a particular logical range (e.g. zero to one for pressure, -pi to pi radians for angles, etc.). Information about the tool which generated the event is also stored so that applications can disambiguate events from multiple devices (or in the case of multitouch screens, individual fingers). This API is only wired up for use with X11 at the moment. Support for other backends (e.g. Wayland) should be easy to add for those familiar them. **Note**: The following is a list of changes from the "v2" patches originally sent to the mailinglist //Define and implement new Ecore_Event_Axis_Update events// * Harcode axis labels instead of including xserver-properties.h * Use C89-style comments * Use doxygen comments * Update comment text to note axes with unbounded/undefined ranges/units * Create "Ecore_Axis" and "Ecore_Axis_Label" typedefs * Reference typedef'd instead of raw types * Adjust how we count through valuators to support tilt/az * Add support for tilt and azimuth * Tweak memory management in case number of valuators differ * Expand TWIST axis normalization to declared range * Only normalize TWIST axis if resolution == 1 (wacom bug) * Cache label atoms on first use to minimize round-trips //Implement EVAS_CALLBACK_AXIS_UPDATE event and friends// * Update to doxygen comments * Update comment text to note axes with unbounded/undefined ranges/units * Typedef 'Evas_Axis_Label', 'Evas_Axis' * Move typedef for 'Evas_Event_Axis_Update' * Reference typedef'd instead of raw types //Wire the Ecore and Evas implementations of axis update events together// * Expose ecore_event_evas_axis_update in Ecore_Input_Evas.h * Move ecore_event_evas_axis_update to more logical position //DEBUG: Add axis update logging to evas-multi-touch.c// * Removed from patch set //Make evas-multi-touch demo use new axis functionality// * Have pressure adjust rectangle brightness instead of size * Use more available axis data when rendering rectangle (azimuth, tilt, twist) Test Plan: The evas-multi-touch demo was updated to support axis update events. A graphics tablet was then used to verify that the pressure, azimuth, tilt, and twist data was coming through correctly. Reviewers: cedric, raster Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D1514 Conflicts: src/lib/ecore_input/Ecore_Input.h Carsten Haitzler - ** fixed forward enum typedefs (make things unhappy) ** fixed conflict above ** fixed wrong param type for _evas_canvas_event_feed_axis_update() ** fixed @sinces to be 1.13 ** fixed formatting/indeting ** fixed order of operation reliance in if's with ()'s to be clear ** fixed functions to be static that should have been
2014-11-24 19:07:50 -08:00
EAPI const Eo_Event_Description _EVAS_CANVAS_EVENT_AXIS_UPDATE =
EO_EVENT_DESCRIPTION("Axis Update", "Device axis value changed");
EAPI const Eo_Event_Description _EVAS_CANVAS_EVENT_FOCUS_IN =
EO_HOT_EVENT_DESCRIPTION("Canvas Focus In", "Canvas got focus as a whole");
EAPI const Eo_Event_Description _EVAS_CANVAS_EVENT_FOCUS_OUT =
EO_HOT_EVENT_DESCRIPTION("Canvas Focus Out", "Canvas lost focus as a whole");
EAPI const Eo_Event_Description _EVAS_CANVAS_EVENT_RENDER_FLUSH_PRE =
EO_HOT_EVENT_DESCRIPTION("Render Flush Pre", "Called just before rendering is updated on the canvas target");
EAPI const Eo_Event_Description _EVAS_CANVAS_EVENT_RENDER_FLUSH_POST =
EO_HOT_EVENT_DESCRIPTION("Render Flush Post", "Called just after rendering is updated on the canvas target");
EAPI const Eo_Event_Description _EVAS_CANVAS_EVENT_OBJECT_FOCUS_IN =
EO_HOT_EVENT_DESCRIPTION("Canvas Object Focus In", "Canvas object got focus");
EAPI const Eo_Event_Description _EVAS_CANVAS_EVENT_OBJECT_FOCUS_OUT =
EO_HOT_EVENT_DESCRIPTION("Canvas Object Focus Out", "Canvas object lost focus");
EAPI const Eo_Event_Description _EVAS_CANVAS_EVENT_DEVICE_CHANGED =
EO_HOT_EVENT_DESCRIPTION("Device changed",
"Devices added, removed or changed to the canvas");
/**
* Evas events descriptions for Eo.
*/
static const Eo_Event_Description *_legacy_evas_callback_table[EVAS_CALLBACK_LAST] =
{
EVAS_OBJECT_EVENT_MOUSE_IN,
EVAS_OBJECT_EVENT_MOUSE_OUT,
EVAS_OBJECT_EVENT_MOUSE_DOWN,
EVAS_OBJECT_EVENT_MOUSE_UP,
EVAS_OBJECT_EVENT_MOUSE_MOVE,
EVAS_OBJECT_EVENT_MOUSE_WHEEL,
EVAS_OBJECT_EVENT_MULTI_DOWN,
EVAS_OBJECT_EVENT_MULTI_UP,
EVAS_OBJECT_EVENT_MULTI_MOVE,
EVAS_OBJECT_EVENT_FREE,
EVAS_OBJECT_EVENT_KEY_DOWN,
EVAS_OBJECT_EVENT_KEY_UP,
EVAS_OBJECT_EVENT_FOCUS_IN,
EVAS_OBJECT_EVENT_FOCUS_OUT,
EVAS_OBJECT_EVENT_SHOW,
EVAS_OBJECT_EVENT_HIDE,
EVAS_OBJECT_EVENT_MOVE,
EVAS_OBJECT_EVENT_RESIZE,
EVAS_OBJECT_EVENT_RESTACK,
EVAS_OBJECT_EVENT_DEL,
EVAS_OBJECT_EVENT_HOLD,
EVAS_OBJECT_EVENT_CHANGED_SIZE_HINTS,
EVAS_OBJECT_EVENT_IMAGE_PRELOADED,
EVAS_CANVAS_EVENT_FOCUS_IN,
EVAS_CANVAS_EVENT_FOCUS_OUT,
EVAS_CANVAS_EVENT_RENDER_FLUSH_PRE,
EVAS_CANVAS_EVENT_RENDER_FLUSH_POST,
EVAS_CANVAS_EVENT_OBJECT_FOCUS_IN,
EVAS_CANVAS_EVENT_OBJECT_FOCUS_OUT,
EVAS_OBJECT_EVENT_IMAGE_UNLOADED,
EVAS_CANVAS_EVENT_RENDER_PRE,
EVAS_CANVAS_EVENT_RENDER_POST,
EVAS_OBJECT_EVENT_IMAGE_RESIZE,
Expose device (e.g. pen) axis information to applications Summary: This patch set adds the necessary code to expose device axis state to applications. This was primarily written with graphics tablets in mind, which -- in addition to acting like a mouse -- also provide information about pen pressure, tilt, etc. Other devices could potentially benefit from this API as well: touchscreens, joysticks, knob controllers, "spaceballs", etc. Whenever an update to the device state is recieved, an "Axis update" event is synthesized. This event contains the updated information, typically scaled and normalized to a particular logical range (e.g. zero to one for pressure, -pi to pi radians for angles, etc.). Information about the tool which generated the event is also stored so that applications can disambiguate events from multiple devices (or in the case of multitouch screens, individual fingers). This API is only wired up for use with X11 at the moment. Support for other backends (e.g. Wayland) should be easy to add for those familiar them. **Note**: The following is a list of changes from the "v2" patches originally sent to the mailinglist //Define and implement new Ecore_Event_Axis_Update events// * Harcode axis labels instead of including xserver-properties.h * Use C89-style comments * Use doxygen comments * Update comment text to note axes with unbounded/undefined ranges/units * Create "Ecore_Axis" and "Ecore_Axis_Label" typedefs * Reference typedef'd instead of raw types * Adjust how we count through valuators to support tilt/az * Add support for tilt and azimuth * Tweak memory management in case number of valuators differ * Expand TWIST axis normalization to declared range * Only normalize TWIST axis if resolution == 1 (wacom bug) * Cache label atoms on first use to minimize round-trips //Implement EVAS_CALLBACK_AXIS_UPDATE event and friends// * Update to doxygen comments * Update comment text to note axes with unbounded/undefined ranges/units * Typedef 'Evas_Axis_Label', 'Evas_Axis' * Move typedef for 'Evas_Event_Axis_Update' * Reference typedef'd instead of raw types //Wire the Ecore and Evas implementations of axis update events together// * Expose ecore_event_evas_axis_update in Ecore_Input_Evas.h * Move ecore_event_evas_axis_update to more logical position //DEBUG: Add axis update logging to evas-multi-touch.c// * Removed from patch set //Make evas-multi-touch demo use new axis functionality// * Have pressure adjust rectangle brightness instead of size * Use more available axis data when rendering rectangle (azimuth, tilt, twist) Test Plan: The evas-multi-touch demo was updated to support axis update events. A graphics tablet was then used to verify that the pressure, azimuth, tilt, and twist data was coming through correctly. Reviewers: cedric, raster Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D1514 Conflicts: src/lib/ecore_input/Ecore_Input.h Carsten Haitzler - ** fixed forward enum typedefs (make things unhappy) ** fixed conflict above ** fixed wrong param type for _evas_canvas_event_feed_axis_update() ** fixed @sinces to be 1.13 ** fixed formatting/indeting ** fixed order of operation reliance in if's with ()'s to be clear ** fixed functions to be static that should have been
2014-11-24 19:07:50 -08:00
EVAS_CANVAS_EVENT_DEVICE_CHANGED,
EVAS_CANVAS_EVENT_AXIS_UPDATE
};
typedef struct
{
EINA_INLIST;
Evas_Object_Event_Cb func;
void *data;
Evas_Callback_Type type;
} _eo_evas_object_cb_info;
static Eina_Bool
_eo_evas_object_cb(void *data, Eo *eo_obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info)
{
_eo_evas_object_cb_info *info = data;
if (info->func) info->func(info->data, evas_object_evas_get(eo_obj), eo_obj, event_info);
return EINA_TRUE;
}
typedef struct
{
EINA_INLIST;
Evas_Event_Cb func;
void *data;
Evas_Callback_Type type;
} _eo_evas_cb_info;
static Eina_Bool
_eo_evas_cb(void *data, Eo *eo_obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info)
{
_eo_evas_cb_info *info = data;
if (info->func) info->func(info->data, eo_obj, event_info);
return EINA_TRUE;
}
void
_evas_post_event_callback_call(Evas *eo_e, Evas_Public_Data *e)
{
Evas_Post_Callback *pc;
int skip = 0;
static int first_run = 1; // FIXME: This is a workaround to prevent this
// function from being called recursively.
if (e->delete_me || (!first_run)) return;
_evas_walk(e);
first_run = 0;
EINA_LIST_FREE(e->post_events, pc)
{
if ((!skip) && (!e->delete_me) && (!pc->delete_me))
{
if (!pc->func((void*)pc->data, eo_e)) skip = 1;
}
2011-12-14 21:56:19 -08:00
EVAS_MEMPOOL_FREE(_mp_pc, pc);
}
first_run = 1;
_evas_unwalk(e);
}
void
_evas_post_event_callback_free(Evas *eo_e)
{
Evas_Public_Data *e = eo_data_scope_get(eo_e, EVAS_CANVAS_CLASS);
Evas_Post_Callback *pc;
2011-12-14 21:56:19 -08:00
EINA_LIST_FREE(e->post_events, pc)
{
2011-12-14 21:56:19 -08:00
EVAS_MEMPOOL_FREE(_mp_pc, pc);
}
}
void
evas_object_event_callback_all_del(Evas_Object *eo_obj)
{
_eo_evas_object_cb_info *info;
Eina_Inlist *itr;
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
if (!obj) return;
if (!obj->callbacks) return;
EINA_INLIST_FOREACH_SAFE(obj->callbacks, itr, info)
{
eo_do(eo_obj, eo_event_callback_del(
_legacy_evas_callback_table[info->type], _eo_evas_object_cb, info));
obj->callbacks =
eina_inlist_remove(obj->callbacks, EINA_INLIST_GET(info));
free(info);
}
}
void
evas_object_event_callback_cleanup(Evas_Object *eo_obj)
{
evas_object_event_callback_all_del(eo_obj);
}
void
evas_event_callback_all_del(Evas *eo_e)
{
_eo_evas_object_cb_info *info;
Eina_Inlist *itr;
Evas_Public_Data *e = eo_data_scope_get(eo_e, EVAS_CANVAS_CLASS);
if (!e) return;
if (!e->callbacks) return;
EINA_INLIST_FOREACH_SAFE(e->callbacks, itr, info)
{
eo_do(eo_e, eo_event_callback_del(
_legacy_evas_callback_table[info->type], _eo_evas_cb, info));
e->callbacks =
eina_inlist_remove(e->callbacks, EINA_INLIST_GET(info));
free(info);
}
}
void
evas_event_callback_cleanup(Evas *eo_e)
{
evas_event_callback_all_del(eo_e);
}
void
evas_event_callback_call(Evas *eo_e, Evas_Callback_Type type, void *event_info)
{
eo_do(eo_e, eo_event_callback_call(_legacy_evas_callback_table[type], event_info));
}
2002-11-08 00:02:15 -08:00
void
evas_object_event_callback_call(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, Evas_Callback_Type type, void *event_info, int event_id)
2002-11-08 00:02:15 -08:00
{
/* MEM OK */
Evas_Button_Flags flags = EVAS_BUTTON_NONE;
Evas_Public_Data *e;
2005-05-21 19:49:50 -07:00
if (!obj) return;
if ((obj->delete_me) || (!obj->layer)) return;
if ((obj->last_event == event_id) &&
From: Hyoyoung Chang <hyoyoung.chang@samsung.com> Subject: [E-devel] [patch] evas - add checking event type Dear developers. I found a bug about evas event handling. In some situation, evas blocks some events by checking _evas_event_counter. So I made a patch that is checking event type also event counter. Reproduce steps: 1. make a window 2. show window before adding a elementary/genlist widget --- codes --- void _gl_mousedown_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info) { printf("_gl_mousedown_cb !! \n"); } static Eina_Bool create_main_win(App *app) { app->win = elm_win_add(NULL, "genlist-win", ELM_WIN_BASIC); evas_object_show(app->win); <-- position 1 Evas_Object *genlist = elm_genlist_add(app->win); elm_win_resize_object_add(app->win, genlist); evas_object_event_callback_add(genlist, EVAS_CALLBACK_MOUSE_DOWN, _gl_mousedown_cb, NULL); evas_object_show(genlist); evas_object_resize(app->win, 320, 240); //evas_object_show(app->win); <-- position 2 return EINA_TRUE; } --- codes --- In common use case, apps don't show main window at position 1. However to reproduce, it can be at position 1. Then, focus is at just on main window. In that situation, if a user clicks a genlist, its event is dropped by evas. Because in mouse down callback, it give focus to genlist. Then two events is made. First is mouse down, second is focus handling. In event callback, evas processes mouse down after focus handling. But evas found that mouse event is retarded event than focus handling. So it ignores it. This patch is introduce event handling type checking to evas_object_event_callback_call. SVN revision: 61026
2011-07-04 18:33:59 -07:00
(obj->last_event_type == type)) return;
From: Hyoyoung Chang <hyoyoung@gmail.com> Subject: [E-devel] [patch] evas - preventing retard mouse event process in evas_object_event_callback_call I made a small patch to prevent retard mouse event process. At certain circumstance (like as genlist select callback + naviframe item push), some events are repeat processed. If some evas_objects're iterating in evas_event_feed_mouse_up and mouse_out event's emitted by other interrupt(such as naviframe item push), then some evas_objects events are multiple processed by evas_object_event_callback_call. More elaborating it with a example. There are a genlist and a multibuttonentry on genlist item. When a user clicks multibuttonentry then evas will process mouse down and up. in evas_event_feed_mouse_up, it gets evas object list to process mouse events. Then in the evas object list, there are two evas objects - rect and textblock. Two objects have its own parents. the rect has below parents. ---------------------------------------- edje - genlist item elm_genlist_pan edje multibuttonentry box entry els_scroller (0x2a601788) rect <== the rect the textblock has below parents. ---------------------------------------------- edje - genlist item elm_genlist_pan edje multibuttonentry box entry els_scroller(0x2a601788) edje elm_pan edje textblock <== the textblock (note : two evas object have same parent (els_scroller)) So normally mouse up callbacks event propagates to its own parent. the rect is processed to genlist item. and the textblock is processed to genlist item. but when els_scroller is processed, it's blocked by checking event type and event id checking. Mouse Up(rect) -> Mouse Up(textblock) event_id (3) -> event_id (3) evas_object_event_callback_call(Evas_Object *obj, Evas_Callback_Type type, void *event_info, int event_id) { ... if ((obj->delete_me) || (!obj->layer)) return; if ((obj->last_event == event_id) && (obj->last_event_type == type)) return; <=== blocked However if naviframe item is pushed in the middle of mouse up processing. It can break into mouse up. So it's processed like below. Mouse Up(rect) -> Mouse Out(rect) -> Mouse Out(textblock) -> Mouse Up(textblock) event_id (3) -> event_id(4) -> event_id(4) -> event_id(3) (note Mouse_Out is made by naviframe item push for event freezing) If that, there's no mechanism to block that repeat processing same event. So I suggest this patch. This patch blocks old events if there's no reason to process. (It blocks old mouse_up event because mouse_out is processed.) And I think it also clear the bug in "[E-devel] event repetition with elm_naviframe/elm_genlist" SVN revision: 67879
2012-02-13 03:25:23 -08:00
if (obj->last_event > event_id)
{
if ((obj->last_event_type == EVAS_CALLBACK_MOUSE_OUT) &&
((type >= EVAS_CALLBACK_MOUSE_DOWN) &&
(type <= EVAS_CALLBACK_MULTI_MOVE)))
{
return;
}
}
obj->last_event = event_id;
From: Hyoyoung Chang <hyoyoung.chang@samsung.com> Subject: [E-devel] [patch] evas - add checking event type Dear developers. I found a bug about evas event handling. In some situation, evas blocks some events by checking _evas_event_counter. So I made a patch that is checking event type also event counter. Reproduce steps: 1. make a window 2. show window before adding a elementary/genlist widget --- codes --- void _gl_mousedown_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info) { printf("_gl_mousedown_cb !! \n"); } static Eina_Bool create_main_win(App *app) { app->win = elm_win_add(NULL, "genlist-win", ELM_WIN_BASIC); evas_object_show(app->win); <-- position 1 Evas_Object *genlist = elm_genlist_add(app->win); elm_win_resize_object_add(app->win, genlist); evas_object_event_callback_add(genlist, EVAS_CALLBACK_MOUSE_DOWN, _gl_mousedown_cb, NULL); evas_object_show(genlist); evas_object_resize(app->win, 320, 240); //evas_object_show(app->win); <-- position 2 return EINA_TRUE; } --- codes --- In common use case, apps don't show main window at position 1. However to reproduce, it can be at position 1. Then, focus is at just on main window. In that situation, if a user clicks a genlist, its event is dropped by evas. Because in mouse down callback, it give focus to genlist. Then two events is made. First is mouse down, second is focus handling. In event callback, evas processes mouse down after focus handling. But evas found that mouse event is retarded event than focus handling. So it ignores it. This patch is introduce event handling type checking to evas_object_event_callback_call. SVN revision: 61026
2011-07-04 18:33:59 -07:00
obj->last_event_type = type;
if (!(e = obj->layer->evas)) return;
_evas_walk(e);
{
switch (type)
{
2011-12-14 21:56:19 -08:00
case EVAS_CALLBACK_MOUSE_DOWN:
{
Evas_Event_Mouse_Down *ev = event_info;
flags = ev->flags;
if (ev->flags & (EVAS_BUTTON_DOUBLE_CLICK | EVAS_BUTTON_TRIPLE_CLICK))
{
if (obj->last_mouse_down_counter < (e->last_mouse_down_counter - 1))
ev->flags &= ~(EVAS_BUTTON_DOUBLE_CLICK | EVAS_BUTTON_TRIPLE_CLICK);
}
obj->last_mouse_down_counter = e->last_mouse_down_counter;
break;
}
case EVAS_CALLBACK_MOUSE_UP:
{
Evas_Event_Mouse_Up *ev = event_info;
flags = ev->flags;
if (ev->flags & (EVAS_BUTTON_DOUBLE_CLICK | EVAS_BUTTON_TRIPLE_CLICK))
{
if (obj->last_mouse_up_counter < (e->last_mouse_up_counter - 1))
ev->flags &= ~(EVAS_BUTTON_DOUBLE_CLICK | EVAS_BUTTON_TRIPLE_CLICK);
}
obj->last_mouse_up_counter = e->last_mouse_up_counter;
break;
}
default:
break;
}
eo_do(eo_obj, eo_event_callback_call(_legacy_evas_callback_table[type], event_info));
if (type == EVAS_CALLBACK_MOUSE_DOWN)
{
Evas_Event_Mouse_Down *ev = event_info;
ev->flags = flags;
}
else if (type == EVAS_CALLBACK_MOUSE_UP)
{
Evas_Event_Mouse_Up *ev = event_info;
ev->flags = flags;
}
2002-11-08 00:02:15 -08:00
}
if (!obj->no_propagate)
{
if ((obj->smart.parent) && (type != EVAS_CALLBACK_FREE) &&
(type <= EVAS_CALLBACK_KEY_UP))
2011-12-14 21:56:19 -08:00
{
Evas_Object_Protected_Data *smart_parent = eo_data_scope_get(obj->smart.parent, EVAS_OBJECT_CLASS);
evas_object_event_callback_call(obj->smart.parent, smart_parent, type, event_info, event_id);
2011-12-14 21:56:19 -08:00
}
}
_evas_unwalk(e);
2002-11-08 00:02:15 -08:00
}
EAPI void
evas_object_event_callback_add(Evas_Object *eo_obj, Evas_Callback_Type type, Evas_Object_Event_Cb func, const void *data)
{
evas_object_event_callback_priority_add(eo_obj, type,
2011-12-14 21:56:19 -08:00
EVAS_CALLBACK_PRIORITY_DEFAULT, func, data);
}
EAPI void
evas_object_event_callback_priority_add(Evas_Object *eo_obj, Evas_Callback_Type type, Evas_Callback_Priority priority, Evas_Object_Event_Cb func, const void *data)
2002-11-08 00:02:15 -08:00
{
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
2005-05-21 19:49:50 -07:00
MAGIC_CHECK(eo_obj, Evas_Object, MAGIC_OBJ);
2002-11-08 00:02:15 -08:00
return;
MAGIC_CHECK_END();
2005-05-21 19:49:50 -07:00
2002-11-08 00:02:15 -08:00
if (!func) return;
2005-05-21 19:49:50 -07:00
_eo_evas_object_cb_info *cb_info = calloc(1, sizeof(*cb_info));
cb_info->func = func;
cb_info->data = (void *)data;
cb_info->type = type;
2011-12-14 21:56:19 -08:00
const Eo_Event_Description *desc = _legacy_evas_callback_table[type];
eo_do(eo_obj, eo_event_callback_priority_add(desc, priority, _eo_evas_object_cb, cb_info));
obj->callbacks =
eina_inlist_append(obj->callbacks, EINA_INLIST_GET(cb_info));
2002-11-08 00:02:15 -08:00
}
EAPI void *
evas_object_event_callback_del(Evas_Object *eo_obj, Evas_Callback_Type type, Evas_Object_Event_Cb func)
2002-11-08 00:02:15 -08:00
{
_eo_evas_object_cb_info *info;
2005-05-21 19:49:50 -07:00
MAGIC_CHECK(eo_obj, Evas_Object, MAGIC_OBJ);
2002-11-08 00:02:15 -08:00
return NULL;
MAGIC_CHECK_END();
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
2005-05-21 19:49:50 -07:00
if (!obj) return NULL;
2002-11-08 00:02:15 -08:00
if (!func) return NULL;
2005-05-21 19:49:50 -07:00
if (!obj->callbacks) return NULL;
2005-05-21 19:49:50 -07:00
EINA_INLIST_FOREACH(obj->callbacks, info)
{
if ((info->func == func) && (info->type == type))
2011-12-14 21:56:19 -08:00
{
void *tmp = info->data;
eo_do(eo_obj, eo_event_callback_del(
_legacy_evas_callback_table[type], _eo_evas_object_cb, info));
2011-12-14 21:56:19 -08:00
obj->callbacks =
eina_inlist_remove(obj->callbacks, EINA_INLIST_GET(info));
free(info);
2011-12-14 21:56:19 -08:00
return tmp;
}
}
2002-11-08 00:02:15 -08:00
return NULL;
}
EAPI void *
evas_object_event_callback_del_full(Evas_Object *eo_obj, Evas_Callback_Type type, Evas_Object_Event_Cb func, const void *data)
{
_eo_evas_object_cb_info *info;
MAGIC_CHECK(eo_obj, Evas_Object, MAGIC_OBJ);
return NULL;
MAGIC_CHECK_END();
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
if (!obj) return NULL;
if (!func) return NULL;
if (!obj->callbacks) return NULL;
EINA_INLIST_FOREACH(obj->callbacks, info)
{
if ((info->func == func) && (info->type == type) && info->data == data)
2011-12-14 21:56:19 -08:00
{
void *tmp = info->data;
eo_do(eo_obj, eo_event_callback_del(
_legacy_evas_callback_table[type], _eo_evas_object_cb, info));
2011-12-14 21:56:19 -08:00
obj->callbacks =
eina_inlist_remove(obj->callbacks, EINA_INLIST_GET(info));
free(info);
2011-12-14 21:56:19 -08:00
return tmp;
}
}
return NULL;
}
EAPI void
evas_event_callback_add(Evas *eo_e, Evas_Callback_Type type, Evas_Event_Cb func, const void *data)
{
evas_event_callback_priority_add(eo_e, type, EVAS_CALLBACK_PRIORITY_DEFAULT,
2011-12-14 21:56:19 -08:00
func, data);
}
EAPI void
evas_event_callback_priority_add(Evas *eo_e, Evas_Callback_Type type, Evas_Callback_Priority priority, Evas_Event_Cb func, const void *data)
{
Evas_Public_Data *e = eo_data_scope_get(eo_e, EVAS_CANVAS_CLASS);
MAGIC_CHECK(eo_e, Evas, MAGIC_EVAS);
return;
MAGIC_CHECK_END();
if (!func) return;
_eo_evas_cb_info *cb_info = calloc(1, sizeof(*cb_info));
cb_info->func = func;
cb_info->data = (void *)data;
cb_info->type = type;
2011-12-14 21:56:19 -08:00
const Eo_Event_Description *desc = _legacy_evas_callback_table[type];
eo_do(eo_e, eo_event_callback_priority_add(desc, priority, _eo_evas_cb, cb_info));
e->callbacks = eina_inlist_append(e->callbacks, EINA_INLIST_GET(cb_info));
}
EAPI void *
evas_event_callback_del(Evas *eo_e, Evas_Callback_Type type, Evas_Event_Cb func)
{
Evas_Public_Data *e = eo_data_scope_get(eo_e, EVAS_CANVAS_CLASS);
_eo_evas_cb_info *info;
MAGIC_CHECK(eo_e, Evas, MAGIC_EVAS);
return NULL;
MAGIC_CHECK_END();
if (!e) return NULL;
if (!func) return NULL;
if (!e->callbacks) return NULL;
EINA_INLIST_FOREACH(e->callbacks, info)
{
if ((info->func == func) && (info->type == type))
2011-12-14 21:56:19 -08:00
{
void *tmp = info->data;
eo_do(eo_e, eo_event_callback_del(
_legacy_evas_callback_table[type], _eo_evas_cb, info));
e->callbacks =
eina_inlist_remove(e->callbacks, EINA_INLIST_GET(info));
free(info);
return tmp;
2011-12-14 21:56:19 -08:00
}
}
return NULL;
}
EAPI void *
evas_event_callback_del_full(Evas *eo_e, Evas_Callback_Type type, Evas_Event_Cb func, const void *data)
{
_eo_evas_cb_info *info;
MAGIC_CHECK(eo_e, Evas, MAGIC_EVAS);
return NULL;
MAGIC_CHECK_END();
Evas_Public_Data *e = eo_data_scope_get(eo_e, EVAS_CANVAS_CLASS);
if (!e) return NULL;
if (!func) return NULL;
if (!e->callbacks) return NULL;
EINA_INLIST_FOREACH(e->callbacks, info)
{
if ((info->func == func) && (info->type == type) && (info->data == data))
2011-12-14 21:56:19 -08:00
{
void *tmp = info->data;
eo_do(eo_e, eo_event_callback_del(
_legacy_evas_callback_table[type], _eo_evas_cb, info));
2011-12-14 21:56:19 -08:00
e->callbacks =
eina_inlist_remove(e->callbacks, EINA_INLIST_GET(info));
free(info);
2011-12-14 21:56:19 -08:00
return tmp;
}
}
return NULL;
}
EAPI void
evas_post_event_callback_push(Evas *eo_e, Evas_Object_Event_Post_Cb func, const void *data)
{
Evas_Post_Callback *pc;
2011-12-14 21:56:19 -08:00
MAGIC_CHECK(eo_e, Evas, MAGIC_EVAS);
return;
MAGIC_CHECK_END();
2011-12-14 21:56:19 -08:00
Evas_Public_Data *e = eo_data_scope_get(eo_e, EVAS_CANVAS_CLASS);
if (!e) return;
EVAS_MEMPOOL_INIT(_mp_pc, "evas_post_callback", Evas_Post_Callback, 64, );
pc = EVAS_MEMPOOL_ALLOC(_mp_pc, Evas_Post_Callback);
if (!pc) return;
EVAS_MEMPOOL_PREP(_mp_pc, pc, Evas_Post_Callback);
if (e->delete_me) return;
2011-12-14 21:56:19 -08:00
pc->func = func;
pc->data = data;
e->post_events = eina_list_prepend(e->post_events, pc);
}
EAPI void
evas_post_event_callback_remove(Evas *eo_e, Evas_Object_Event_Post_Cb func)
{
Evas_Post_Callback *pc;
Eina_List *l;
2011-12-14 21:56:19 -08:00
MAGIC_CHECK(eo_e, Evas, MAGIC_EVAS);
return;
MAGIC_CHECK_END();
2011-12-14 21:56:19 -08:00
Evas_Public_Data *e = eo_data_scope_get(eo_e, EVAS_CANVAS_CLASS);
if (!e) return;
EINA_LIST_FOREACH(e->post_events, l, pc)
{
if (pc->func == func)
{
pc->delete_me = 1;
return;
}
}
}
EAPI void
evas_post_event_callback_remove_full(Evas *eo_e, Evas_Object_Event_Post_Cb func, const void *data)
{
Evas_Post_Callback *pc;
Eina_List *l;
2011-12-14 21:56:19 -08:00
MAGIC_CHECK(eo_e, Evas, MAGIC_EVAS);
return;
MAGIC_CHECK_END();
2011-12-14 21:56:19 -08:00
Evas_Public_Data *e = eo_data_scope_get(eo_e, EVAS_CANVAS_CLASS);
if (!e) return;
EINA_LIST_FOREACH(e->post_events, l, pc)
{
if ((pc->func == func) && (pc->data == data))
{
pc->delete_me = 1;
return;
}
}
}