summaryrefslogtreecommitdiff
path: root/legacy
diff options
context:
space:
mode:
authorEunMi Lee <eunmi15.lee@samsung.com>2011-10-04 07:30:22 +0000
committerCarsten Haitzler <raster@rasterman.com>2011-10-04 07:30:22 +0000
commitc6681aa189094e5429572adcb3689466c02c057d (patch)
tree3faede2984fab51684941d143b8f46b904a04404 /legacy
parenta8d945f0a686f4359ca28ce288ca09e7ccb20ea2 (diff)
From: EunMi Lee <eunmi15.lee@samsung.com>
Subject: [E-devel] [Patch] Evas touch event patch. Nice to meet you. I'm Eunmi Lee, developing mobile web browser and working on WebKit EFL port. I need new type of event for touch, so I've made patch to add EVAS_CALLBACK_TOUCH event to the evas. I will explain history of this patch. Currently, many web applications and sites use TouchEvent and they can do everything(scrolling, zooming and so on) like native application using TouchEvent. So, I'm also want to provide TouchEvent for web in the WebKit EFL port, but I got a problem during making TouchEvent because EFL's touch event's structure (Mouse, Multi Event) is different from Web TouchEvent's one. Let me explain about Web TouchEvent firstly. Web TouchEvent is consist of type and touch points list simply. There are 3 kinds of type. TouchStart: Happens every time a finger is placed on the screen. TouchEnd: Happens every time a finger is removed from the screen. TouchMove: Happens as a finger already placed on the screen is moved across the screen. for example, we can make (1 finger starts to touch), (2 fingers are moving), (1 finger is released duirng 3 fingers are moving) and so on. You can see the detailed information in the following url: http://www.sitepen.com/blog/2008/07/10/touching-and-gesturing-on-the-iphone However, EFL's touch event is consist of six kinds of type : MOUSE_DOWN, MOUSE_UP, MOUSE_MOVE, MULTI_DOWN, MULTI_UP, MULTI_MOVE. So, I have to make a converter to make web touch event from EFL's touch event. You can reference attatched image file : evas_touch_event.png. To tell the truth, converting code is not a big one. But, I want to reduce this additional job and make code simple. In the WebKit QT port, they don't have to make converting code for TouchEvent, because they have QTouchEvent, it has type and touchPoints list and they can be mapped to Web TouchEvent one by one. I think iPhone and Android also have such kind of event. That's all why I want to add new touch event type to the evas. about my patch: - EVAS_CALLBACK_TOUCH event is added - touch_points Eina_List is added to the Evas structure to maintain current touch lists. - process MOUSE/MULTI UP, DOWN, MOVE to make TOUCH event. It is my first time to modify eves codes and actually I don't know too much about evas. So, I will be grateful if you send any feedback and comments. SVN revision: 63796
Diffstat (limited to 'legacy')
-rw-r--r--legacy/evas/AUTHORS1
-rw-r--r--legacy/evas/src/lib/Evas.h41
-rw-r--r--legacy/evas/src/lib/canvas/Makefile.am1
-rw-r--r--legacy/evas/src/lib/canvas/evas_callbacks.c2
-rw-r--r--legacy/evas/src/lib/canvas/evas_events.c18
-rw-r--r--legacy/evas/src/lib/canvas/evas_main.c4
-rw-r--r--legacy/evas/src/lib/canvas/evas_touch_events.c127
-rw-r--r--legacy/evas/src/lib/include/evas_private.h7
8 files changed, 200 insertions, 1 deletions
diff --git a/legacy/evas/AUTHORS b/legacy/evas/AUTHORS
index d29615f62c..ebae05f96c 100644
--- a/legacy/evas/AUTHORS
+++ b/legacy/evas/AUTHORS
@@ -30,3 +30,4 @@ Christopher 'devilhorns' Michael <cpmichael1@comcast.net>
30Seungsoo Woo <om101.woo@samsung.com> 30Seungsoo Woo <om101.woo@samsung.com>
31Youness Alaoui <kakaroto@kakaroto.homelinux.net> 31Youness Alaoui <kakaroto@kakaroto.homelinux.net>
32Jim Kukunas <james.t.kukunas@linux.intel.com> 32Jim Kukunas <james.t.kukunas@linux.intel.com>
33EunMi Lee <eunmi15.lee@samsung.com>
diff --git a/legacy/evas/src/lib/Evas.h b/legacy/evas/src/lib/Evas.h
index 5a0b0cab45..0a8706b262 100644
--- a/legacy/evas/src/lib/Evas.h
+++ b/legacy/evas/src/lib/Evas.h
@@ -430,6 +430,7 @@ typedef enum _Evas_Callback_Type
430 * More Evas object event types - see evas_object_event_callback_add(): 430 * More Evas object event types - see evas_object_event_callback_add():
431 */ 431 */
432 EVAS_CALLBACK_IMAGE_UNLOADED, /**< Image data has been unloaded (by some mechanims in Evas that throw out original image data) */ 432 EVAS_CALLBACK_IMAGE_UNLOADED, /**< Image data has been unloaded (by some mechanims in Evas that throw out original image data) */
433 EVAS_CALLBACK_TOUCH, /**< Touch Event */
433 434
434 EVAS_CALLBACK_LAST /**< kept as last element/sentinel -- not really an event */ 435 EVAS_CALLBACK_LAST /**< kept as last element/sentinel -- not really an event */
435} Evas_Callback_Type; /**< The types of events triggering a callback */ 436} Evas_Callback_Type; /**< The types of events triggering a callback */
@@ -488,6 +489,29 @@ typedef enum _Evas_Event_Flags
488} Evas_Event_Flags; /**< Flags for Events */ 489} Evas_Event_Flags; /**< Flags for Events */
489 490
490/** 491/**
492 * State of Evas_Coord_Touch_Point
493 */
494typedef enum _Evas_Touch_Point_State
495{
496 EVAS_TOUCH_POINT_DOWN, /**< Touch point is pressed down */
497 EVAS_TOUCH_POINT_UP, /**< Touch point is released */
498 EVAS_TOUCH_POINT_MOVE, /**< Touch point is moved */
499 EVAS_TOUCH_POINT_STILL, /**< Touch point is not moved after pressed */
500 EVAS_TOUCH_POINT_CANCEL /**< Touch point is calcelled */
501} Evas_Touch_Point_State;
502
503/**
504 * Types for Evas_Touch_Event
505 */
506typedef enum _Evas_Event_Touch_Type
507{
508 EVAS_EVENT_TOUCH_BEGIN, /**< Begin touch event with pressed new touch point */
509 EVAS_EVENT_TOUCH_END, /**< End touch event with released touch point */
510 EVAS_EVENT_TOUCH_MOVE, /**< Any touch point in the touch_points list is moved */
511 EVAS_EVENT_TOUCH_CANCEL /**< Touch event is cancelled */
512} Evas_Event_Touch_Type;
513
514/**
491 * Flags for Font Hinting 515 * Flags for Font Hinting
492 * @ingroup Evas_Font_Group 516 * @ingroup Evas_Font_Group
493 */ 517 */
@@ -534,6 +558,7 @@ typedef struct _Evas_Point Evas_Point; /**< integer point */
534 558
535typedef struct _Evas_Coord_Point Evas_Coord_Point; /**< Evas_Coord point */ 559typedef struct _Evas_Coord_Point Evas_Coord_Point; /**< Evas_Coord point */
536typedef struct _Evas_Coord_Precision_Point Evas_Coord_Precision_Point; /**< Evas_Coord point with sub-pixel precision */ 560typedef struct _Evas_Coord_Precision_Point Evas_Coord_Precision_Point; /**< Evas_Coord point with sub-pixel precision */
561typedef struct _Evas_Coord_Touch_Point Evas_Coord_Touch_Point; /**< Evas_Coord point with touch type and id */
537 562
538typedef struct _Evas_Position Evas_Position; /**< associates given point in Canvas and Output */ 563typedef struct _Evas_Position Evas_Position; /**< associates given point in Canvas and Output */
539typedef struct _Evas_Precision_Position Evas_Precision_Position; /**< associates given point in Canvas and Output, with sub-pixel precision */ 564typedef struct _Evas_Precision_Position Evas_Precision_Position; /**< associates given point in Canvas and Output, with sub-pixel precision */
@@ -624,6 +649,13 @@ struct _Evas_Coord_Precision_Point
624 double xsub, ysub; 649 double xsub, ysub;
625}; 650};
626 651
652struct _Evas_Coord_Touch_Point
653{
654 Evas_Coord x, y;
655 int id; /**< id in order to distinguish each point */
656 Evas_Touch_Point_State state;
657};
658
627struct _Evas_Position 659struct _Evas_Position
628{ 660{
629 Evas_Point output; 661 Evas_Point output;
@@ -660,6 +692,7 @@ typedef struct _Evas_Event_Multi_Move Evas_Event_Multi_Move; /**< Event structur
660typedef struct _Evas_Event_Key_Down Evas_Event_Key_Down; /**< Event structure for #EVAS_CALLBACK_KEY_DOWN event callbacks */ 692typedef struct _Evas_Event_Key_Down Evas_Event_Key_Down; /**< Event structure for #EVAS_CALLBACK_KEY_DOWN event callbacks */
661typedef struct _Evas_Event_Key_Up Evas_Event_Key_Up; /**< Event structure for #EVAS_CALLBACK_KEY_UP event callbacks */ 693typedef struct _Evas_Event_Key_Up Evas_Event_Key_Up; /**< Event structure for #EVAS_CALLBACK_KEY_UP event callbacks */
662typedef struct _Evas_Event_Hold Evas_Event_Hold; /**< Event structure for #EVAS_CALLBACK_HOLD event callbacks */ 694typedef struct _Evas_Event_Hold Evas_Event_Hold; /**< Event structure for #EVAS_CALLBACK_HOLD event callbacks */
695typedef struct _Evas_Event_Touch Evas_Event_Touch; /**< Event structure for #EVAS_CALLBACK_TOUCH event callbacks */
663 696
664typedef enum _Evas_Load_Error 697typedef enum _Evas_Load_Error
665{ 698{
@@ -1016,6 +1049,14 @@ struct _Evas_Event_Hold /** Hold change event */
1016 Evas_Device *dev; 1049 Evas_Device *dev;
1017}; 1050};
1018 1051
1052struct _Evas_Event_Touch /** Touch event */
1053{
1054 Eina_List *points; /**< Evas_Coord_Touch_Point list */
1055 Evas_Modifier *modifiers;
1056 unsigned int timestamp;
1057 Evas_Event_Touch_Type type; /**< Type for Evas_Event_Touch */
1058};
1059
1019/** 1060/**
1020 * How the mouse pointer should be handled by Evas. 1061 * How the mouse pointer should be handled by Evas.
1021 * 1062 *
diff --git a/legacy/evas/src/lib/canvas/Makefile.am b/legacy/evas/src/lib/canvas/Makefile.am
index 32dadc3219..fd32990e77 100644
--- a/legacy/evas/src/lib/canvas/Makefile.am
+++ b/legacy/evas/src/lib/canvas/Makefile.am
@@ -51,6 +51,7 @@ evas_smart.c \
51evas_stack.c \ 51evas_stack.c \
52evas_async_events.c \ 52evas_async_events.c \
53evas_stats.c \ 53evas_stats.c \
54evas_touch_events.c \
54evas_map.c \ 55evas_map.c \
55evas_gl.c 56evas_gl.c
56 57
diff --git a/legacy/evas/src/lib/canvas/evas_callbacks.c b/legacy/evas/src/lib/canvas/evas_callbacks.c
index 33b93bcbc6..f87adaa361 100644
--- a/legacy/evas/src/lib/canvas/evas_callbacks.c
+++ b/legacy/evas/src/lib/canvas/evas_callbacks.c
@@ -249,7 +249,7 @@ evas_object_event_callback_call(Evas_Object *obj, Evas_Callback_Type type, void
249 if (!obj->no_propagate) 249 if (!obj->no_propagate)
250 { 250 {
251 if ((obj->smart.parent) && (type != EVAS_CALLBACK_FREE) && 251 if ((obj->smart.parent) && (type != EVAS_CALLBACK_FREE) &&
252 (type <= EVAS_CALLBACK_KEY_UP)) 252 ((type <= EVAS_CALLBACK_KEY_UP) || (type == EVAS_CALLBACK_TOUCH)))
253 evas_object_event_callback_call(obj->smart.parent, type, event_info); 253 evas_object_event_callback_call(obj->smart.parent, type, event_info);
254 } 254 }
255 } 255 }
diff --git a/legacy/evas/src/lib/canvas/evas_events.c b/legacy/evas/src/lib/canvas/evas_events.c
index e7fb6b040b..33b5015ff2 100644
--- a/legacy/evas/src/lib/canvas/evas_events.c
+++ b/legacy/evas/src/lib/canvas/evas_events.c
@@ -270,6 +270,9 @@ evas_event_feed_mouse_down(Evas *e, int b, Evas_Button_Flags flags, unsigned int
270 e->last_mouse_down_counter++; 270 e->last_mouse_down_counter++;
271 _evas_post_event_callback_call(e); 271 _evas_post_event_callback_call(e);
272 _evas_unwalk(e); 272 _evas_unwalk(e);
273
274 /* process mouse down for touch */
275 _evas_event_touch_down(e, e->pointer.x, e->pointer.y, 0, timestamp);
273} 276}
274 277
275static int 278static int
@@ -455,6 +458,9 @@ evas_event_feed_mouse_up(Evas *e, int b, Evas_Button_Flags flags, unsigned int t
455 } 458 }
456 */ 459 */
457 _evas_unwalk(e); 460 _evas_unwalk(e);
461
462 /* process mouse up for touch */
463 _evas_event_touch_up(e, e->pointer.x, e->pointer.y, 0, timestamp);
458} 464}
459 465
460EAPI void 466EAPI void
@@ -771,6 +777,9 @@ evas_event_feed_mouse_move(Evas *e, int x, int y, unsigned int timestamp, const
771 _evas_post_event_callback_call(e); 777 _evas_post_event_callback_call(e);
772 } 778 }
773 _evas_unwalk(e); 779 _evas_unwalk(e);
780
781 /* process mouse move for touch */
782 _evas_event_touch_move(e, e->pointer.x, e->pointer.y, 0, timestamp);
774} 783}
775 784
776EAPI void 785EAPI void
@@ -960,6 +969,9 @@ evas_event_feed_multi_down(Evas *e,
960 if (copy) eina_list_free(copy); 969 if (copy) eina_list_free(copy);
961 _evas_post_event_callback_call(e); 970 _evas_post_event_callback_call(e);
962 _evas_unwalk(e); 971 _evas_unwalk(e);
972
973 /* process multi down for touch */
974 _evas_event_touch_down(e, x, y, d, timestamp);
963} 975}
964 976
965EAPI void 977EAPI void
@@ -1030,6 +1042,9 @@ evas_event_feed_multi_up(Evas *e,
1030 if ((e->pointer.mouse_grabbed == 0) && !_post_up_handle(e, timestamp, data)) 1042 if ((e->pointer.mouse_grabbed == 0) && !_post_up_handle(e, timestamp, data))
1031 _evas_post_event_callback_call(e); 1043 _evas_post_event_callback_call(e);
1032 _evas_unwalk(e); 1044 _evas_unwalk(e);
1045
1046 /* process multi up for touch */
1047 _evas_event_touch_up(e, x, y, d, timestamp);
1033} 1048}
1034 1049
1035EAPI void 1050EAPI void
@@ -1178,6 +1193,9 @@ evas_event_feed_multi_move(Evas *e,
1178 _evas_post_event_callback_call(e); 1193 _evas_post_event_callback_call(e);
1179 } 1194 }
1180 _evas_unwalk(e); 1195 _evas_unwalk(e);
1196
1197 /* process multi move for touch */
1198 _evas_event_touch_move(e, x, y, d, timestamp);
1181} 1199}
1182 1200
1183EAPI void 1201EAPI void
diff --git a/legacy/evas/src/lib/canvas/evas_main.c b/legacy/evas/src/lib/canvas/evas_main.c
index b52efe8e3b..d3e4c8c52d 100644
--- a/legacy/evas/src/lib/canvas/evas_main.c
+++ b/legacy/evas/src/lib/canvas/evas_main.c
@@ -143,6 +143,7 @@ EAPI void
143evas_free(Evas *e) 143evas_free(Evas *e)
144{ 144{
145 Eina_Rectangle *r; 145 Eina_Rectangle *r;
146 Evas_Coord_Touch_Point *touch_point;
146 Evas_Layer *lay; 147 Evas_Layer *lay;
147 int i; 148 int i;
148 int del; 149 int del;
@@ -249,6 +250,9 @@ evas_free(Evas *e)
249 eina_array_flush(&e->calculate_objects); 250 eina_array_flush(&e->calculate_objects);
250 eina_array_flush(&e->clip_changes); 251 eina_array_flush(&e->clip_changes);
251 252
253 EINA_LIST_FREE(e->touch_points, touch_point)
254 free(touch_point);
255
252 eina_list_free(e->calc_list); 256 eina_list_free(e->calc_list);
253 257
254 e->magic = 0; 258 e->magic = 0;
diff --git a/legacy/evas/src/lib/canvas/evas_touch_events.c b/legacy/evas/src/lib/canvas/evas_touch_events.c
new file mode 100644
index 0000000000..456cd8b621
--- /dev/null
+++ b/legacy/evas/src/lib/canvas/evas_touch_events.c
@@ -0,0 +1,127 @@
1#include "evas_common.h"
2#include "evas_private.h"
3
4static void
5_evas_touch_point_append(Evas *e, int id, int x, int y)
6{
7 Evas_Coord_Touch_Point *point;
8
9 /* create new Evas_Coord_Touch_Point */
10 point = (Evas_Coord_Touch_Point *)calloc(1, sizeof(Evas_Coord_Touch_Point));
11 point->x = x;
12 point->y = y;
13 point->id = id;
14 point->state = EVAS_TOUCH_POINT_DOWN;
15
16 _evas_walk(e);
17 e->touch_points = eina_list_append(e->touch_points, point);
18 _evas_unwalk(e);
19}
20
21static Evas_Coord_Touch_Point *
22_evas_touch_point_update(Evas *e, int id, int x, int y, Evas_Touch_Point_State state)
23{
24 Eina_List *l;
25 Evas_Coord_Touch_Point *point = NULL;
26
27 _evas_walk(e);
28 EINA_LIST_FOREACH(e->touch_points, l, point)
29 {
30 if (point->id == id)
31 {
32 point->x = x;
33 point->y = y;
34 point->state = state;
35 break;
36 }
37 }
38 _evas_unwalk(e);
39
40 return point;
41}
42
43static void
44_evas_event_feed_touch(Evas *e, unsigned int timestamp, Evas_Event_Touch_Type type)
45{
46 Evas_Event_Touch ev;
47 Eina_List *l, *copy;
48 Evas_Coord_Touch_Point *point;
49 Evas_Object *obj;
50 const void *data;
51
52 _evas_walk(e);
53 /* set Evas_Event_Touch's members */
54 ev.points = NULL;
55 EINA_LIST_FOREACH(e->touch_points, l, point)
56 ev.points = eina_list_append(ev.points, point);
57 ev.modifiers = &(e->modifiers);
58 ev.timestamp = timestamp;
59 ev.type = type;
60
61 /* make copy of object list */
62 copy = NULL;
63 EINA_LIST_FOREACH(e->pointer.object.in, l, data)
64 copy = eina_list_append(copy, data);
65
66 /* call all EVAS_CALLBACK_TOUCH's callbacks */
67 EINA_LIST_FOREACH(copy, l, obj)
68 {
69 if (!obj->delete_me && (e->events_frozen <= 0))
70 evas_object_event_callback_call(obj, EVAS_CALLBACK_TOUCH, &ev);
71 if (e->delete_me) break;
72 }
73 if (copy) eina_list_free(copy);
74 if (ev.points) eina_list_free(ev.points);
75
76 /* if finger is released or pressed, reset all touch point's state */
77 if (type != EVAS_EVENT_TOUCH_MOVE)
78 {
79 EINA_LIST_FOREACH(e->touch_points, l, point)
80 point->state = EVAS_TOUCH_POINT_STILL;
81 }
82 _evas_unwalk(e);
83}
84
85void
86_evas_event_touch_down(Evas *e, Evas_Coord x, Evas_Coord y, int id, unsigned int timestamp)
87{
88 _evas_touch_point_append(e, id, x, y);
89 _evas_event_feed_touch(e, timestamp, EVAS_EVENT_TOUCH_BEGIN);
90}
91
92void
93_evas_event_touch_up(Evas *e, Evas_Coord x, Evas_Coord y, int id, unsigned int timestamp)
94{
95 Evas_Coord_Touch_Point *point;
96
97 /* update touch point in the touch_points list */
98 point = _evas_touch_point_update(e, id, x, y, EVAS_TOUCH_POINT_UP);
99 if (!point) return;
100
101 _evas_walk(e);
102 _evas_event_feed_touch(e, timestamp, EVAS_EVENT_TOUCH_END);
103 e->touch_points = eina_list_remove(e->touch_points, point);
104 _evas_unwalk(e);
105}
106
107void
108_evas_event_touch_move(Evas *e, Evas_Coord x, Evas_Coord y, int id, unsigned int timestamp)
109{
110 Eina_List *l;
111 Evas_Coord_Touch_Point *point;
112
113 _evas_walk(e);
114 EINA_LIST_FOREACH(e->touch_points, l, point)
115 {
116 if (point->id == id)
117 {
118 /* update touch point */
119 point->x = x;
120 point->y = y;
121 point->state = EVAS_TOUCH_POINT_MOVE;
122
123 _evas_event_feed_touch(e, timestamp, EVAS_EVENT_TOUCH_MOVE);
124 }
125 }
126 _evas_unwalk(e);
127}
diff --git a/legacy/evas/src/lib/include/evas_private.h b/legacy/evas/src/lib/include/evas_private.h
index c9ee526649..bb16f47530 100644
--- a/legacy/evas/src/lib/include/evas_private.h
+++ b/legacy/evas/src/lib/include/evas_private.h
@@ -378,6 +378,8 @@ struct _Evas
378 unsigned char invalidate : 1; 378 unsigned char invalidate : 1;
379 unsigned char cleanup : 1; 379 unsigned char cleanup : 1;
380 unsigned char focus : 1; 380 unsigned char focus : 1;
381
382 Eina_List *touch_points;
381}; 383};
382 384
383struct _Evas_Layer 385struct _Evas_Layer
@@ -1010,6 +1012,11 @@ Eina_Bool evas_map_coords_get(const Evas_Map *m, Evas_Coord x, Evas_Coord y, Eva
1010 1012
1011Eina_List *evas_module_engine_list(void); 1013Eina_List *evas_module_engine_list(void);
1012 1014
1015/* for touch event */
1016void _evas_event_touch_down(Evas *e, Evas_Coord x, Evas_Coord y, int id, unsigned int timestamp);
1017void _evas_event_touch_up(Evas *e, Evas_Coord x, Evas_Coord y, int id, unsigned int timestamp);
1018void _evas_event_touch_move(Evas *e, Evas_Coord x, Evas_Coord y, int id, unsigned int timestamp);
1019
1013/****************************************************************************/ 1020/****************************************************************************/
1014/*****************************************/ 1021/*****************************************/
1015/********************/ 1022/********************/