summaryrefslogtreecommitdiff
path: root/src/lib/evas/canvas
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2016-08-10 18:59:36 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-08-16 20:22:57 +0900
commit6d52d1db2b2b85eda6dc16124d319d25e975f49c (patch)
tree5fef775ee472ee5ed871a1efce1c919f2d53654a /src/lib/evas/canvas
parentae3ac0cd2520469c700d43c81e33534ce0d8e92e (diff)
evas: Fix ordering of input event
The previous patch 1185c40e508ca2ecc4c5e86b shows how having two event types for the same thing (key or mouse input events) was a bad idea. The only guaranteed order of callbacks is the priority but even that was not enforced (since legacy or eo style event had to come first). Fixes T4310
Diffstat (limited to 'src/lib/evas/canvas')
-rw-r--r--src/lib/evas/canvas/efl_canvas_object.eo12
-rw-r--r--src/lib/evas/canvas/efl_event_hold.c29
-rw-r--r--src/lib/evas/canvas/efl_event_hold.eo1
-rw-r--r--src/lib/evas/canvas/efl_event_key.c2
-rw-r--r--src/lib/evas/canvas/efl_event_pointer.c17
-rw-r--r--src/lib/evas/canvas/efl_event_pointer.eo1
-rw-r--r--src/lib/evas/canvas/evas_callbacks.c138
-rw-r--r--src/lib/evas/canvas/evas_events_legacy.c274
8 files changed, 409 insertions, 65 deletions
diff --git a/src/lib/evas/canvas/efl_canvas_object.eo b/src/lib/evas/canvas/efl_canvas_object.eo
index 61da55f..cd21b3e 100644
--- a/src/lib/evas/canvas/efl_canvas_object.eo
+++ b/src/lib/evas/canvas/efl_canvas_object.eo
@@ -599,21 +599,9 @@ abstract Efl.Canvas.Object (Efl.Object, Efl.Gfx, Efl.Gfx.Stack, Efl.Animator,
599 Efl.Gfx.Map.map_enable.get; 599 Efl.Gfx.Map.map_enable.get;
600 } 600 }
601 events { 601 events {
602 mouse,in @beta; [[Mouse In Event ]]
603 mouse,out @beta; [[Mouse Out Event ]]
604 mouse,down @beta; [[Mouse Button Down Event ]]
605 mouse,up @beta; [[Mouse Button Up Event ]]
606 mouse,move @beta; [[Mouse Move Event ]]
607 mouse,wheel @beta; [[Mouse Wheel Event ]]
608 multi,down @beta; [[Mouse-touch Down Event ]]
609 multi,up @beta; [[Mouse-touch Up Event ]]
610 multi,move @beta; [[Multi-touch Move Event ]]
611 free @beta; [[Object Being Freed (Called after Del) ]] 602 free @beta; [[Object Being Freed (Called after Del) ]]
612 key,down @beta; [[Key Press Event ]]
613 key,up @beta; [[Key Release Event ]]
614 focus,in; [[Focus In Event ]] 603 focus,in; [[Focus In Event ]]
615 focus,out; [[Focus Out Event ]] 604 focus,out; [[Focus Out Event ]]
616 del @beta; [[Object Being Deleted (called before Free) ]] 605 del @beta; [[Object Being Deleted (called before Free) ]]
617 hold @beta; [[Events go on/off hold ]]
618 } 606 }
619} 607}
diff --git a/src/lib/evas/canvas/efl_event_hold.c b/src/lib/evas/canvas/efl_event_hold.c
index 524f75c..8a84574 100644
--- a/src/lib/evas/canvas/efl_event_hold.c
+++ b/src/lib/evas/canvas/efl_event_hold.c
@@ -64,10 +64,23 @@ EOLIAN static Eo *
64_efl_event_hold_efl_object_constructor(Eo *obj, Efl_Event_Hold_Data *pd) 64_efl_event_hold_efl_object_constructor(Eo *obj, Efl_Event_Hold_Data *pd)
65{ 65{
66 obj = efl_constructor(efl_super(obj, MY_CLASS)); 66 obj = efl_constructor(efl_super(obj, MY_CLASS));
67 pd->eo = obj; 67 efl_event_reset(obj);
68 return obj; 68 return obj;
69} 69}
70 70
71static inline void
72_efl_event_hold_free(Efl_Event_Hold_Data *pd)
73{
74 free(pd->legacy);
75}
76
77EOLIAN static void
78_efl_event_hold_efl_object_destructor(Eo *obj, Efl_Event_Hold_Data *pd)
79{
80 _efl_event_hold_free(pd);
81 efl_destructor(efl_super(obj, MY_CLASS));
82}
83
71EOLIAN static Efl_Event * 84EOLIAN static Efl_Event *
72_efl_event_hold_efl_event_instance_get(Eo *klass EINA_UNUSED, void *_pd EINA_UNUSED, 85_efl_event_hold_efl_event_instance_get(Eo *klass EINA_UNUSED, void *_pd EINA_UNUSED,
73 Efl_Object *owner, void **priv) 86 Efl_Object *owner, void **priv)
@@ -81,6 +94,7 @@ _efl_event_hold_efl_event_instance_get(Eo *klass EINA_UNUSED, void *_pd EINA_UNU
81EOLIAN static void 94EOLIAN static void
82_efl_event_hold_efl_event_reset(Eo *obj, Efl_Event_Hold_Data *pd) 95_efl_event_hold_efl_event_reset(Eo *obj, Efl_Event_Hold_Data *pd)
83{ 96{
97 _efl_event_hold_free(pd);
84 memset(pd, 0, sizeof(*pd)); 98 memset(pd, 0, sizeof(*pd));
85 pd->eo = obj; 99 pd->eo = obj;
86} 100}
@@ -91,11 +105,14 @@ _efl_event_hold_efl_event_dup(Eo *obj, Efl_Event_Hold_Data *pd)
91 Efl_Event_Hold_Data *ev; 105 Efl_Event_Hold_Data *ev;
92 Efl_Event *evt = efl_add(EFL_EVENT_HOLD_CLASS, efl_parent_get(obj)); 106 Efl_Event *evt = efl_add(EFL_EVENT_HOLD_CLASS, efl_parent_get(obj));
93 ev = efl_data_scope_get(evt, MY_CLASS); 107 ev = efl_data_scope_get(evt, MY_CLASS);
94 if (ev) 108 if (!ev) return NULL;
95 { 109
96 memcpy(ev, pd, sizeof(*ev)); 110 ev->eo = evt;
97 ev->eo = evt; 111 ev->timestamp = pd->timestamp;
98 } 112 ev->data = pd->data;
113 ev->hold = pd->hold;
114 ev->device = pd->device; // lacks a proper ref :(
115
99 return evt; 116 return evt;
100} 117}
101 118
diff --git a/src/lib/evas/canvas/efl_event_hold.eo b/src/lib/evas/canvas/efl_event_hold.eo
index ddc4c3c..142a1b6 100644
--- a/src/lib/evas/canvas/efl_event_hold.eo
+++ b/src/lib/evas/canvas/efl_event_hold.eo
@@ -11,6 +11,7 @@ class Efl.Event.Hold (Efl.Object, Efl.Event.Input)
11 } 11 }
12 implements { 12 implements {
13 Efl.Object.constructor; 13 Efl.Object.constructor;
14 Efl.Object.destructor;
14 Efl.Event.instance_get; 15 Efl.Event.instance_get;
15 Efl.Event.reset; 16 Efl.Event.reset;
16 Efl.Event.dup; 17 Efl.Event.dup;
diff --git a/src/lib/evas/canvas/efl_event_key.c b/src/lib/evas/canvas/efl_event_key.c
index 2b81d4e..c54ef1a 100644
--- a/src/lib/evas/canvas/efl_event_key.c
+++ b/src/lib/evas/canvas/efl_event_key.c
@@ -79,6 +79,7 @@ _efl_event_key_efl_object_constructor(Eo *obj, Efl_Event_Key_Data *pd EINA_UNUSE
79static inline void 79static inline void
80_efl_event_key_free(Efl_Event_Key_Data *pd) 80_efl_event_key_free(Efl_Event_Key_Data *pd)
81{ 81{
82 free(pd->legacy);
82 eina_stringshare_del(pd->key); 83 eina_stringshare_del(pd->key);
83 eina_stringshare_del(pd->keyname); 84 eina_stringshare_del(pd->keyname);
84 eina_stringshare_del(pd->string); 85 eina_stringshare_del(pd->string);
@@ -185,6 +186,7 @@ _efl_event_key_efl_event_dup(Eo *obj EINA_UNUSED, Efl_Event_Key_Data *pd)
185 186
186 memcpy(ev, pd, sizeof(*ev)); 187 memcpy(ev, pd, sizeof(*ev));
187 ev->eo = evt; 188 ev->eo = evt;
189 ev->legacy = NULL;
188 ev->key = eina_stringshare_add(pd->key); 190 ev->key = eina_stringshare_add(pd->key);
189 ev->keyname = eina_stringshare_add(pd->keyname); 191 ev->keyname = eina_stringshare_add(pd->keyname);
190 ev->string = eina_stringshare_add(pd->string); 192 ev->string = eina_stringshare_add(pd->string);
diff --git a/src/lib/evas/canvas/efl_event_pointer.c b/src/lib/evas/canvas/efl_event_pointer.c
index 8db2735..f3f9597 100644
--- a/src/lib/evas/canvas/efl_event_pointer.c
+++ b/src/lib/evas/canvas/efl_event_pointer.c
@@ -82,15 +82,29 @@ _efl_event_pointer_class_destructor(Efl_Class *klass EINA_UNUSED)
82EOLIAN static Efl_Object * 82EOLIAN static Efl_Object *
83_efl_event_pointer_efl_object_constructor(Eo *obj, Efl_Event_Pointer_Data *pd EINA_UNUSED) 83_efl_event_pointer_efl_object_constructor(Eo *obj, Efl_Event_Pointer_Data *pd EINA_UNUSED)
84{ 84{
85 efl_constructor(efl_super(obj, MY_CLASS)); 85 obj = efl_constructor(efl_super(obj, MY_CLASS));
86 efl_event_reset(obj); 86 efl_event_reset(obj);
87 return obj; 87 return obj;
88} 88}
89 89
90static inline void
91_efl_event_pointer_free(Efl_Event_Pointer_Data *pd)
92{
93 free(pd->legacy);
94}
95
96EOLIAN static void
97_efl_event_pointer_efl_object_destructor(Eo *obj, Efl_Event_Pointer_Data *pd)
98{
99 _efl_event_pointer_free(pd);
100 efl_destructor(efl_super(obj, MY_CLASS));
101}
102
90EOLIAN static void 103EOLIAN static void
91_efl_event_pointer_efl_event_reset(Eo *obj, Efl_Event_Pointer_Data *pd) 104_efl_event_pointer_efl_event_reset(Eo *obj, Efl_Event_Pointer_Data *pd)
92{ 105{
93 Eina_Bool fake = pd->fake; 106 Eina_Bool fake = pd->fake;
107 _efl_event_pointer_free(pd);
94 memset(pd, 0, sizeof(*pd)); 108 memset(pd, 0, sizeof(*pd));
95 pd->eo = obj; 109 pd->eo = obj;
96 pd->wheel.dir = EFL_ORIENT_VERTICAL; 110 pd->wheel.dir = EFL_ORIENT_VERTICAL;
@@ -109,6 +123,7 @@ _efl_event_pointer_efl_event_dup(Eo *obj EINA_UNUSED, Efl_Event_Pointer_Data *pd
109 123
110 memcpy(ev, pd, sizeof(*ev)); 124 memcpy(ev, pd, sizeof(*ev));
111 ev->eo = evt; 125 ev->eo = evt;
126 ev->legacy = NULL;
112 ev->evas_done = 0; 127 ev->evas_done = 0;
113 ev->win_fed = 0; 128 ev->win_fed = 0;
114 ev->fake = 1; 129 ev->fake = 1;
diff --git a/src/lib/evas/canvas/efl_event_pointer.eo b/src/lib/evas/canvas/efl_event_pointer.eo
index 09fb1ba..e73866a 100644
--- a/src/lib/evas/canvas/efl_event_pointer.eo
+++ b/src/lib/evas/canvas/efl_event_pointer.eo
@@ -128,6 +128,7 @@ class Efl.Event.Pointer (Efl.Object, Efl.Event, Efl.Input.State, Efl.Event.Input
128 } 128 }
129 implements { 129 implements {
130 Efl.Object.constructor; 130 Efl.Object.constructor;
131 Efl.Object.destructor;
131 class.destructor; 132 class.destructor;
132 Efl.Event.instance_get; 133 Efl.Event.instance_get;
133 Efl.Event.reset; 134 Efl.Event.reset;
diff --git a/src/lib/evas/canvas/evas_callbacks.c b/src/lib/evas/canvas/evas_callbacks.c
index 36f4f38..ae9c9bb 100644
--- a/src/lib/evas/canvas/evas_callbacks.c
+++ b/src/lib/evas/canvas/evas_callbacks.c
@@ -16,11 +16,12 @@ extern Eina_Hash* signals_hash_table;
16/** 16/**
17 * Evas events descriptions for Eo. 17 * Evas events descriptions for Eo.
18 */ 18 */
19#define DEFINE_EVAS_CALLBACKS(LAST, ...) \ 19#define DEFINE_EVAS_CALLBACKS(FUNC, LAST, ...) \
20 static const Efl_Event_Description *_legacy_evas_callback_table(unsigned int index) \ 20 static const Efl_Event_Description *FUNC(unsigned int index) \
21 { \ 21 { \
22 static const Efl_Event_Description *internals[LAST] = { NULL }; \ 22 static const Efl_Event_Description *internals[LAST] = { NULL }; \
23 \ 23 \
24 if (index >= LAST) return NULL; \
24 if (internals[0] == NULL) \ 25 if (internals[0] == NULL) \
25 { \ 26 { \
26 memcpy(internals, \ 27 memcpy(internals, \
@@ -30,19 +31,19 @@ extern Eina_Hash* signals_hash_table;
30 return internals[index]; \ 31 return internals[index]; \
31 } 32 }
32 33
33DEFINE_EVAS_CALLBACKS(EVAS_CALLBACK_LAST, 34DEFINE_EVAS_CALLBACKS(_legacy_evas_callback_table, EVAS_CALLBACK_LAST,
34 EFL_CANVAS_OBJECT_EVENT_MOUSE_IN, 35 EFL_EVENT_POINTER_IN,
35 EFL_CANVAS_OBJECT_EVENT_MOUSE_OUT, 36 EFL_EVENT_POINTER_OUT,
36 EFL_CANVAS_OBJECT_EVENT_MOUSE_DOWN, 37 EFL_EVENT_POINTER_DOWN,
37 EFL_CANVAS_OBJECT_EVENT_MOUSE_UP, 38 EFL_EVENT_POINTER_UP,
38 EFL_CANVAS_OBJECT_EVENT_MOUSE_MOVE, 39 EFL_EVENT_POINTER_MOVE,
39 EFL_CANVAS_OBJECT_EVENT_MOUSE_WHEEL, 40 EFL_EVENT_POINTER_WHEEL,
40 EFL_CANVAS_OBJECT_EVENT_MULTI_DOWN, 41 EFL_EVENT_POINTER_DOWN,
41 EFL_CANVAS_OBJECT_EVENT_MULTI_UP, 42 EFL_EVENT_POINTER_UP,
42 EFL_CANVAS_OBJECT_EVENT_MULTI_MOVE, 43 EFL_EVENT_POINTER_MOVE,
43 EFL_CANVAS_OBJECT_EVENT_FREE, 44 EFL_CANVAS_OBJECT_EVENT_FREE,
44 EFL_CANVAS_OBJECT_EVENT_KEY_DOWN, 45 EFL_EVENT_KEY_DOWN,
45 EFL_CANVAS_OBJECT_EVENT_KEY_UP, 46 EFL_EVENT_KEY_UP,
46 EFL_CANVAS_OBJECT_EVENT_FOCUS_IN, 47 EFL_CANVAS_OBJECT_EVENT_FOCUS_IN,
47 EFL_CANVAS_OBJECT_EVENT_FOCUS_OUT, 48 EFL_CANVAS_OBJECT_EVENT_FOCUS_OUT,
48 EFL_GFX_EVENT_SHOW, 49 EFL_GFX_EVENT_SHOW,
@@ -51,7 +52,7 @@ DEFINE_EVAS_CALLBACKS(EVAS_CALLBACK_LAST,
51 EFL_GFX_EVENT_RESIZE, 52 EFL_GFX_EVENT_RESIZE,
52 EFL_GFX_EVENT_RESTACK, 53 EFL_GFX_EVENT_RESTACK,
53 EFL_CANVAS_OBJECT_EVENT_DEL, 54 EFL_CANVAS_OBJECT_EVENT_DEL,
54 EFL_CANVAS_OBJECT_EVENT_HOLD, 55 EFL_EVENT_HOLD,
55 EFL_GFX_EVENT_CHANGE_SIZE_HINTS, 56 EFL_GFX_EVENT_CHANGE_SIZE_HINTS,
56 EFL_IMAGE_EVENT_PRELOAD, 57 EFL_IMAGE_EVENT_PRELOAD,
57 EFL_CANVAS_EVENT_FOCUS_IN, 58 EFL_CANVAS_EVENT_FOCUS_IN,
@@ -74,6 +75,7 @@ typedef struct
74 Evas_Object_Event_Cb func; 75 Evas_Object_Event_Cb func;
75 void *data; 76 void *data;
76 Evas_Callback_Type type; 77 Evas_Callback_Type type;
78 int efl_event_info; // for key, pointer and hold
77} _eo_evas_object_cb_info; 79} _eo_evas_object_cb_info;
78 80
79typedef struct 81typedef struct
@@ -84,12 +86,74 @@ typedef struct
84 Evas_Callback_Type type; 86 Evas_Callback_Type type;
85} _eo_evas_cb_info; 87} _eo_evas_cb_info;
86 88
89#define EFL_EVENT_TYPE_LEGACY 0
90#define EFL_EVENT_TYPE_POINTER 1
91#define EFL_EVENT_TYPE_KEY 2
92#define EFL_EVENT_TYPE_HOLD 3
93
94static int
95_evas_event_efl_event_info_exists(Evas_Callback_Type type)
96{
97 switch (type)
98 {
99 case EVAS_CALLBACK_MOUSE_IN:
100 case EVAS_CALLBACK_MOUSE_OUT:
101 case EVAS_CALLBACK_MOUSE_DOWN:
102 case EVAS_CALLBACK_MOUSE_UP:
103 case EVAS_CALLBACK_MOUSE_MOVE:
104 case EVAS_CALLBACK_MOUSE_WHEEL:
105 case EVAS_CALLBACK_MULTI_DOWN:
106 case EVAS_CALLBACK_MULTI_UP:
107 case EVAS_CALLBACK_MULTI_MOVE:
108 return EFL_EVENT_TYPE_POINTER;
109 case EVAS_CALLBACK_KEY_DOWN:
110 case EVAS_CALLBACK_KEY_UP:
111 return EFL_EVENT_TYPE_KEY;
112 case EVAS_CALLBACK_HOLD:
113 return EFL_EVENT_TYPE_HOLD;
114 default:
115 return EFL_EVENT_TYPE_LEGACY;
116 }
117}
118
87static void 119static void
88_eo_evas_object_cb(void *data, const Eo_Event *event) 120_eo_evas_object_cb(void *data, const Eo_Event *event)
89{ 121{
122 Evas_Event_Flags *event_flags = NULL, evflags = EVAS_EVENT_FLAG_NONE;
123 Efl_Event *efl_event_info = event->info;
90 _eo_evas_object_cb_info *info = data; 124 _eo_evas_object_cb_info *info = data;
91 Evas *evas = evas_object_evas_get(event->object); 125 void *event_info;
92 if (info->func) info->func(info->data, evas, event->object, event->info); 126 Evas *evas;
127
128 evas = evas_object_evas_get(event->object);
129
130 if (!info->func) return;
131 switch (info->efl_event_info)
132 {
133 case EFL_EVENT_TYPE_POINTER:
134 event_info = efl_event_pointer_legacy_info_fill(efl_event_info, &event_flags);
135 break;
136
137 case EFL_EVENT_TYPE_KEY:
138 event_info = efl_event_key_legacy_info_fill(efl_event_info, &event_flags);
139 break;
140
141 case EFL_EVENT_TYPE_HOLD:
142 event_info = efl_event_hold_legacy_info_fill(efl_event_info, &event_flags);
143 break;
144
145 case EFL_EVENT_TYPE_LEGACY:
146 info->func(info->data, evas, event->object, event->info);
147 return;
148
149 default: return;
150 }
151
152 if (!event_info) return;
153 if (event_flags) evflags = *event_flags;
154 info->func(info->data, evas, event->object, event_info);
155 if (event_flags && (evflags != *event_flags))
156 efl_event_flags_set(efl_event_info, *event_flags);
93} 157}
94 158
95static void 159static void
@@ -262,38 +326,19 @@ evas_object_event_callback_call(Evas_Object *eo_obj, Evas_Object_Protected_Data
262 break; 326 break;
263 } 327 }
264 328
265 /* legacy callbacks - relying on Efl.Canvas.Object events */ 329 if (_evas_event_efl_event_info_exists(type))
266 efl_event_callback_call(eo_obj, _legacy_evas_callback_table(type), event_info);
267
268 /* new input events */
269 if (efl_event_desc)
270 { 330 {
271 Efl_Event_Flags *pevflags = NULL;
272
273#define EV_CASE(TYPE, NEWTYPE, Type) \
274 case EVAS_CALLBACK_ ## TYPE: \
275 pevflags = &(((Evas_Event_ ## Type *) event_info)->event_flags); \
276 break
277 switch (type)
278 {
279 EV_CASE(MOUSE_MOVE, POINTER_MOVE, Mouse_Move);
280 EV_CASE(MOUSE_OUT, POINTER_OUT, Mouse_Out);
281 EV_CASE(MOUSE_IN, POINTER_IN, Mouse_In);
282 EV_CASE(MOUSE_DOWN , POINTER_DOWN, Mouse_Down);
283 EV_CASE(MOUSE_UP, POINTER_UP, Mouse_Up);
284 EV_CASE(MULTI_MOVE, POINTER_MOVE, Multi_Move);
285 EV_CASE(MULTI_DOWN, POINTER_DOWN, Multi_Down);
286 EV_CASE(MULTI_UP, POINTER_UP, Multi_Up);
287 EV_CASE(MOUSE_WHEEL, POINTER_WHEEL, Mouse_Wheel);
288 EV_CASE(KEY_DOWN, KEY_DOWN, Key_Down);
289 EV_CASE(KEY_UP, KEY_UP, Key_Up);
290 default: break;
291 }
292#undef EV_CASE
293
294 if (pevflags) efl_event_flags_set(efl_event_info, *pevflags);
295 efl_event_callback_call(eo_obj, efl_event_desc, efl_event_info); 331 efl_event_callback_call(eo_obj, efl_event_desc, efl_event_info);
296 } 332 }
333 else
334 {
335 /* legacy callbacks - relying on Efl.Canvas.Object events */
336 efl_event_callback_call(eo_obj, _legacy_evas_callback_table(type), event_info);
337
338 /* new input events - unlikely */
339 if (efl_event_desc)
340 efl_event_callback_call(eo_obj, efl_event_desc, efl_event_info);
341 }
297 342
298 if (type == EVAS_CALLBACK_MOUSE_DOWN) 343 if (type == EVAS_CALLBACK_MOUSE_DOWN)
299 { 344 {
@@ -346,6 +391,7 @@ evas_object_event_callback_priority_add(Evas_Object *eo_obj, Evas_Callback_Type
346 cb_info->func = func; 391 cb_info->func = func;
347 cb_info->data = (void *)data; 392 cb_info->data = (void *)data;
348 cb_info->type = type; 393 cb_info->type = type;
394 cb_info->efl_event_info = _evas_event_efl_event_info_exists(type);
349 395
350 const Efl_Event_Description *desc = _legacy_evas_callback_table(type); 396 const Efl_Event_Description *desc = _legacy_evas_callback_table(type);
351 efl_event_callback_priority_add(eo_obj, desc, priority, _eo_evas_object_cb, cb_info); 397 efl_event_callback_priority_add(eo_obj, desc, priority, _eo_evas_object_cb, cb_info);
diff --git a/src/lib/evas/canvas/evas_events_legacy.c b/src/lib/evas/canvas/evas_events_legacy.c
index 5c48e8d..0d2cd24 100644
--- a/src/lib/evas/canvas/evas_events_legacy.c
+++ b/src/lib/evas/canvas/evas_events_legacy.c
@@ -209,6 +209,215 @@ efl_event_pointer_legacy_info_set(Efl_Event_Pointer *evt, const void *event_info
209 return EINA_TRUE; 209 return EINA_TRUE;
210} 210}
211 211
212void *
213efl_event_pointer_legacy_info_fill(Efl_Event_Key *evt, Evas_Event_Flags **pflags)
214{
215 Efl_Event_Pointer_Data *ev = efl_data_scope_get(evt, EFL_EVENT_POINTER_CLASS);
216 if (!ev) return NULL;
217
218#define COORD_DUP(e) do { (e)->output.x = (e)->canvas.x; (e)->output.y = (e)->canvas.y; } while (0)
219
220 switch (ev->action)
221 {
222 case EFL_POINTER_ACTION_IN:
223 {
224 Evas_Event_Mouse_In *e = ev->legacy ? ev->legacy : calloc(1, sizeof(*e));
225 e->canvas.x = ev->cur.x;
226 e->canvas.y = ev->cur.y;
227 COORD_DUP(e);
228 e->data = ev->data;
229 e->timestamp = ev->timestamp;
230 e->event_flags = ev->event_flags;
231 e->dev = ev->device;
232 e->event_src = ev->source;
233 e->modifiers = ev->modifiers;
234 e->locks = ev->locks;
235 if (pflags) *pflags = &e->event_flags;
236 ev->legacy = e;
237 return e;
238 }
239
240 case EFL_POINTER_ACTION_OUT:
241 {
242 Evas_Event_Mouse_Out *e = ev->legacy ? ev->legacy : calloc(1, sizeof(*e));
243 e->canvas.x = ev->cur.x;
244 e->canvas.y = ev->cur.y;
245 COORD_DUP(e);
246 e->data = ev->data;
247 e->timestamp = ev->timestamp;
248 e->event_flags = ev->event_flags;
249 e->dev = ev->device;
250 e->event_src = ev->source;
251 e->modifiers = ev->modifiers;
252 e->locks = ev->locks;
253 if (pflags) *pflags = &e->event_flags;
254 ev->legacy = e;
255 return e;
256 }
257
258 case EFL_POINTER_ACTION_DOWN:
259 if (ev->finger == 0)
260 {
261 Evas_Event_Mouse_Down *e = ev->legacy ? ev->legacy : calloc(1, sizeof(*e));
262 e->button = ev->button;
263 e->canvas.x = ev->cur.x;
264 e->canvas.y = ev->cur.y;
265 COORD_DUP(e);
266 e->data = ev->data;
267 e->flags = ev->button_flags;
268 e->timestamp = ev->timestamp;
269 e->event_flags = ev->event_flags;
270 e->dev = ev->device;
271 e->event_src = ev->source;
272 e->modifiers = ev->modifiers;
273 e->locks = ev->locks;
274 if (pflags) *pflags = &e->event_flags;
275 ev->legacy = e;
276 return e;
277 }
278 else
279 {
280 Evas_Event_Multi_Down *e = ev->legacy ? ev->legacy : calloc(1, sizeof(*e));
281 e->device = ev->finger;
282 e->radius = ev->radius;
283 e->radius_x = ev->radius_x;
284 e->radius_y = ev->radius_y;
285 e->pressure = ev->pressure;
286 e->angle = ev->angle;
287 e->canvas.xsub = ev->cur.x;
288 e->canvas.ysub = ev->cur.y;
289 e->canvas.x = ev->cur.x;
290 e->canvas.y = ev->cur.y;
291 COORD_DUP(e);
292 e->data = ev->data;
293 e->flags = ev->button_flags;
294 e->timestamp = ev->timestamp;
295 e->event_flags = ev->event_flags;
296 e->dev = ev->device;
297 e->modifiers = ev->modifiers;
298 e->locks = ev->locks;
299 if (pflags) *pflags = &e->event_flags;
300 ev->legacy = e;
301 return e;
302 }
303
304 case EFL_POINTER_ACTION_UP:
305 if (ev->finger == 0)
306 {
307 Evas_Event_Mouse_Up *e = ev->legacy ? ev->legacy : calloc(1, sizeof(*e));
308 e->button = ev->button;
309 e->canvas.x = ev->cur.x;
310 e->canvas.y = ev->cur.y;
311 COORD_DUP(e);
312 e->data = ev->data;
313 e->flags = ev->button_flags;
314 e->timestamp = ev->timestamp;
315 e->event_flags = ev->event_flags;
316 e->dev = ev->device;
317 e->event_src = ev->source;
318 e->modifiers = ev->modifiers;
319 e->locks = ev->locks;
320 if (pflags) *pflags = &e->event_flags;
321 ev->legacy = e;
322 return e;
323 }
324 else
325 {
326 Evas_Event_Multi_Up *e = ev->legacy ? ev->legacy : calloc(1, sizeof(*e));
327 e->device = ev->finger;
328 e->radius = ev->radius;
329 e->radius_x = ev->radius_x;
330 e->radius_y = ev->radius_y;
331 e->pressure = ev->pressure;
332 e->angle = ev->angle;
333 e->canvas.xsub = ev->cur.x;
334 e->canvas.ysub = ev->cur.y;
335 e->canvas.x = ev->cur.x;
336 e->canvas.y = ev->cur.y;
337 COORD_DUP(e);
338 e->data = ev->data;
339 e->flags = ev->button_flags;
340 e->timestamp = ev->timestamp;
341 e->event_flags = ev->event_flags;
342 e->dev = ev->device;
343 e->modifiers = ev->modifiers;
344 e->locks = ev->locks;
345 if (pflags) *pflags = &e->event_flags;
346 ev->legacy = e;
347 return e;
348 }
349
350 case EFL_POINTER_ACTION_MOVE:
351 if (ev->finger == 0)
352 {
353 Evas_Event_Mouse_Move *e = ev->legacy ? ev->legacy : calloc(1, sizeof(*e));
354 e->buttons = ev->pressed_buttons;
355 e->cur.canvas.x = ev->cur.x;
356 e->cur.canvas.y = ev->cur.y;
357 COORD_DUP(&e->cur);
358 e->prev.canvas.x = ev->prev.x;
359 e->prev.canvas.y = ev->prev.y;
360 COORD_DUP(&e->prev);
361 e->data = ev->data;
362 e->timestamp = ev->timestamp;
363 e->event_flags = ev->event_flags;
364 e->dev = ev->device;
365 e->event_src = ev->source;
366 e->modifiers = ev->modifiers;
367 e->locks = ev->locks;
368 if (pflags) *pflags = &e->event_flags;
369 ev->legacy = e;
370 return e;
371 }
372 else
373 {
374 Evas_Event_Multi_Move *e = ev->legacy ? ev->legacy : calloc(1, sizeof(*e));
375 e->device = ev->finger;
376 e->radius = ev->radius;
377 e->radius_x = ev->radius_x;
378 e->radius_y = ev->radius_y;
379 e->pressure = ev->pressure;
380 e->angle = ev->angle;
381 e->cur.canvas.xsub = ev->cur.x;
382 e->cur.canvas.ysub = ev->cur.y;
383 e->cur.canvas.x = ev->cur.x;
384 e->cur.canvas.y = ev->cur.y;
385 COORD_DUP(&e->cur);
386 e->data = ev->data;
387 e->timestamp = ev->timestamp;
388 e->event_flags = ev->event_flags;
389 e->dev = ev->device;
390 e->modifiers = ev->modifiers;
391 e->locks = ev->locks;
392 if (pflags) *pflags = &e->event_flags;
393 ev->legacy = e;
394 return e;
395 }
396
397 case EFL_POINTER_ACTION_WHEEL:
398 {
399 Evas_Event_Mouse_Wheel *e = ev->legacy ? ev->legacy : calloc(1, sizeof(*e));
400 e->direction = (ev->wheel.dir == EFL_ORIENT_HORIZONTAL) ? 1 : 0;
401 e->z = ev->wheel.z;
402 e->canvas.x = ev->cur.x;
403 e->canvas.y = ev->cur.y;
404 COORD_DUP(e);
405 e->data = ev->data;
406 e->timestamp = ev->timestamp;
407 e->event_flags = ev->event_flags;
408 e->dev = ev->device;
409 e->modifiers = ev->modifiers;
410 e->locks = ev->locks;
411 if (pflags) *pflags = &e->event_flags;
412 ev->legacy = e;
413 return e;
414 }
415
416 default:
417 return NULL;
418 }
419}
420
212Eina_Bool 421Eina_Bool
213efl_event_key_legacy_info_set(Efl_Event_Key *evt, const void *event_info, Evas_Callback_Type type) 422efl_event_key_legacy_info_set(Efl_Event_Key *evt, const void *event_info, Evas_Callback_Type type)
214{ 423{
@@ -261,6 +470,52 @@ efl_event_key_legacy_info_set(Efl_Event_Key *evt, const void *event_info, Evas_C
261 return EINA_TRUE; 470 return EINA_TRUE;
262} 471}
263 472
473void *
474efl_event_key_legacy_info_fill(Efl_Event_Key *evt, Evas_Event_Flags **pflags)
475{
476 Efl_Event_Key_Data *ev;
477
478 ev = efl_data_scope_get(evt, EFL_EVENT_KEY_CLASS);
479 if (!ev) return NULL;
480
481 if (ev->pressed)
482 {
483 Evas_Event_Key_Down *e = ev->legacy ? ev->legacy : calloc(1, sizeof(*e));
484 e->timestamp = ev->timestamp;
485 e->keyname = (char *) ev->keyname;
486 e->key = ev->key;
487 e->string = ev->string;
488 e->compose = ev->compose;
489 e->keycode = ev->keycode;
490 e->data = ev->data;
491 e->modifiers = ev->modifiers;
492 e->locks = ev->locks;
493 e->event_flags = ev->event_flags;
494 e->dev = ev->device;
495 if (pflags) *pflags = &e->event_flags;
496 ev->legacy = e;
497 return e;
498 }
499 else
500 {
501 Evas_Event_Key_Up *e = ev->legacy ? ev->legacy : calloc(1, sizeof(*e));
502 e->timestamp = ev->timestamp;
503 e->keyname = (char *) ev->keyname;
504 e->key = ev->key;
505 e->string = ev->string;
506 e->compose = ev->compose;
507 e->keycode = ev->keycode;
508 e->data = ev->data;
509 e->modifiers = ev->modifiers;
510 e->locks = ev->locks;
511 e->event_flags = ev->event_flags;
512 e->dev = ev->device;
513 if (pflags) *pflags = &e->event_flags;
514 ev->legacy = e;
515 return e;
516 }
517}
518
264Eina_Bool 519Eina_Bool
265efl_event_hold_legacy_info_set(Efl_Event_Hold *evt, const void *event_info, Evas_Callback_Type type) 520efl_event_hold_legacy_info_set(Efl_Event_Hold *evt, const void *event_info, Evas_Callback_Type type)
266{ 521{
@@ -281,3 +536,22 @@ efl_event_hold_legacy_info_set(Efl_Event_Hold *evt, const void *event_info, Evas
281 536
282 return EINA_TRUE; 537 return EINA_TRUE;
283} 538}
539
540void *
541efl_event_hold_legacy_info_fill(Efl_Event_Hold *evt, Evas_Event_Flags **pflags)
542{
543 Efl_Event_Hold_Data *ev = efl_data_scope_get(evt, EFL_EVENT_HOLD_CLASS);
544 Evas_Event_Hold *e;
545
546 if (!ev) return NULL;
547
548 e = ev->legacy ? ev->legacy : calloc(1, sizeof(*e));
549 e->timestamp = ev->timestamp;
550 e->dev = ev->device;
551 e->hold = ev->hold;
552 e->event_flags = 0; // FIXME?
553 if (pflags) *pflags = &e->event_flags;
554 ev->legacy = e;
555
556 return e;
557}