diff --git a/legacy/evas/ChangeLog b/legacy/evas/ChangeLog index 1fbbb3c178..f05479c59e 100644 --- a/legacy/evas/ChangeLog +++ b/legacy/evas/ChangeLog @@ -1039,3 +1039,8 @@ 2012-09-14 Carsten Haitzler (The Rasterman) * Add env EVAS_GL_NO_BLACKLIST to disable blacklisting. + +2012-09-17 Carsten Haitzler (The Rasterman) + + * Add evas_device API for being able to register devices, set + their names, descriptions, classes, parents, sources etc. etc. diff --git a/legacy/evas/NEWS b/legacy/evas/NEWS index cbcef4135e..489617dc53 100644 --- a/legacy/evas/NEWS +++ b/legacy/evas/NEWS @@ -7,6 +7,7 @@ Additions: * WEBP image loader support. * EVAS_CALLBACK_IMAGE_RESIZE. + * Evas_Device registration/manipulation/querying API Improvements: diff --git a/legacy/evas/src/lib/Evas.h b/legacy/evas/src/lib/Evas.h index 5096e45492..3a6e1243b8 100644 --- a/legacy/evas/src/lib/Evas.h +++ b/legacy/evas/src/lib/Evas.h @@ -446,6 +446,7 @@ typedef enum _Evas_Callback_Type EVAS_CALLBACK_RENDER_POST, /**< Called just after rendering stops on the canvas target @since 1.2 */ EVAS_CALLBACK_IMAGE_RESIZE, /**< Image size is changed @since 1.8 */ + EVAS_CALLBACK_DEVICE_CHANGED, /**< Devices added, removed or changed on canvas @since 1.8 */ EVAS_CALLBACK_LAST /**< kept as last element/sentinel -- not really an event */ } Evas_Callback_Type; /**< The types of events triggering a callback */ @@ -880,6 +881,18 @@ typedef enum _Evas_Image_Content_Hint EVAS_IMAGE_CONTENT_HINT_STATIC = 2 /**< The contents won't change over time */ } Evas_Image_Content_Hint; /**< How an image's data is to be treated by Evas, for optimization */ +typedef enum _Evas_Device_Class +{ + EVAS_DEVICE_CLASS_NONE, /**< Not a device @since 1.8 */ + EVAS_DEVICE_CLASS_SEAT, /**< The user/seat (the user themselves) @since 1.8 */ + EVAS_DEVICE_CLASS_KEYBOARD, /**< A regular keyboard, numberpad or attached buttons @since 1.8 */ + EVAS_DEVICE_CLASS_MOUSE, /**< A mouse, trackball or touchpad relative motion device @since 1.8 */ + EVAS_DEVICE_CLASS_TOUCH, /**< A touchscreen with fingers or stylus @since 1.8 */ + EVAS_DEVICE_CLASS_PEN, /**< A special pen device @since 1.8 */ + EVAS_DEVICE_CLASS_POINTER, /**< A laser pointer, wii-style or "minority report" pointing device @since 1.8 */ + EVAS_DEVICE_CLASS_GAMEPAD /**< A gamepad controller or joystick @since 1.8 */ +} Evas_Device_Class; + struct _Evas_Engine_Info /** Generic engine information. Generic info is useless */ { int magic; /**< Magic number */ @@ -2162,8 +2175,9 @@ EAPI int evas_pointer_button_down_mask_get(const Evas *e) EINA_WAR * @endcode */ EAPI Eina_Bool evas_pointer_inside_get(const Evas *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); -EAPI void evas_sync(Evas *e) EINA_ARG_NONNULL(1); +EAPI void evas_sync(Evas *e) EINA_ARG_NONNULL(1); + /** * @defgroup Evas_Canvas_Events Canvas Events * @@ -2544,6 +2558,81 @@ EAPI void evas_event_thaw_eval(Evas *e) EINA_ARG_NONNULL(1); * @{ */ +/** + * @since 1.8 + */ +EAPI Evas_Device *evas_device_new(Evas *e); + +/** + * @since 1.8 + */ +EAPI void evas_device_free(Evas_Device *dev); + +/** + * @since 1.8 + */ +EAPI void evas_device_push(Evas *e, Evas_Device *dev); + +/** + * @since 1.8 + */ +EAPI void evas_device_pop(Evas *e); + +/** + * @since 1.8 + */ +EAPI const Eina_List *evas_device_list(Evas *e, const Evas_Device *dev); + +/** + * @since 1.8 + */ +EAPI void evas_device_name_set(Evas_Device *dev, const char *name); + +/** + * @since 1.8 + */ +EAPI const char *evas_device_name_get(const Evas_Device *dev); + +/** + * @since 1.8 + */ +EAPI void evas_device_description_set(Evas_Device *dev, const char *desc); + +/** + * @since 1.8 + */ +EAPI const char *evas_device_description_get(const Evas_Device *dev); + +/** + * @since 1.8 + */ +EAPI void evas_device_parent_set(Evas_Device *dev, Evas_Device *parent); + +/** + * @since 1.8 + */ +EAPI const Evas_Device *evas_device_parent_get(const Evas_Device *dev); + +/** + * @since 1.8 + */ +EAPI void evas_device_class_set(Evas_Device *dev, Evas_Device_Class clas); + +/** + * @since 1.8 + */ +EAPI Evas_Device_Class evas_device_class_get(const Evas_Device *dev); + +/** + * @since 1.8 + */ +EAPI void evas_device_emulation_source_set(Evas_Device *dev, Evas_Device *src); + +/** + * @since 1.8 + */ +EAPI const Evas_Device *evas_device_emulation_source_get(const Evas_Device *dev); + /** * Get the number of mouse or multi presses currently active * diff --git a/legacy/evas/src/lib/canvas/Makefile.am b/legacy/evas/src/lib/canvas/Makefile.am index 8564d66cbe..2ed5c50ae4 100644 --- a/legacy/evas/src/lib/canvas/Makefile.am +++ b/legacy/evas/src/lib/canvas/Makefile.am @@ -23,6 +23,7 @@ libevas_canvas_la_SOURCES = \ evas_callbacks.c \ evas_clip.c \ evas_data.c \ +evas_device.c \ evas_events.c \ evas_filter.c \ evas_focus.c \ diff --git a/legacy/evas/src/lib/canvas/evas_device.c b/legacy/evas/src/lib/canvas/evas_device.c new file mode 100644 index 0000000000..95204be77b --- /dev/null +++ b/legacy/evas/src/lib/canvas/evas_device.c @@ -0,0 +1,253 @@ +#include "evas_common.h" +#include "evas_private.h" + +EAPI Evas_Device * +evas_device_new(Evas *e) +{ + Evas_Device *dev; + + MAGIC_CHECK(e, Evas, MAGIC_EVAS); + return NULL; + MAGIC_CHECK_END(); + dev = calloc(1, sizeof(Evas_Device)); + if (!dev) return NULL; + dev->magic = MAGIC_DEV; + dev->evas = e; + dev->ref = 1; + e->devices = eina_list_append(e->devices, dev); + evas_event_callback_call(e, EVAS_CALLBACK_DEVICE_CHANGED, dev); + return dev; +} + +EAPI void +evas_device_free(Evas_Device *dev) +{ + MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV); + return; + MAGIC_CHECK_END(); + if (dev->ref == 1) + { + Evas_Device *dev2; + + EINA_LIST_FREE(dev->children, dev2) + { + dev2->parent = NULL; + evas_device_free(dev2); + } + if (dev->src) + { + _evas_device_unref(dev->src); + dev->src = NULL; + } + dev->parent = NULL; + } + _evas_device_unref(dev); +} + +EAPI void +evas_device_push(Evas *e, Evas_Device *dev) +{ + MAGIC_CHECK(e, Evas, MAGIC_EVAS); + return; + MAGIC_CHECK_END(); + MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV); + return; + MAGIC_CHECK_END(); + if (!e->cur_device) + { + e->cur_device = eina_array_new(4); + if (!e->cur_device) return; + } + dev->ref++; + eina_array_push(e->cur_device, dev); +} + +EAPI void +evas_device_pop(Evas *e) +{ + Evas_Device *dev; + + MAGIC_CHECK(e, Evas, MAGIC_EVAS); + return; + MAGIC_CHECK_END(); + dev = eina_array_pop(e->cur_device); + if (dev) _evas_device_unref(dev); +} + +EAPI const Eina_List * +evas_device_list(Evas *e, const Evas_Device *dev) +{ + MAGIC_CHECK(e, Evas, MAGIC_EVAS); + return NULL; + MAGIC_CHECK_END(); + if (dev) + { + MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV); + return NULL; + MAGIC_CHECK_END(); + } + if (dev) return dev->children; + return e->devices; +} + +EAPI void +evas_device_name_set(Evas_Device *dev, const char *name) +{ + MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV); + return; + MAGIC_CHECK_END(); + eina_stringshare_replace(&(dev->name), name); + evas_event_callback_call(dev->evas, EVAS_CALLBACK_DEVICE_CHANGED, dev); +} + +EAPI const char * +evas_device_name_get(const Evas_Device *dev) +{ + MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV); + return NULL; + MAGIC_CHECK_END(); + return dev->name; +} + +EAPI void +evas_device_description_set(Evas_Device *dev, const char *desc) +{ + MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV); + return; + MAGIC_CHECK_END(); + eina_stringshare_replace(&(dev->desc), desc); + evas_event_callback_call(dev->evas, EVAS_CALLBACK_DEVICE_CHANGED, dev); +} + +EAPI const char * +evas_device_description_get(const Evas_Device *dev) +{ + MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV); + return NULL; + MAGIC_CHECK_END(); + return dev->desc; +} + +EAPI void +evas_device_parent_set(Evas_Device *dev, Evas_Device *parent) +{ + MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV); + return; + MAGIC_CHECK_END(); + if (parent) + { + MAGIC_CHECK(parent, Evas_Device, MAGIC_DEV); + return; + MAGIC_CHECK_END(); + } + if (dev->parent == parent) return; + if (dev->parent) + dev->parent->children = eina_list_remove(dev->parent->children, dev); + dev->parent = parent; + if (parent) + parent->children = eina_list_append(parent->children, dev); + evas_event_callback_call(dev->evas, EVAS_CALLBACK_DEVICE_CHANGED, dev); +} + +EAPI const Evas_Device * +evas_device_parent_get(const Evas_Device *dev) +{ + MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV); + return NULL; + MAGIC_CHECK_END(); + return dev->parent; +} + +EAPI void +evas_device_class_set(Evas_Device *dev, Evas_Device_Class clas) +{ + MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV); + return; + MAGIC_CHECK_END(); + dev->clas = clas; + evas_event_callback_call(dev->evas, EVAS_CALLBACK_DEVICE_CHANGED, dev); +} + +EAPI Evas_Device_Class +evas_device_class_get(const Evas_Device *dev) +{ + MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV); + return EVAS_DEVICE_CLASS_NONE; + MAGIC_CHECK_END(); + return dev->clas; +} + +EAPI void +evas_device_emulation_source_set(Evas_Device *dev, Evas_Device *src) +{ + MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV); + return; + MAGIC_CHECK_END(); + if (src) + { + MAGIC_CHECK(src, Evas_Device, MAGIC_DEV); + return; + MAGIC_CHECK_END(); + } + if (dev->src == src) return; + if (dev->src) _evas_device_unref(dev->src); + dev->src = src; + if (dev->src) dev->src->ref++; + evas_event_callback_call(dev->evas, EVAS_CALLBACK_DEVICE_CHANGED, dev); +} + +EAPI const Evas_Device * +evas_device_emulation_source_get(const Evas_Device *dev) +{ + MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV); + return NULL; + MAGIC_CHECK_END(); + return dev->src; +} + +void +_evas_device_cleanup(Evas *e) +{ + Evas_Device *dev; + + if (e->cur_device) + { + while ((dev = eina_array_pop(e->cur_device))) + _evas_device_unref(dev); + eina_array_free(e->cur_device); + e->cur_device = NULL; + } + EINA_LIST_FREE(e->devices, dev) + { + evas_device_free(dev); + } +} + +Evas_Device * +_evas_device_top_get(const Evas *e) +{ + int num; + + if (!e->cur_device) return NULL; + num = eina_array_count(e->cur_device); + if (num < 1) return NULL; + return eina_array_data_get(e->cur_device, num - 1); +} + +void +_evas_device_ref(Evas_Device *dev) +{ + dev->ref++; +} + +void +_evas_device_unref(Evas_Device *dev) +{ + dev->ref--; + if (dev->ref > 0) return; + if (dev->name) eina_stringshare_del(dev->name); + if (dev->desc) eina_stringshare_del(dev->desc); + dev->magic = 0; + free(dev); +} + diff --git a/legacy/evas/src/lib/canvas/evas_events.c b/legacy/evas/src/lib/canvas/evas_events.c index 9c42750fff..9a21bac8b0 100644 --- a/legacy/evas/src/lib/canvas/evas_events.c +++ b/legacy/evas/src/lib/canvas/evas_events.c @@ -296,6 +296,8 @@ evas_event_feed_mouse_down(Evas *e, int b, Evas_Button_Flags flags, unsigned int ev.flags = flags; ev.timestamp = timestamp; ev.event_flags = e->default_event_flags; + ev.dev = _evas_device_top_get(e); + if (ev.dev) _evas_device_ref(ev.dev); _evas_walk(e); /* append new touch point to the touch point list */ @@ -350,6 +352,7 @@ evas_event_feed_mouse_down(Evas *e, int b, Evas_Button_Flags flags, unsigned int _evas_post_event_callback_call(e); /* update touch point's state to EVAS_TOUCH_POINT_STILL */ _evas_touch_point_update(e, 0, e->pointer.x, e->pointer.y, EVAS_TOUCH_POINT_STILL); + if (ev.dev) _evas_device_unref(ev.dev); _evas_unwalk(e); } @@ -375,7 +378,9 @@ _post_up_handle(Evas *e, unsigned int timestamp, const void *data) ev.locks = &(e->locks); ev.timestamp = timestamp; ev.event_flags = e->default_event_flags; - + ev.dev = _evas_device_top_get(e); + if (ev.dev) _evas_device_ref(ev.dev); + /* get new list of ins */ ins = evas_event_objects_event_list(e, NULL, e->pointer.x, e->pointer.y); /* go thru old list of in objects */ @@ -459,6 +464,7 @@ _post_up_handle(Evas *e, unsigned int timestamp, const void *data) } if (e->pointer.inside) evas_event_feed_mouse_move(e, e->pointer.x, e->pointer.y, timestamp, data); + if (ev.dev) _evas_device_unref(ev.dev); return post_called; } @@ -499,7 +505,9 @@ evas_event_feed_mouse_up(Evas *e, int b, Evas_Button_Flags flags, unsigned int t ev.flags = flags; ev.timestamp = timestamp; ev.event_flags = e->default_event_flags; - + ev.dev = _evas_device_top_get(e); + if (ev.dev) _evas_device_ref(ev.dev); + _evas_walk(e); /* update released touch point */ _evas_touch_point_update(e, 0, e->pointer.x, e->pointer.y, EVAS_TOUCH_POINT_UP); @@ -532,6 +540,7 @@ evas_event_feed_mouse_up(Evas *e, int b, Evas_Button_Flags flags, unsigned int t if (copy) copy = eina_list_free(copy); e->last_mouse_up_counter++; _evas_post_event_callback_call(e); + if (ev.dev) _evas_device_unref(ev.dev); } if (e->pointer.mouse_grabbed == 0) @@ -600,7 +609,9 @@ evas_event_feed_mouse_wheel(Evas *e, int direction, int z, unsigned int timestam ev.locks = &(e->locks); ev.timestamp = timestamp; ev.event_flags = e->default_event_flags; - + ev.dev = _evas_device_top_get(e); + if (ev.dev) _evas_device_ref(ev.dev); + _evas_walk(e); copy = evas_event_list_copy(e->pointer.object.in); @@ -617,6 +628,7 @@ evas_event_feed_mouse_wheel(Evas *e, int direction, int z, unsigned int timestam if (copy) copy = eina_list_free(copy); _evas_post_event_callback_call(e); + if (ev.dev) _evas_device_unref(ev.dev); _evas_unwalk(e); } @@ -679,6 +691,8 @@ evas_event_feed_mouse_move(Evas *e, int x, int y, unsigned int timestamp, const ev.locks = &(e->locks); ev.timestamp = timestamp; ev.event_flags = e->default_event_flags; + ev.dev = _evas_device_top_get(e); + if (ev.dev) _evas_device_ref(ev.dev); copy = evas_event_list_copy(e->pointer.object.in); EINA_LIST_FOREACH(copy, l, obj) { @@ -710,6 +724,7 @@ evas_event_feed_mouse_move(Evas *e, int x, int y, unsigned int timestamp, const if (e->delete_me) break; } _evas_post_event_callback_call(e); + if (ev.dev) _evas_device_unref(ev.dev); } { Evas_Event_Mouse_Out ev; @@ -728,7 +743,9 @@ evas_event_feed_mouse_move(Evas *e, int x, int y, unsigned int timestamp, const ev.locks = &(e->locks); ev.timestamp = timestamp; ev.event_flags = e->default_event_flags; - + ev.dev = _evas_device_top_get(e); + if (ev.dev) _evas_device_ref(ev.dev); + if (copy) eina_list_free(copy); while (outs) { @@ -755,6 +772,7 @@ evas_event_feed_mouse_move(Evas *e, int x, int y, unsigned int timestamp, const } } _evas_post_event_callback_call(e); + if (ev.dev) _evas_device_unref(ev.dev); } } else @@ -784,7 +802,9 @@ evas_event_feed_mouse_move(Evas *e, int x, int y, unsigned int timestamp, const ev.locks = &(e->locks); ev.timestamp = timestamp; ev.event_flags = e->default_event_flags; - + ev.dev = _evas_device_top_get(e); + if (ev.dev) _evas_device_ref(ev.dev); + ev2.buttons = e->pointer.button; ev2.output.x = e->pointer.x; ev2.output.y = e->pointer.y; @@ -795,6 +815,7 @@ evas_event_feed_mouse_move(Evas *e, int x, int y, unsigned int timestamp, const ev2.locks = &(e->locks); ev2.timestamp = timestamp; ev2.event_flags = e->default_event_flags; + ev2.dev = ev.dev; ev3.buttons = e->pointer.button; ev3.output.x = e->pointer.x; @@ -806,6 +827,7 @@ evas_event_feed_mouse_move(Evas *e, int x, int y, unsigned int timestamp, const ev3.locks = &(e->locks); ev3.timestamp = timestamp; ev3.event_flags = e->default_event_flags; + ev3.dev = ev.dev; /* get all new in objects */ ins = evas_event_objects_event_list(e, NULL, x, y); @@ -890,6 +912,7 @@ evas_event_feed_mouse_move(Evas *e, int x, int y, unsigned int timestamp, const eina_list_free(ins); } _evas_post_event_callback_call(e); + if (ev.dev) _evas_device_unref(ev.dev); } _evas_unwalk(e); return; @@ -922,7 +945,9 @@ nogrep: ev.locks = &(e->locks); ev.timestamp = timestamp; ev.event_flags = e->default_event_flags; - + ev.dev = _evas_device_top_get(e); + if (ev.dev) _evas_device_ref(ev.dev); + ev2.buttons = e->pointer.button; ev2.output.x = e->pointer.x; ev2.output.y = e->pointer.y; @@ -933,7 +958,8 @@ nogrep: ev2.locks = &(e->locks); ev2.timestamp = timestamp; ev2.event_flags = e->default_event_flags; - + ev2.dev = ev.dev; + ev3.buttons = e->pointer.button; ev3.output.x = e->pointer.x; ev3.output.y = e->pointer.y; @@ -944,6 +970,7 @@ nogrep: ev3.locks = &(e->locks); ev3.timestamp = timestamp; ev3.event_flags = e->default_event_flags; + ev3.dev = ev.dev; /* go thru old list of in objects */ copy = evas_event_list_copy(e->pointer.object.in); @@ -1047,6 +1074,7 @@ nogrep: e->pointer.object.in = newin; _evas_post_event_callback_call(e); + if (ev.dev) _evas_device_unref(ev.dev); } _evas_unwalk(e); } @@ -1083,7 +1111,9 @@ evas_event_feed_mouse_in(Evas *e, unsigned int timestamp, const void *data) ev.locks = &(e->locks); ev.timestamp = timestamp; ev.event_flags = e->default_event_flags; - + ev.dev = _evas_device_top_get(e); + if (ev.dev) _evas_device_ref(ev.dev); + _evas_walk(e); /* get new list of ins */ ins = evas_event_objects_event_list(e, NULL, e->pointer.x, e->pointer.y); @@ -1110,6 +1140,7 @@ evas_event_feed_mouse_in(Evas *e, unsigned int timestamp, const void *data) e->pointer.object.in = ins; _evas_post_event_callback_call(e); evas_event_feed_mouse_move(e, e->pointer.x, e->pointer.y, timestamp, data); + if (ev.dev) _evas_device_unref(ev.dev); _evas_unwalk(e); } @@ -1140,7 +1171,9 @@ evas_event_feed_mouse_out(Evas *e, unsigned int timestamp, const void *data) ev.locks = &(e->locks); ev.timestamp = timestamp; ev.event_flags = e->default_event_flags; - + ev.dev = _evas_device_top_get(e); + if (ev.dev) _evas_device_ref(ev.dev); + _evas_walk(e); /* if our mouse button is inside any objects */ { @@ -1173,6 +1206,7 @@ evas_event_feed_mouse_out(Evas *e, unsigned int timestamp, const void *data) e->pointer.mouse_grabbed = 0; _evas_post_event_callback_call(e); } + if (ev.dev) _evas_device_unref(ev.dev); _evas_unwalk(e); } @@ -1220,7 +1254,9 @@ evas_event_feed_multi_down(Evas *e, ev.flags = flags; ev.timestamp = timestamp; ev.event_flags = e->default_event_flags; - + ev.dev = _evas_device_top_get(e); + if (ev.dev) _evas_device_ref(ev.dev); + _evas_walk(e); /* append new touch point to the touch point list */ _evas_touch_point_append(e, d, x, y); @@ -1257,6 +1293,7 @@ evas_event_feed_multi_down(Evas *e, _evas_post_event_callback_call(e); /* update touch point's state to EVAS_TOUCH_POINT_STILL */ _evas_touch_point_update(e, d, x, y, EVAS_TOUCH_POINT_STILL); + if (ev.dev) _evas_device_unref(ev.dev); _evas_unwalk(e); } @@ -1304,7 +1341,9 @@ evas_event_feed_multi_up(Evas *e, ev.flags = flags; ev.timestamp = timestamp; ev.event_flags = e->default_event_flags; - + ev.dev = _evas_device_top_get(e); + if (ev.dev) _evas_device_ref(ev.dev); + _evas_walk(e); /* update released touch point */ _evas_touch_point_update(e, d, x, y, EVAS_TOUCH_POINT_UP); @@ -1336,6 +1375,7 @@ evas_event_feed_multi_up(Evas *e, _evas_post_event_callback_call(e); /* remove released touch point from the touch point list */ _evas_touch_point_remove(e, d); + if (ev.dev) _evas_device_unref(ev.dev); _evas_unwalk(e); } @@ -1388,7 +1428,9 @@ evas_event_feed_multi_move(Evas *e, ev.locks = &(e->locks); ev.timestamp = timestamp; ev.event_flags = e->default_event_flags; - + ev.dev = _evas_device_top_get(e); + if (ev.dev) _evas_device_ref(ev.dev); + copy = evas_event_list_copy(e->pointer.object.in); EINA_LIST_FOREACH(copy, l, obj) { @@ -1413,6 +1455,7 @@ evas_event_feed_multi_move(Evas *e, if (e->delete_me) break; } _evas_post_event_callback_call(e); + if (ev.dev) _evas_device_unref(ev.dev); } else { @@ -1442,7 +1485,9 @@ evas_event_feed_multi_move(Evas *e, ev.locks = &(e->locks); ev.timestamp = timestamp; ev.event_flags = e->default_event_flags; - + ev.dev = _evas_device_top_get(e); + if (ev.dev) _evas_device_ref(ev.dev); + /* get all new in objects */ ins = evas_event_objects_event_list(e, NULL, x, y); /* go thru old list of in objects */ @@ -1492,6 +1537,7 @@ evas_event_feed_multi_move(Evas *e, eina_list_free(ins); } _evas_post_event_callback_call(e); + if (ev.dev) _evas_device_unref(ev.dev); } _evas_unwalk(e); } @@ -1525,7 +1571,9 @@ evas_event_feed_key_down(Evas *e, const char *keyname, const char *key, const ch ev.compose = compose; ev.timestamp = timestamp; ev.event_flags = e->default_event_flags; - + ev.dev = _evas_device_top_get(e); + if (ev.dev) _evas_device_ref(ev.dev); + if (e->grabs) { Eina_List *l; @@ -1580,6 +1628,7 @@ evas_event_feed_key_down(Evas *e, const char *keyname, const char *key, const ch &ev, event_id); } _evas_post_event_callback_call(e); + if (ev.dev) _evas_device_unref(ev.dev); _evas_unwalk(e); } @@ -1611,7 +1660,9 @@ evas_event_feed_key_up(Evas *e, const char *keyname, const char *key, const char ev.compose = compose; ev.timestamp = timestamp; ev.event_flags = e->default_event_flags; - + ev.dev = _evas_device_top_get(e); + if (ev.dev) _evas_device_ref(ev.dev); + if (e->grabs) { Eina_List *l; @@ -1665,6 +1716,7 @@ evas_event_feed_key_up(Evas *e, const char *keyname, const char *key, const char &ev, event_id); } _evas_post_event_callback_call(e); + if (ev.dev) _evas_device_unref(ev.dev); _evas_unwalk(e); } @@ -1690,7 +1742,9 @@ evas_event_feed_hold(Evas *e, int hold, unsigned int timestamp, const void *data ev.data = (void *)data; ev.timestamp = timestamp; ev.event_flags = e->default_event_flags; - + ev.dev = _evas_device_top_get(e); + if (ev.dev) _evas_device_ref(ev.dev); + _evas_walk(e); copy = evas_event_list_copy(e->pointer.object.in); EINA_LIST_FOREACH(copy, l, obj) @@ -1701,6 +1755,7 @@ evas_event_feed_hold(Evas *e, int hold, unsigned int timestamp, const void *data } if (copy) copy = eina_list_free(copy); _evas_post_event_callback_call(e); + if (ev.dev) _evas_device_unref(ev.dev); _evas_unwalk(e); _evas_object_event_new(); } diff --git a/legacy/evas/src/lib/canvas/evas_main.c b/legacy/evas/src/lib/canvas/evas_main.c index 6f6b4e12a9..94b54bb595 100644 --- a/legacy/evas/src/lib/canvas/evas_main.c +++ b/legacy/evas/src/lib/canvas/evas_main.c @@ -242,6 +242,8 @@ evas_free(Evas *e) EINA_LIST_FREE(e->touch_points, touch_point) free(touch_point); + _evas_device_cleanup(e); + e->magic = 0; free(e); } diff --git a/legacy/evas/src/lib/include/evas_private.h b/legacy/evas/src/lib/include/evas_private.h index abe7a07f99..46e5c97a12 100644 --- a/legacy/evas/src/lib/include/evas_private.h +++ b/legacy/evas/src/lib/include/evas_private.h @@ -107,21 +107,22 @@ OPAQUE_TYPE(Evas_Font_Instance); /* General type for RGBA_Font_Int */ /* End of general types */ #define MAGIC_EVAS 0x70777770 -#define MAGIC_OBJ 0x71777770 -#define MAGIC_OBJ_RECTANGLE 0x71777771 -#define MAGIC_OBJ_LINE 0x71777772 -#define MAGIC_OBJ_POLYGON 0x71777774 -#define MAGIC_OBJ_IMAGE 0x71777775 -#define MAGIC_OBJ_TEXT 0x71777776 -#define MAGIC_OBJ_SMART 0x71777777 -#define MAGIC_OBJ_TEXTBLOCK 0x71777778 -#define MAGIC_OBJ_TEXTGRID 0x7177777A -#define MAGIC_SMART 0x72777770 -#define MAGIC_OBJ_SHAPE 0x72777773 -#define MAGIC_OBJ_CONTAINER 0x72777774 -#define MAGIC_OBJ_CUSTOM 0x72777775 -#define MAGIC_EVAS_GL 0x72777776 -#define MAGIC_MAP 0x72777777 +#define MAGIC_OBJ 0x71737723 +#define MAGIC_OBJ_RECTANGLE 0x76748772 +#define MAGIC_OBJ_LINE 0x7a27f839 +#define MAGIC_OBJ_POLYGON 0x7bb7577e +#define MAGIC_OBJ_IMAGE 0x747ad76c +#define MAGIC_OBJ_TEXT 0x77757721 +#define MAGIC_OBJ_SMART 0x78c7c73f +#define MAGIC_OBJ_TEXTBLOCK 0x71737744 +#define MAGIC_OBJ_TEXTGRID 0x7377a7ca +#define MAGIC_SMART 0x7c6977c5 +#define MAGIC_OBJ_SHAPE 0x747297f7 +#define MAGIC_OBJ_CONTAINER 0x71877776 +#define MAGIC_OBJ_CUSTOM 0x7b7857ab +#define MAGIC_EVAS_GL 0x77976718 +#define MAGIC_MAP 0x7575177d +#define MAGIC_DEV 0x7d773738 #ifdef MAGIC_DEBUG # define MAGIC_CHECK_FAILED(o, t, m) \ @@ -408,6 +409,8 @@ struct _Evas unsigned char focus : 1; Eina_List *touch_points; + Eina_List *devices; + Eina_Array *cur_device; }; struct _Evas_Layer @@ -711,6 +714,19 @@ struct _Evas_Font_Description Eina_Bool is_new : 1; }; +struct _Evas_Device +{ + DATA32 magic; + Evas *evas; + Evas_Device *parent; + Evas_Device *src; + Eina_List *children; + const char *name; + const char *desc; + int ref; + Evas_Device_Class clas; +}; + struct _Evas_Object_Func { void (*free) (Evas_Object *obj); @@ -1093,6 +1109,11 @@ void _evas_touch_point_append(Evas *e, int id, Evas_Coord x, Evas_Coord y); void _evas_touch_point_update(Evas *e, int id, Evas_Coord x, Evas_Coord y, Evas_Touch_Point_State state); void _evas_touch_point_remove(Evas *e, int id); +void _evas_device_cleanup(Evas *e); +Evas_Device *_evas_device_top_get(const Evas *e); +void _evas_device_ref(Evas_Device *dev); +void _evas_device_unref(Evas_Device *dev); + /****************************************************************************/ /*****************************************/ /********************/