summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2017-02-16 16:26:42 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-02-16 16:26:42 +0900
commite434653fc2a23b1841ebbe243f5169813939b178 (patch)
tree74a70f04bf6c498eeec293b559b581ab194644df
parent5335352eda4f4e1fe11c0aace94d9e6c1c2e87b9 (diff)
evas: Ensure post-event cb push is called from an event cb
This rejects calls to evas_post_event_callback_push() that don't originate from inside an input event callback.
-rw-r--r--src/lib/evas/canvas/evas_callbacks.c28
-rw-r--r--src/lib/evas/canvas/evas_main.c1
-rw-r--r--src/lib/evas/include/evas_private.h1
3 files changed, 27 insertions, 3 deletions
diff --git a/src/lib/evas/canvas/evas_callbacks.c b/src/lib/evas/canvas/evas_callbacks.c
index 2b4e88e4f9..da5bb48b96 100644
--- a/src/lib/evas/canvas/evas_callbacks.c
+++ b/src/lib/evas/canvas/evas_callbacks.c
@@ -252,6 +252,8 @@ _evas_post_event_callback_free(Evas *eo_e)
252 Evas_Public_Data *e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS); 252 Evas_Public_Data *e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS);
253 Evas_Post_Callback *pc; 253 Evas_Post_Callback *pc;
254 254
255 if (EINA_LIKELY(!e->post_events)) return;
256
255 EINA_LIST_FREE(e->post_events, pc) 257 EINA_LIST_FREE(e->post_events, pc)
256 { 258 {
257 EVAS_MEMPOOL_FREE(_mp_pc, pc); 259 EVAS_MEMPOOL_FREE(_mp_pc, pc);
@@ -323,6 +325,7 @@ evas_object_event_callback_call(Evas_Object *eo_obj, Evas_Object_Protected_Data
323 /* MEM OK */ 325 /* MEM OK */
324 const Evas_Button_Flags CLICK_MASK = EVAS_BUTTON_DOUBLE_CLICK | EVAS_BUTTON_TRIPLE_CLICK; 326 const Evas_Button_Flags CLICK_MASK = EVAS_BUTTON_DOUBLE_CLICK | EVAS_BUTTON_TRIPLE_CLICK;
325 Evas_Button_Flags flags = EVAS_BUTTON_NONE; 327 Evas_Button_Flags flags = EVAS_BUTTON_NONE;
328 Evas_Callback_Type prev_type;
326 Evas_Public_Data *e; 329 Evas_Public_Data *e;
327 330
328 if (!obj) return; 331 if (!obj) return;
@@ -364,27 +367,41 @@ evas_object_event_callback_call(Evas_Object *eo_obj, Evas_Object_Protected_Data
364 efl_event_desc = _legacy_evas_callback_table(type); 367 efl_event_desc = _legacy_evas_callback_table(type);
365 } 368 }
366 369
370 prev_type = e->current_event;
371 e->current_event = type;
372
367 efl_event_callback_legacy_call(eo_obj, efl_event_desc, event_info); 373 efl_event_callback_legacy_call(eo_obj, efl_event_desc, event_info);
368 374
369 /* multi events with finger 0 - only for eo callbacks */ 375 /* multi events with finger 0 - only for eo callbacks */
370 if (type == EVAS_CALLBACK_MOUSE_DOWN) 376 if (type == EVAS_CALLBACK_MOUSE_DOWN)
371 { 377 {
372 if (_evas_object_callback_has_by_type(obj, EVAS_CALLBACK_MULTI_DOWN)) 378 if (_evas_object_callback_has_by_type(obj, EVAS_CALLBACK_MULTI_DOWN))
373 efl_event_callback_call(eo_obj, EFL_EVENT_FINGER_DOWN, event_info); 379 {
380 e->current_event = EVAS_CALLBACK_MULTI_DOWN;
381 efl_event_callback_call(eo_obj, EFL_EVENT_FINGER_DOWN, event_info);
382 }
374 efl_input_pointer_button_flags_set(event_info, flags); 383 efl_input_pointer_button_flags_set(event_info, flags);
375 } 384 }
376 else if (type == EVAS_CALLBACK_MOUSE_UP) 385 else if (type == EVAS_CALLBACK_MOUSE_UP)
377 { 386 {
378 if (_evas_object_callback_has_by_type(obj, EVAS_CALLBACK_MULTI_UP)) 387 if (_evas_object_callback_has_by_type(obj, EVAS_CALLBACK_MULTI_UP))
379 efl_event_callback_call(eo_obj, EFL_EVENT_FINGER_UP, event_info); 388 {
389 e->current_event = EVAS_CALLBACK_MULTI_UP;
390 efl_event_callback_call(eo_obj, EFL_EVENT_FINGER_UP, event_info);
391 }
380 efl_input_pointer_button_flags_set(event_info, flags); 392 efl_input_pointer_button_flags_set(event_info, flags);
381 } 393 }
382 else if (type == EVAS_CALLBACK_MOUSE_MOVE) 394 else if (type == EVAS_CALLBACK_MOUSE_MOVE)
383 { 395 {
384 if (_evas_object_callback_has_by_type(obj, EVAS_CALLBACK_MULTI_MOVE)) 396 if (_evas_object_callback_has_by_type(obj, EVAS_CALLBACK_MULTI_MOVE))
385 efl_event_callback_call(eo_obj, EFL_EVENT_FINGER_MOVE, event_info); 397 {
398 e->current_event = EVAS_CALLBACK_MULTI_MOVE;
399 efl_event_callback_call(eo_obj, EFL_EVENT_FINGER_MOVE, event_info);
400 }
386 } 401 }
387 402
403 e->current_event = prev_type;
404
388nothing_here: 405nothing_here:
389 if (!obj->no_propagate) 406 if (!obj->no_propagate)
390 { 407 {
@@ -580,6 +597,11 @@ evas_post_event_callback_push(Evas *eo_e, Evas_Object_Event_Post_Cb func, const
580 Evas_Post_Callback *pc; 597 Evas_Post_Callback *pc;
581 598
582 if (!e || e->delete_me) return; 599 if (!e || e->delete_me) return;
600 if (e->current_event == EVAS_CALLBACK_LAST)
601 {
602 ERR("%s() can only be called from an input event callback!", __FUNCTION__);
603 return;
604 }
583 EVAS_MEMPOOL_INIT(_mp_pc, "evas_post_callback", Evas_Post_Callback, 64, ); 605 EVAS_MEMPOOL_INIT(_mp_pc, "evas_post_callback", Evas_Post_Callback, 64, );
584 pc = EVAS_MEMPOOL_ALLOC(_mp_pc, Evas_Post_Callback); 606 pc = EVAS_MEMPOOL_ALLOC(_mp_pc, Evas_Post_Callback);
585 if (!pc) return; 607 if (!pc) return;
diff --git a/src/lib/evas/canvas/evas_main.c b/src/lib/evas/canvas/evas_main.c
index 3a1aa0e63f..fff28b4bc2 100644
--- a/src/lib/evas/canvas/evas_main.c
+++ b/src/lib/evas/canvas/evas_main.c
@@ -214,6 +214,7 @@ _evas_canvas_efl_object_constructor(Eo *eo_obj, Evas_Public_Data *e)
214 e->framespace.w = 0; 214 e->framespace.w = 0;
215 e->framespace.h = 0; 215 e->framespace.h = 0;
216 e->hinting = EVAS_FONT_HINTING_BYTECODE; 216 e->hinting = EVAS_FONT_HINTING_BYTECODE;
217 e->current_event = EVAS_CALLBACK_LAST;
217 e->name_hash = eina_hash_string_superfast_new(NULL); 218 e->name_hash = eina_hash_string_superfast_new(NULL);
218 eina_clist_init(&e->calc_list); 219 eina_clist_init(&e->calc_list);
219 eina_clist_init(&e->calc_done); 220 eina_clist_init(&e->calc_done);
diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h
index a62852a91e..ff28339f32 100644
--- a/src/lib/evas/include/evas_private.h
+++ b/src/lib/evas/include/evas_private.h
@@ -929,6 +929,7 @@ struct _Evas_Public_Data
929 int last_mouse_up_counter; 929 int last_mouse_up_counter;
930 int nochange; 930 int nochange;
931 Evas_Font_Hinting_Flags hinting; 931 Evas_Font_Hinting_Flags hinting;
932 Evas_Callback_Type current_event;
932 933
933 Eina_List *touch_points; 934 Eina_List *touch_points;
934 Eina_List *devices; 935 Eina_List *devices;