2002-11-08 00:02:15 -08:00
|
|
|
#include "evas_common.h"
|
|
|
|
#include "evas_private.h"
|
|
|
|
|
2003-01-19 19:54:00 -08:00
|
|
|
static void evas_object_event_callback_clear(Evas_Object *obj);
|
2010-03-21 22:33:46 -07:00
|
|
|
static void evas_event_callback_clear(Evas *e);
|
2010-03-04 06:48:21 -08:00
|
|
|
int _evas_event_counter = 0;
|
2002-12-14 16:33:57 -08:00
|
|
|
|
2010-05-04 08:58:10 -07:00
|
|
|
void
|
|
|
|
_evas_post_event_callback_call(Evas *e)
|
|
|
|
{
|
|
|
|
Evas_Post_Callback *pc;
|
|
|
|
int skip = 0;
|
|
|
|
|
|
|
|
if (e->delete_me) return;
|
|
|
|
_evas_walk(e);
|
|
|
|
EINA_LIST_FREE(e->post_events, pc)
|
|
|
|
{
|
|
|
|
if ((!skip) && (!e->delete_me) && (!pc->delete_me))
|
|
|
|
{
|
2010-06-27 22:14:36 -07:00
|
|
|
if (!pc->func((void*)pc->data, e)) skip = 1;
|
2010-05-04 08:58:10 -07:00
|
|
|
}
|
|
|
|
free(pc);
|
|
|
|
}
|
|
|
|
_evas_unwalk(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_evas_post_event_callback_free(Evas *e)
|
|
|
|
{
|
|
|
|
Evas_Post_Callback *pc;
|
|
|
|
|
|
|
|
EINA_LIST_FREE(e->post_events, pc)
|
|
|
|
{
|
|
|
|
free(pc);
|
|
|
|
}
|
|
|
|
_evas_unwalk(e);
|
|
|
|
}
|
|
|
|
|
2010-01-31 20:26:55 -08:00
|
|
|
void
|
|
|
|
evas_event_callback_list_post_free(Eina_Inlist **list)
|
2003-01-19 19:54:00 -08:00
|
|
|
{
|
2008-10-17 04:23:18 -07:00
|
|
|
Eina_Inlist *l;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2003-01-19 19:54:00 -08:00
|
|
|
/* MEM OK */
|
|
|
|
for (l = *list; l;)
|
|
|
|
{
|
|
|
|
Evas_Func_Node *fn;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2003-01-19 19:54:00 -08:00
|
|
|
fn = (Evas_Func_Node *)l;
|
|
|
|
l = l->next;
|
|
|
|
if (fn->delete_me)
|
|
|
|
{
|
2010-03-28 22:03:25 -07:00
|
|
|
*list = eina_inlist_remove(*list, EINA_INLIST_GET(fn));
|
2003-01-19 19:54:00 -08:00
|
|
|
free(fn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
evas_object_event_callback_clear(Evas_Object *obj)
|
|
|
|
{
|
2003-02-08 20:22:45 -08:00
|
|
|
if (!obj->callbacks) return;
|
|
|
|
if (!obj->callbacks->deletions_waiting) return;
|
|
|
|
obj->callbacks->deletions_waiting = 0;
|
2010-01-31 20:26:55 -08:00
|
|
|
evas_event_callback_list_post_free(&obj->callbacks->callbacks);
|
2007-01-22 04:44:57 -08:00
|
|
|
if (!obj->callbacks->callbacks)
|
|
|
|
{
|
|
|
|
free(obj->callbacks);
|
|
|
|
obj->callbacks = NULL;
|
|
|
|
}
|
2003-01-19 19:54:00 -08:00
|
|
|
}
|
|
|
|
|
2010-03-21 22:33:46 -07:00
|
|
|
static void
|
|
|
|
evas_event_callback_clear(Evas *e)
|
|
|
|
{
|
|
|
|
if (!e->callbacks) return;
|
|
|
|
if (!e->callbacks->deletions_waiting) return;
|
|
|
|
e->callbacks->deletions_waiting = 0;
|
|
|
|
evas_event_callback_list_post_free(&e->callbacks->callbacks);
|
|
|
|
if (!e->callbacks->callbacks)
|
|
|
|
{
|
|
|
|
free(e->callbacks);
|
|
|
|
e->callbacks = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-21 13:43:45 -08:00
|
|
|
void
|
|
|
|
evas_object_event_callback_all_del(Evas_Object *obj)
|
|
|
|
{
|
2008-10-20 05:36:48 -07:00
|
|
|
Evas_Func_Node *fn;
|
2007-02-21 13:43:45 -08:00
|
|
|
|
|
|
|
if (!obj->callbacks) return;
|
2008-10-21 05:19:57 -07:00
|
|
|
EINA_INLIST_FOREACH(obj->callbacks->callbacks, fn)
|
2008-10-20 05:36:48 -07:00
|
|
|
fn->delete_me = 1;
|
2007-02-21 13:43:45 -08:00
|
|
|
}
|
|
|
|
|
2002-12-14 16:33:57 -08:00
|
|
|
void
|
|
|
|
evas_object_event_callback_cleanup(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
/* MEM OK */
|
2003-02-08 20:22:45 -08:00
|
|
|
if (!obj->callbacks) return;
|
2010-01-31 20:26:55 -08:00
|
|
|
evas_event_callback_list_post_free(&obj->callbacks->callbacks);
|
2007-01-22 04:44:57 -08:00
|
|
|
free(obj->callbacks);
|
|
|
|
obj->callbacks = NULL;
|
2002-12-14 16:33:57 -08:00
|
|
|
}
|
|
|
|
|
2010-03-28 22:03:25 -07:00
|
|
|
void
|
|
|
|
evas_event_callback_all_del(Evas *e)
|
|
|
|
{
|
|
|
|
Evas_Func_Node *fn;
|
|
|
|
|
|
|
|
if (!e->callbacks) return;
|
|
|
|
EINA_INLIST_FOREACH(e->callbacks->callbacks, fn)
|
|
|
|
fn->delete_me = 1;
|
|
|
|
}
|
|
|
|
|
2010-03-28 19:40:49 -07:00
|
|
|
void
|
|
|
|
evas_event_callback_cleanup(Evas *e)
|
|
|
|
{
|
|
|
|
/* MEM OK */
|
|
|
|
if (!e->callbacks) return;
|
|
|
|
evas_event_callback_list_post_free(&e->callbacks->callbacks);
|
|
|
|
free(e->callbacks);
|
|
|
|
e->callbacks = NULL;
|
|
|
|
}
|
|
|
|
|
2010-01-31 20:26:55 -08:00
|
|
|
void
|
|
|
|
evas_event_callback_call(Evas *e, Evas_Callback_Type type, void *event_info)
|
|
|
|
{
|
|
|
|
Eina_Inlist **l_mod = NULL, *l;
|
2010-02-16 04:59:37 -08:00
|
|
|
|
2010-01-31 20:26:55 -08:00
|
|
|
_evas_walk(e);
|
|
|
|
if (e->callbacks)
|
|
|
|
{
|
|
|
|
l_mod = &e->callbacks->callbacks;
|
|
|
|
e->callbacks->walking_list++;
|
|
|
|
for (l = *l_mod; l; l = l->next)
|
|
|
|
{
|
|
|
|
Evas_Func_Node *fn;
|
|
|
|
|
|
|
|
fn = (Evas_Func_Node *)l;
|
|
|
|
if ((fn->type == type) && (!fn->delete_me))
|
|
|
|
{
|
2010-02-16 04:59:37 -08:00
|
|
|
Evas_Event_Cb func = fn->func;
|
|
|
|
if (func)
|
|
|
|
func(fn->data, e, event_info);
|
2010-01-31 20:26:55 -08:00
|
|
|
}
|
|
|
|
if (e->delete_me) break;
|
|
|
|
}
|
|
|
|
e->callbacks->walking_list--;
|
|
|
|
if (!e->callbacks->walking_list)
|
2010-03-21 22:33:46 -07:00
|
|
|
{
|
|
|
|
evas_event_callback_clear(e);
|
|
|
|
l_mod = NULL;
|
|
|
|
}
|
2010-01-31 20:26:55 -08:00
|
|
|
}
|
|
|
|
_evas_unwalk(e);
|
|
|
|
}
|
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
void
|
|
|
|
evas_object_event_callback_call(Evas_Object *obj, Evas_Callback_Type type, void *event_info)
|
|
|
|
{
|
2002-11-23 20:06:08 -08:00
|
|
|
/* MEM OK */
|
2008-10-17 04:23:18 -07:00
|
|
|
Eina_Inlist **l_mod = NULL, *l;
|
2006-08-25 13:47:32 -07:00
|
|
|
Evas_Button_Flags flags = EVAS_BUTTON_NONE;
|
|
|
|
Evas *e;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2010-08-29 15:59:11 -07:00
|
|
|
if ((obj->delete_me) || (!obj->layer)) return;
|
2010-03-22 00:04:04 -07:00
|
|
|
if (obj->last_event == _evas_event_counter) return;
|
2010-03-04 06:48:21 -08:00
|
|
|
obj->last_event = _evas_event_counter;
|
2010-08-29 15:59:11 -07:00
|
|
|
if (!(e = obj->layer->evas)) return;
|
2009-09-03 22:13:19 -07:00
|
|
|
|
2007-04-29 21:22:42 -07:00
|
|
|
_evas_walk(e);
|
2006-08-25 13:47:32 -07:00
|
|
|
if (obj->callbacks)
|
2003-12-11 03:20:40 -08:00
|
|
|
{
|
2007-01-22 04:44:57 -08:00
|
|
|
l_mod = &obj->callbacks->callbacks;
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case EVAS_CALLBACK_MOUSE_DOWN:
|
|
|
|
{
|
|
|
|
Evas_Event_Mouse_Down *ev = event_info;
|
2009-09-03 22:13:19 -07:00
|
|
|
|
2007-01-22 04:44:57 -08:00
|
|
|
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;
|
2009-09-03 22:13:19 -07:00
|
|
|
|
2007-01-22 04:44:57 -08:00
|
|
|
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;
|
|
|
|
}
|
2006-08-25 13:47:32 -07:00
|
|
|
obj->callbacks->walking_list++;
|
|
|
|
for (l = *l_mod; l; l = l->next)
|
|
|
|
{
|
|
|
|
Evas_Func_Node *fn;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2006-08-25 13:47:32 -07:00
|
|
|
fn = (Evas_Func_Node *)l;
|
2007-01-22 04:44:57 -08:00
|
|
|
if ((fn->type == type) && (!fn->delete_me))
|
2006-08-25 13:47:32 -07:00
|
|
|
{
|
2010-02-16 04:59:37 -08:00
|
|
|
Evas_Object_Event_Cb func = fn->func;
|
|
|
|
if (func)
|
|
|
|
func(fn->data, obj->layer->evas, obj, event_info);
|
2006-08-25 13:47:32 -07:00
|
|
|
}
|
|
|
|
if (obj->delete_me) break;
|
|
|
|
}
|
|
|
|
obj->callbacks->walking_list--;
|
|
|
|
if (!obj->callbacks->walking_list)
|
2008-02-26 01:16:17 -08:00
|
|
|
{
|
|
|
|
evas_object_event_callback_clear(obj);
|
|
|
|
l_mod = NULL;
|
|
|
|
}
|
2009-09-03 22:13:19 -07:00
|
|
|
|
2006-10-06 12:13:33 -07:00
|
|
|
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
|
|
|
}
|
2009-09-03 22:13:19 -07:00
|
|
|
|
2008-07-30 00:57:05 -07:00
|
|
|
if (!((obj->no_propagate) && (l_mod) && (*l_mod)))
|
2007-04-29 21:22:42 -07:00
|
|
|
{
|
2008-10-19 16:58:56 -07:00
|
|
|
if (!obj->no_propagate)
|
|
|
|
{
|
|
|
|
if ((obj->smart.parent) && (type != EVAS_CALLBACK_FREE) &&
|
|
|
|
(type <= EVAS_CALLBACK_KEY_UP))
|
|
|
|
evas_object_event_callback_call(obj->smart.parent, type, event_info);
|
|
|
|
}
|
2007-04-29 21:22:42 -07:00
|
|
|
}
|
|
|
|
_evas_unwalk(e);
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2004-08-23 16:04:34 -07:00
|
|
|
|
2008-11-01 14:50:36 -07:00
|
|
|
/**
|
2010-03-17 21:57:40 -07:00
|
|
|
* @addtogroup Evas_Object_Group_Events
|
2008-11-01 14:50:36 -07:00
|
|
|
* @{
|
2004-08-23 16:04:34 -07:00
|
|
|
*/
|
|
|
|
|
2002-11-23 20:06:08 -08:00
|
|
|
/**
|
|
|
|
* Add a callback function to an object
|
2009-09-17 15:38:10 -07:00
|
|
|
*
|
2002-11-23 20:06:08 -08:00
|
|
|
* @param obj Object to attach a callback to
|
|
|
|
* @param type The type of event that will trigger the callback
|
|
|
|
* @param func The function to be called when the event is triggered
|
|
|
|
* @param data The data pointer to be passed to @p func
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2009-09-17 15:38:10 -07:00
|
|
|
* This function adds a function callback to an object when the event
|
|
|
|
* of type @p type occurs on object @p obj. The function is @p func.
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2009-09-17 15:38:10 -07:00
|
|
|
* In the event of a memory allocation error during addition of the
|
|
|
|
* callback to the object, evas_alloc_error() should be used to
|
|
|
|
* determine the nature of the error, if any, and the program should
|
|
|
|
* sensibly try and recover.
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2009-09-17 15:38:10 -07:00
|
|
|
* The function will be passed the pointer @p data when it is
|
|
|
|
* called. A callback function must look like this:
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2002-11-23 20:06:08 -08:00
|
|
|
* @code
|
|
|
|
* void callback (void *data, Evas *e, Evas_Object *obj, void *event_info);
|
|
|
|
* @endcode
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2009-09-17 15:38:10 -07:00
|
|
|
* The first parameter @p data in this function will be the same value
|
|
|
|
* passed to evas_object_event_callback_add() as the @p data
|
|
|
|
* parameter. The second parameter is a convenience for the programmer
|
2010-09-07 20:51:24 -07:00
|
|
|
* to know what evas canvas the event occurred on. The third parameter
|
|
|
|
* @p obj is the Object handle on which the event occurred. The foruth
|
2009-09-17 15:38:10 -07:00
|
|
|
* parameter @p event_info is a pointer to a data structure that may
|
|
|
|
* or may not be passed to the callback, depending on the event type
|
|
|
|
* that triggered the callback.
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
|
|
|
* The event type @p type to trigger the function may be one of
|
2010-03-17 21:57:40 -07:00
|
|
|
* #EVAS_CALLBACK_MOUSE_IN, #EVAS_CALLBACK_MOUSE_OUT,
|
|
|
|
* #EVAS_CALLBACK_MOUSE_DOWN, #EVAS_CALLBACK_MOUSE_UP,
|
|
|
|
* #EVAS_CALLBACK_MOUSE_MOVE, #EVAS_CALLBACK_MOUSE_WHEEL,
|
|
|
|
* #EVAS_CALLBACK_FREE, #EVAS_CALLBACK_KEY_DOWN, #EVAS_CALLBACK_KEY_UP,
|
|
|
|
* #EVAS_CALLBACK_FOCUS_IN, #EVAS_CALLBACK_FOCUS_OUT,
|
|
|
|
* #EVAS_CALLBACK_SHOW, #EVAS_CALLBACK_HIDE, #EVAS_CALLBACK_MOVE,
|
|
|
|
* #EVAS_CALLBACK_RESIZE or #EVAS_CALLBACK_RESTACK.
|
2009-09-17 15:38:10 -07:00
|
|
|
* This determines the kind of event that will trigger the callback to
|
|
|
|
* be called. The @p event_info pointer passed to the callback will
|
|
|
|
* be one of the following, depending on the event triggering it:
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2010-03-17 21:57:40 -07:00
|
|
|
* #EVAS_CALLBACK_MOUSE_IN: event_info = pointer to Evas_Event_Mouse_In
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
|
|
|
* This event is triggered when the mouse pointer enters the region of
|
2009-09-17 15:38:10 -07:00
|
|
|
* the object @p obj. This may occur by the mouse pointer being moved
|
|
|
|
* by evas_event_feed_mouse_move() or
|
|
|
|
* evas_event_feed_mouse_move_data() calls, or by the object being
|
|
|
|
* shown, raised, moved, resized, or other objects being moved out of
|
|
|
|
* the way, hidden, lowered or moved out of the way.
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2010-03-17 21:57:40 -07:00
|
|
|
* #EVAS_CALLBACK_MOUSE_OUT: event_info = pointer to Evas_Event_Mouse_Out
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2010-03-17 21:57:40 -07:00
|
|
|
* This event is triggered exactly like #EVAS_CALLBACK_MOUSE_IN is, but
|
2009-09-17 15:38:10 -07:00
|
|
|
* occurs when the mouse pointer exits an object. Note that no out
|
|
|
|
* events will be reported if the mouse pointer is implicitly grabbed
|
|
|
|
* to an object (the mouse buttons are down at all and any were
|
|
|
|
* pressed on that object). An out event will be reported as soon as
|
|
|
|
* the mouse is no longer grabbed (no mouse buttons are
|
|
|
|
* depressed). Out events will be reported once all buttons are
|
|
|
|
* released, if the mouse has left the object.
|
|
|
|
*
|
2010-03-17 21:57:40 -07:00
|
|
|
* #EVAS_CALLBACK_MOUSE_DOWN: event_info = pointer to
|
2009-09-17 15:38:10 -07:00
|
|
|
* Evas_Event_Mouse_Down
|
|
|
|
*
|
|
|
|
* This event is triggered by a mouse button being depressed while
|
|
|
|
* over an object. If pointermode is EVAS_OBJECT_POINTER_MODE_AUTOGRAB
|
|
|
|
* (default) this causes this object to passively grab the mouse until
|
|
|
|
* all mouse buttons have been released. That means if this mouse
|
|
|
|
* button is the first to be pressed, all future mouse events will be
|
|
|
|
* reported to only this object until no buttons are down. That
|
|
|
|
* includes mouse move events, in and out events, and further button
|
|
|
|
* presses. When all buttons are released, event propagation occurs as
|
|
|
|
* normal.
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2010-03-17 21:57:40 -07:00
|
|
|
* #EVAS_CALLBACK_MOUSE_UP: event_info = pointer to Evas_Event_Mouse_Up
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2009-09-17 15:38:10 -07:00
|
|
|
* This event is triggered by a mouse button being released while over
|
|
|
|
* an object or when passively grabbed to an object. If this is the
|
|
|
|
* last mouse button to be raised on an object then the passive grab
|
|
|
|
* is released and event processing will continue as normal.
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2010-03-17 21:57:40 -07:00
|
|
|
* #EVAS_CALLBACK_MOUSE_MOVE: event_info = pointer to Evas_Event_Mouse_Move
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2009-09-17 15:38:10 -07:00
|
|
|
* This event is triggered by the mouse pointer moving while over an
|
|
|
|
* object or passively grabbed to an object.
|
2003-05-25 02:43:53 -07:00
|
|
|
*
|
2010-03-17 21:57:40 -07:00
|
|
|
* #EVAS_CALLBACK_MOUSE_WHEEL: event_info = pointer to
|
2009-09-17 15:38:10 -07:00
|
|
|
* Evas_Event_Mouse_Wheel
|
2003-05-25 02:43:53 -07:00
|
|
|
*
|
2009-09-17 15:38:10 -07:00
|
|
|
* This event is triggered by the mouse wheel being rolled while over
|
|
|
|
* an object or passively grabbed to an object.
|
2003-05-25 02:43:53 -07:00
|
|
|
*
|
2010-03-17 21:57:40 -07:00
|
|
|
* #EVAS_CALLBACK_FREE: event_info = NULL
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2009-09-17 15:38:10 -07:00
|
|
|
* This event is triggered just before Evas is about to free all
|
|
|
|
* memory used by an object and remove all references to it. This is
|
|
|
|
* useful for programs to use if they attached data to an object and
|
|
|
|
* want to free it when the object is deleted. The object is still
|
|
|
|
* valid when this callback is called, but after this callback
|
|
|
|
* returns, there is no guarantee on the object's validity.
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2010-03-17 21:57:40 -07:00
|
|
|
* #EVAS_CALLBACK_KEY_DOWN: event_info = pointer to Evas_Event_Key_Down
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2009-09-17 15:38:10 -07:00
|
|
|
* This callback is called when a key is pressed and the focus is on
|
|
|
|
* the object, or a key has been grabbed to a particular object which
|
|
|
|
* wants to intercept the key press regardless of what object has the
|
|
|
|
* focus.
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2010-03-17 21:57:40 -07:00
|
|
|
* #EVAS_CALLBACK_KEY_UP: event_info = pointer to Evas_Event_Key_Up
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2009-09-17 15:38:10 -07:00
|
|
|
* This callback is called when a key is released and the focus is on
|
|
|
|
* the object, or a key has been grabbed to a particular object which
|
|
|
|
* wants to intercept the key release regardless of what object has
|
|
|
|
* the focus.
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2010-03-17 21:57:40 -07:00
|
|
|
* #EVAS_CALLBACK_FOCUS_IN: event_info = NULL
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2009-09-17 15:38:10 -07:00
|
|
|
* This event is called when an object gains the focus. When the
|
|
|
|
* callback is called the object has already gained the focus.
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2010-03-17 21:57:40 -07:00
|
|
|
* #EVAS_CALLBACK_FOCUS_OUT: event_info = NULL
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2009-09-17 15:38:10 -07:00
|
|
|
* This event is triggered by an object losing the focus. When the
|
|
|
|
* callback is called the object has already lost the focus.
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2010-03-17 21:57:40 -07:00
|
|
|
* #EVAS_CALLBACK_SHOW: event_info = NULL
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2009-09-17 15:38:10 -07:00
|
|
|
* This event is triggered by the object being shown by
|
|
|
|
* evas_object_show().
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2010-03-17 21:57:40 -07:00
|
|
|
* #EVAS_CALLBACK_HIDE: event_info = NULL
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2009-09-17 15:38:10 -07:00
|
|
|
* This event is triggered by an object being hidden by
|
|
|
|
* evas_object_hide().
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2010-03-17 21:57:40 -07:00
|
|
|
* #EVAS_CALLBACK_MOVE: event_info = NULL
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2009-09-17 15:38:10 -07:00
|
|
|
* This event is triggered by an object being
|
|
|
|
* moved. evas_object_move() can trigger this, as can any
|
|
|
|
* object-specific manipulations that would mean the object's origin
|
|
|
|
* could move.
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2010-03-17 21:57:40 -07:00
|
|
|
* #EVAS_CALLBACK_RESIZE: event_info = NULL
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2002-12-14 16:33:57 -08:00
|
|
|
* This event is triggered by an object being resized. Resizes can be
|
2009-09-17 15:38:10 -07:00
|
|
|
* triggered by evas_object_resize() or by any object-specific calls
|
|
|
|
* that may cause the object to resize.
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2002-11-23 20:06:08 -08:00
|
|
|
* Example:
|
|
|
|
* @code
|
|
|
|
* extern Evas_Object *object;
|
|
|
|
* extern void *my_data;
|
|
|
|
* void down_callback(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
|
|
|
* void up_callback(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2002-11-23 20:06:08 -08:00
|
|
|
* evas_object_event_callback_add(object, EVAS_CALLBACK_MOUSE_UP, up_callback, my_data);
|
2002-12-01 15:48:19 -08:00
|
|
|
* if (evas_alloc_error() != EVAS_ALLOC_ERROR_NONE)
|
|
|
|
* {
|
|
|
|
* fprintf(stderr, "ERROR: Callback registering failed! Abort!\n");
|
|
|
|
* exit(-1);
|
|
|
|
* }
|
2002-11-23 20:06:08 -08:00
|
|
|
* evas_object_event_callback_add(object, EVAS_CALLBACK_MOUSE_DOWN, down_callback, my_data);
|
2002-12-01 15:48:19 -08:00
|
|
|
* if (evas_alloc_error() != EVAS_ALLOC_ERROR_NONE)
|
|
|
|
* {
|
|
|
|
* fprintf(stderr, "ERROR: Callback registering failed! Abort!\n");
|
|
|
|
* exit(-1);
|
|
|
|
* }
|
2002-11-23 20:06:08 -08:00
|
|
|
* @endcode
|
|
|
|
*/
|
2006-01-06 15:05:17 -08:00
|
|
|
EAPI void
|
2010-02-16 04:59:37 -08:00
|
|
|
evas_object_event_callback_add(Evas_Object *obj, Evas_Callback_Type type, Evas_Object_Event_Cb func, const void *data)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2002-11-23 20:06:08 -08:00
|
|
|
/* MEM OK */
|
2002-11-08 00:02:15 -08:00
|
|
|
Evas_Func_Node *fn;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
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
|
|
|
|
2002-11-23 20:06:08 -08:00
|
|
|
fn = evas_mem_calloc(sizeof(Evas_Func_Node));
|
2002-11-08 00:02:15 -08:00
|
|
|
if (!fn) return;
|
|
|
|
fn->func = func;
|
2003-01-09 20:58:51 -08:00
|
|
|
fn->data = (void *)data;
|
2007-01-22 04:44:57 -08:00
|
|
|
fn->type = type;
|
2002-12-14 16:33:57 -08:00
|
|
|
|
2003-02-08 20:22:45 -08:00
|
|
|
if (!obj->callbacks)
|
|
|
|
obj->callbacks = evas_mem_calloc(sizeof(Evas_Callbacks));
|
|
|
|
if (!obj->callbacks)
|
|
|
|
{
|
|
|
|
free(fn);
|
|
|
|
return;
|
|
|
|
}
|
2009-09-03 22:13:19 -07:00
|
|
|
obj->callbacks->callbacks =
|
2009-10-15 13:50:15 -07:00
|
|
|
eina_inlist_prepend(obj->callbacks->callbacks, EINA_INLIST_GET(fn));
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2002-11-25 23:28:02 -08:00
|
|
|
/**
|
2003-01-29 15:37:10 -08:00
|
|
|
* Delete a callback function from an object
|
2009-09-17 15:38:10 -07:00
|
|
|
*
|
2002-11-25 23:28:02 -08:00
|
|
|
* @param obj Object to remove a callback from
|
|
|
|
* @param type The type of event that was triggering the callback
|
|
|
|
* @param func The function that was to be called when the event was triggered
|
2004-02-16 11:22:48 -08:00
|
|
|
* @return The data pointer that was to be passed to the callback
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2009-09-17 15:38:10 -07:00
|
|
|
* This function removes the most recently added callback from the
|
|
|
|
* object @p obj which was triggered by the event type @p type and was
|
|
|
|
* calling the function @p func when triggered. If the removal is
|
|
|
|
* successful it will also return the data pointer that was passed to
|
|
|
|
* evas_object_event_callback_add() when the callback was added to the
|
|
|
|
* object. If not successful NULL will be returned.
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2002-11-25 23:28:02 -08:00
|
|
|
* Example:
|
|
|
|
* @code
|
|
|
|
* extern Evas_Object *object;
|
|
|
|
* void *my_data;
|
|
|
|
* void up_callback(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2002-11-25 23:28:02 -08:00
|
|
|
* my_data = evas_object_event_callback_del(object, EVAS_CALLBACK_MOUSE_UP, up_callback);
|
|
|
|
* @endcode
|
|
|
|
*/
|
2006-01-06 15:05:17 -08:00
|
|
|
EAPI void *
|
2010-02-16 04:59:37 -08:00
|
|
|
evas_object_event_callback_del(Evas_Object *obj, Evas_Callback_Type type, Evas_Object_Event_Cb func)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2002-11-23 20:06:08 -08:00
|
|
|
/* MEM OK */
|
2008-10-20 05:36:48 -07:00
|
|
|
Evas_Func_Node *fn;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return NULL;
|
|
|
|
MAGIC_CHECK_END();
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
if (!func) return NULL;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2003-02-08 20:22:45 -08:00
|
|
|
if (!obj->callbacks) return NULL;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2008-10-21 05:19:57 -07:00
|
|
|
EINA_INLIST_FOREACH(obj->callbacks->callbacks, fn)
|
2007-01-22 04:44:57 -08:00
|
|
|
{
|
|
|
|
if ((fn->func == func) && (fn->type == type) && (!fn->delete_me))
|
|
|
|
{
|
|
|
|
void *data;
|
|
|
|
|
|
|
|
data = fn->data;
|
|
|
|
fn->delete_me = 1;
|
|
|
|
obj->callbacks->deletions_waiting = 1;
|
|
|
|
if (!obj->callbacks->walking_list)
|
|
|
|
evas_object_event_callback_clear(obj);
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
}
|
2002-11-08 00:02:15 -08:00
|
|
|
return NULL;
|
|
|
|
}
|
2008-06-03 13:33:40 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete a callback function from an object
|
2009-09-17 15:38:10 -07:00
|
|
|
*
|
2008-06-03 13:33:40 -07:00
|
|
|
* @param obj Object to remove a callback from
|
|
|
|
* @param type The type of event that was triggering the callback
|
|
|
|
* @param func The function that was to be called when the event was triggered
|
|
|
|
* @param data The data pointer that was to be passed to the callback
|
|
|
|
* @return The data pointer that was to be passed to the callback
|
|
|
|
*
|
2009-09-17 15:38:10 -07:00
|
|
|
* This function removes the most recently added callback from the
|
|
|
|
* object @p obj which was triggered by the event type @p type and was
|
|
|
|
* calling the function @p func with data @p data when triggered. If
|
|
|
|
* the removal is successful it will also return the data pointer that
|
|
|
|
* was passed to evas_object_event_callback_add() (that will be the
|
|
|
|
* same as the parameter) when the callback was added to the
|
|
|
|
* object. If not successful NULL will be returned.
|
2008-06-03 13:33:40 -07:00
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* @code
|
|
|
|
* extern Evas_Object *object;
|
|
|
|
* void *my_data;
|
|
|
|
* void up_callback(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
|
|
|
*
|
|
|
|
* my_data = evas_object_event_callback_del_full(object, EVAS_CALLBACK_MOUSE_UP, up_callback, data);
|
|
|
|
* @endcode
|
|
|
|
*/
|
|
|
|
EAPI void *
|
2010-02-16 04:59:37 -08:00
|
|
|
evas_object_event_callback_del_full(Evas_Object *obj, Evas_Callback_Type type, Evas_Object_Event_Cb func, const void *data)
|
2008-06-03 13:33:40 -07:00
|
|
|
{
|
|
|
|
/* MEM OK */
|
2008-10-20 05:36:48 -07:00
|
|
|
Evas_Func_Node *fn;
|
2008-06-03 13:33:40 -07:00
|
|
|
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return NULL;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
|
|
|
if (!func) return NULL;
|
|
|
|
|
|
|
|
if (!obj->callbacks) return NULL;
|
|
|
|
|
2008-10-21 05:19:57 -07:00
|
|
|
EINA_INLIST_FOREACH(obj->callbacks->callbacks, fn)
|
2008-06-03 13:33:40 -07:00
|
|
|
{
|
|
|
|
if ((fn->func == func) && (fn->type == type) && (fn->data == data) && (!fn->delete_me))
|
|
|
|
{
|
|
|
|
void *data;
|
|
|
|
|
|
|
|
data = fn->data;
|
|
|
|
fn->delete_me = 1;
|
|
|
|
obj->callbacks->deletions_waiting = 1;
|
|
|
|
if (!obj->callbacks->walking_list)
|
|
|
|
evas_object_event_callback_clear(obj);
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2008-11-01 14:50:36 -07:00
|
|
|
|
2010-03-17 21:57:40 -07:00
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @addtogroup Evas_Canvas_Events
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a callback function to the canvas.
|
|
|
|
*
|
|
|
|
* @param e Canvas to attach a callback to
|
|
|
|
* @param type The type of event that will trigger the callback
|
|
|
|
* @param func The function to be called when the event is triggered
|
|
|
|
* @param data The data pointer to be passed to @p func
|
|
|
|
*
|
|
|
|
* This function adds a function callback to the canvas when the event
|
|
|
|
* of type @p type occurs on canvas @p e. The function is @p func.
|
|
|
|
*
|
|
|
|
* In the event of a memory allocation error during addition of the
|
|
|
|
* callback to the canvas, evas_alloc_error() should be used to
|
|
|
|
* determine the nature of the error, if any, and the program should
|
|
|
|
* sensibly try and recover.
|
|
|
|
*
|
|
|
|
* The function will be passed the pointer @p data when it is
|
|
|
|
* called. A callback function must look like this:
|
|
|
|
*
|
|
|
|
* @code
|
|
|
|
* void callback (void *data, Evas *e, void *event_info);
|
|
|
|
* @endcode
|
|
|
|
*
|
|
|
|
* The first parameter @p data in this function will be the same value
|
|
|
|
* passed to evas_event_callback_add() as the @p data parameter. The
|
|
|
|
* second parameter @p e is the canvas handle on which the event
|
2010-09-07 20:51:24 -07:00
|
|
|
* occurred. The third parameter @p event_info is a pointer to a data
|
2010-03-17 21:57:40 -07:00
|
|
|
* structure that may or may not be passed to the callback, depending
|
|
|
|
* on the event type that triggered the callback.
|
|
|
|
*
|
|
|
|
* The event type @p type to trigger the function may be one of
|
|
|
|
* #EVAS_CALLBACK_RENDER_FLUSH_PRE, #EVAS_CALLBACK_RENDER_FLUSH_POST,
|
|
|
|
* #EVAS_CALLBACK_CANVAS_FOCUS_IN, #EVAS_CALLBACK_CANVAS_FOCUS_OUT.
|
|
|
|
* This determines the kind of event that will trigger the callback to
|
|
|
|
* be called. So far none of the event types provide useful data, so
|
|
|
|
* in all of them @p event_info pointer is @c NULL.
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* @code
|
|
|
|
* extern Evas *e;
|
|
|
|
* extern void *my_data;
|
|
|
|
* void focus_in_callback(void *data, Evas *e, void *event_info);
|
|
|
|
* void focus_out_callback(void *data, Evas *e, void *event_info);
|
|
|
|
*
|
|
|
|
* evas_event_callback_add(e, EVAS_CALLBACK_CANVAS_FOCUS_IN, focus_in_callback, my_data);
|
|
|
|
* if (evas_alloc_error() != EVAS_ALLOC_ERROR_NONE)
|
|
|
|
* {
|
|
|
|
* fprintf(stderr, "ERROR: Callback registering failed! Abort!\n");
|
|
|
|
* exit(-1);
|
|
|
|
* }
|
|
|
|
* evas_event_callback_add(e, EVAS_CALLBACK_CANVAS_FOCUS_OUT, focus_out_callback, my_data);
|
|
|
|
* if (evas_alloc_error() != EVAS_ALLOC_ERROR_NONE)
|
|
|
|
* {
|
|
|
|
* fprintf(stderr, "ERROR: Callback registering failed! Abort!\n");
|
|
|
|
* exit(-1);
|
|
|
|
* }
|
|
|
|
* @endcode
|
|
|
|
*/
|
2010-01-31 20:26:55 -08:00
|
|
|
EAPI void
|
2010-02-16 04:59:37 -08:00
|
|
|
evas_event_callback_add(Evas *e, Evas_Callback_Type type, Evas_Event_Cb func, const void *data)
|
2010-01-31 20:26:55 -08:00
|
|
|
{
|
|
|
|
/* MEM OK */
|
|
|
|
Evas_Func_Node *fn;
|
|
|
|
|
|
|
|
MAGIC_CHECK(e, Evas, MAGIC_EVAS);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
|
|
|
if (!func) return;
|
|
|
|
|
|
|
|
fn = evas_mem_calloc(sizeof(Evas_Func_Node));
|
|
|
|
if (!fn) return;
|
|
|
|
fn->func = func;
|
|
|
|
fn->data = (void *)data;
|
|
|
|
fn->type = type;
|
|
|
|
|
|
|
|
if (!e->callbacks)
|
|
|
|
e->callbacks = evas_mem_calloc(sizeof(Evas_Callbacks));
|
|
|
|
if (!e->callbacks)
|
|
|
|
{
|
|
|
|
free(fn);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
e->callbacks->callbacks =
|
|
|
|
eina_inlist_prepend(e->callbacks->callbacks, EINA_INLIST_GET(fn));
|
|
|
|
}
|
|
|
|
|
2010-03-17 21:57:40 -07:00
|
|
|
/**
|
|
|
|
* Delete a callback function from the canvas.
|
|
|
|
*
|
|
|
|
* @param e Canvas to remove a callback from
|
|
|
|
* @param type The type of event that was triggering the callback
|
|
|
|
* @param func The function that was to be called when the event was triggered
|
|
|
|
* @return The data pointer that was to be passed to the callback
|
|
|
|
*
|
|
|
|
* This function removes the most recently added callback from the
|
|
|
|
* canvas @p e which was triggered by the event type @p type and was
|
|
|
|
* calling the function @p func when triggered. If the removal is
|
|
|
|
* successful it will also return the data pointer that was passed to
|
|
|
|
* evas_event_callback_add() when the callback was added to the
|
|
|
|
* canvas. If not successful NULL will be returned.
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* @code
|
|
|
|
* extern Evas *e;
|
|
|
|
* void *my_data;
|
|
|
|
* void focus_in_callback(void *data, Evas *e, void *event_info);
|
|
|
|
*
|
|
|
|
* my_data = evas_event_callback_del(ebject, EVAS_CALLBACK_CANVAS_FOCUS_IN, focus_in_callback);
|
|
|
|
* @endcode
|
|
|
|
*/
|
2010-01-31 20:26:55 -08:00
|
|
|
EAPI void *
|
2010-02-16 04:59:37 -08:00
|
|
|
evas_event_callback_del(Evas *e, Evas_Callback_Type type, Evas_Event_Cb func)
|
2010-01-31 20:26:55 -08:00
|
|
|
{
|
|
|
|
/* MEM OK */
|
|
|
|
Evas_Func_Node *fn;
|
|
|
|
|
|
|
|
MAGIC_CHECK(e, Evas, MAGIC_EVAS);
|
|
|
|
return NULL;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
|
|
|
if (!func) return NULL;
|
|
|
|
|
|
|
|
if (!e->callbacks) return NULL;
|
|
|
|
|
|
|
|
EINA_INLIST_FOREACH(e->callbacks->callbacks, fn)
|
|
|
|
{
|
|
|
|
if ((fn->func == func) && (fn->type == type) && (!fn->delete_me))
|
|
|
|
{
|
|
|
|
void *data;
|
|
|
|
|
|
|
|
data = fn->data;
|
|
|
|
fn->delete_me = 1;
|
|
|
|
e->callbacks->deletions_waiting = 1;
|
2010-03-21 22:33:46 -07:00
|
|
|
if (!e->callbacks->walking_list)
|
|
|
|
evas_event_callback_clear(e);
|
2010-01-31 20:26:55 -08:00
|
|
|
return data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-03-17 21:57:40 -07:00
|
|
|
/**
|
|
|
|
* Delete a callback function from the canvas.
|
|
|
|
*
|
|
|
|
* @param e Canvas to remove a callback from
|
|
|
|
* @param type The type of event that was triggering the callback
|
|
|
|
* @param func The function that was to be called when the event was triggered
|
|
|
|
* @param data The data pointer that was to be passed to the callback
|
|
|
|
* @return The data pointer that was to be passed to the callback
|
|
|
|
*
|
|
|
|
* This function removes the most recently added callback from the
|
|
|
|
* canvas @p e which was triggered by the event type @p type and was
|
|
|
|
* calling the function @p func with data @p data when triggered. If
|
|
|
|
* the removal is successful it will also return the data pointer that
|
|
|
|
* was passed to evas_event_callback_add() (that will be the same as
|
|
|
|
* the parameter) when the callback was added to the canvas. If not
|
|
|
|
* successful NULL will be returned.
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* @code
|
|
|
|
* extern Evas *e;
|
|
|
|
* void *my_data;
|
|
|
|
* void focus_in_callback(void *data, Evas *e, void *event_info);
|
|
|
|
*
|
|
|
|
* my_data = evas_event_callback_del_full(ebject, EVAS_CALLBACK_CANVAS_FOCUS_IN, focus_in_callback, my_data);
|
|
|
|
* @endcode
|
|
|
|
*/
|
2010-01-31 20:26:55 -08:00
|
|
|
EAPI void *
|
2010-02-16 04:59:37 -08:00
|
|
|
evas_event_callback_del_full(Evas *e, Evas_Callback_Type type, Evas_Event_Cb func, const void *data)
|
2010-01-31 20:26:55 -08:00
|
|
|
{
|
|
|
|
/* MEM OK */
|
|
|
|
Evas_Func_Node *fn;
|
|
|
|
|
|
|
|
MAGIC_CHECK(e, Evas, MAGIC_EVAS);
|
|
|
|
return NULL;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
|
|
|
if (!func) return NULL;
|
|
|
|
|
|
|
|
if (!e->callbacks) return NULL;
|
|
|
|
|
|
|
|
EINA_INLIST_FOREACH(e->callbacks->callbacks, fn)
|
|
|
|
{
|
|
|
|
if ((fn->func == func) && (fn->type == type) && (fn->data == data) && (!fn->delete_me))
|
|
|
|
{
|
|
|
|
void *data;
|
|
|
|
|
|
|
|
data = fn->data;
|
|
|
|
fn->delete_me = 1;
|
|
|
|
e->callbacks->deletions_waiting = 1;
|
2010-03-21 22:33:46 -07:00
|
|
|
if (!e->callbacks->walking_list)
|
|
|
|
evas_event_callback_clear(e);
|
2010-01-31 20:26:55 -08:00
|
|
|
return data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-05-04 08:58:10 -07:00
|
|
|
/**
|
|
|
|
* Push a callback on the post-event callback stack
|
|
|
|
*
|
|
|
|
* @param e Canvas to push the callback on
|
|
|
|
* @param func The function that to be called when the stack is unwound
|
|
|
|
* @param data The data pointer to be passed to the callback
|
|
|
|
*
|
|
|
|
* Evas has a stack of callbacks that get called after all the callbacks for
|
|
|
|
* an event have triggered (all the objects it triggers on and al the callbacks
|
|
|
|
* in each object triggered). When all these have been called, the stack is
|
|
|
|
* unwond from most recently to least recently pushed item and removed from the
|
|
|
|
* stack calling the callback set for it.
|
|
|
|
*
|
|
|
|
* This is intended for doing reverse logic-like processing, example - when a
|
|
|
|
* child object that happens to get the event later is meant to be able to
|
|
|
|
* "steal" functions from a parent and thus on unwind of this stack hav its
|
|
|
|
* function called first, thus being able to set flags, or return 0 from the
|
|
|
|
* post-callback that stops all other post-callbacks in the current stack from
|
|
|
|
* being called (thus basically allowing a child to take control, if the event
|
|
|
|
* callback prepares information ready for taking action, but the post callback
|
|
|
|
* actually does the action).
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
EAPI void
|
|
|
|
evas_post_event_callback_push(Evas *e, Evas_Object_Event_Post_Cb func, const void *data)
|
|
|
|
{
|
|
|
|
Evas_Post_Callback *pc;
|
|
|
|
|
|
|
|
MAGIC_CHECK(e, Evas, MAGIC_EVAS);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
|
|
|
pc = evas_mem_calloc(sizeof(Evas_Post_Callback));
|
|
|
|
if (!pc) return;
|
|
|
|
if (e->delete_me) return;
|
|
|
|
|
|
|
|
pc->func = func;
|
|
|
|
pc->data = data;
|
|
|
|
e->post_events = eina_list_prepend(e->post_events, pc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove a callback from the post-event callback stack
|
|
|
|
*
|
|
|
|
* @param e Canvas to push the callback on
|
|
|
|
* @param func The function that to be called when the stack is unwound
|
|
|
|
*
|
|
|
|
* This removes a callback from the stack added with
|
|
|
|
* evas_post_event_callback_push(). The first instance of the function in
|
|
|
|
* the callback stack is removed from being executed when the stack is
|
|
|
|
* unwound. Further instances may still be run on unwind.
|
|
|
|
*/
|
|
|
|
EAPI void
|
|
|
|
evas_post_event_callback_remove(Evas *e, Evas_Object_Event_Post_Cb func)
|
|
|
|
{
|
|
|
|
Evas_Post_Callback *pc;
|
|
|
|
Eina_List *l;
|
|
|
|
|
|
|
|
MAGIC_CHECK(e, Evas, MAGIC_EVAS);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(e->post_events, l, pc)
|
|
|
|
{
|
|
|
|
if (pc->func == func)
|
|
|
|
{
|
|
|
|
pc->delete_me = 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove a callback from the post-event callback stack
|
|
|
|
*
|
|
|
|
* @param e Canvas to push the callback on
|
|
|
|
* @param func The function that to be called when the stack is unwound
|
|
|
|
* @param data The data pointer to be passed to the callback
|
|
|
|
*
|
|
|
|
* This removes a callback from the stack added with
|
|
|
|
* evas_post_event_callback_push(). The first instance of the function and data
|
|
|
|
* in the callback stack is removed from being executed when the stack is
|
|
|
|
* unwound. Further instances may still be run on unwind.
|
|
|
|
*/
|
|
|
|
EAPI void
|
|
|
|
evas_post_event_callback_remove_full(Evas *e, Evas_Object_Event_Post_Cb func, const void *data)
|
|
|
|
{
|
|
|
|
Evas_Post_Callback *pc;
|
|
|
|
Eina_List *l;
|
|
|
|
|
|
|
|
MAGIC_CHECK(e, Evas, MAGIC_EVAS);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(e->post_events, l, pc)
|
|
|
|
{
|
|
|
|
if ((pc->func == func) && (pc->data == data))
|
|
|
|
{
|
|
|
|
pc->delete_me = 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-11-01 14:50:36 -07:00
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|