summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2017-03-13 11:11:44 -0700
committerCedric BAIL <cedric@osg.samsung.com>2017-03-13 13:42:00 -0700
commitee866ca59904077d6e69723d4f996e6bf571db7f (patch)
tree99a5432406939aabc4c9a3f56b8e184abd96ef9a
parent3fa7570bdad6ac8593cdd0a9f6af83f0b1afe286 (diff)
Revert "ecore-evas reduce modifier modification on every event to cut cpu"
This reverts commit 3a9d54085b8751cbd0bca4698a8ff702d9bdc7b4. I got crash and a lot of valgrind warning with this patch. All in all, I think we can just wait for next release and do a proper cleanup of our API to not rely on strings at all. For references this is the first valgrind warning I get (Not going to past the 100 following one) : ==11860== Invalid write of size 4 ==11860== at 0xB10DDD1: _ecore_event_evas_modifier_lock_update (ecore_input_evas.c:432) ==11860== by 0xB10E3DD: ecore_event_evas_mouse_move (ecore_input_evas.c:725) ==11860== by 0x5D5115D: _ecore_call_handler_cb (ecore_private.h:317) ==11860== by 0x5D5115D: _ecore_event_call (ecore_events.c:518) ==11860== by 0x5D5CC47: _ecore_main_loop_iterate_internal (ecore_main.c:2381) ==11860== by 0x5D5D42E: ecore_main_loop_begin (ecore_main.c:1289) ==11860== by 0x5D5D490: _efl_loop_begin (ecore_main.c:2831) ==11860== by 0x5D59555: efl_loop_begin (efl_loop.eo.c:32) ==11860== by 0x14F275: main (test.c:1188) ==11860== Address 0x19a36828 is 7 bytes after a block of size 1 alloc'd ==11860== at 0x4C2AACE: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==11860== by 0x4C2CC81: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==11860== by 0xB10DDA8: _ecore_event_evas_modifier_lock_update (ecore_input_evas.c:425) ==11860== by 0xB10E3DD: ecore_event_evas_mouse_move (ecore_input_evas.c:725) ==11860== by 0x5D5115D: _ecore_call_handler_cb (ecore_private.h:317) ==11860== by 0x5D5115D: _ecore_event_call (ecore_events.c:518) ==11860== by 0x5D5CC47: _ecore_main_loop_iterate_internal (ecore_main.c:2381) ==11860== by 0x5D5D42E: ecore_main_loop_begin (ecore_main.c:1289) ==11860== by 0x5D5D490: _efl_loop_begin (ecore_main.c:2831) ==11860== by 0x5D59555: efl_loop_begin (efl_loop.eo.c:32) ==11860== by 0x14F275: main (test.c:1188)
-rw-r--r--src/lib/ecore_input_evas/ecore_input_evas.c163
1 files changed, 28 insertions, 135 deletions
diff --git a/src/lib/ecore_input_evas/ecore_input_evas.c b/src/lib/ecore_input_evas/ecore_input_evas.c
index 1748167289..7866bd5d9a 100644
--- a/src/lib/ecore_input_evas/ecore_input_evas.c
+++ b/src/lib/ecore_input_evas/ecore_input_evas.c
@@ -15,28 +15,17 @@
15 15
16int _ecore_input_evas_log_dom = -1; 16int _ecore_input_evas_log_dom = -1;
17 17
18typedef struct _Ecore_Input_Window Ecore_Input_Window; 18typedef struct _Ecore_Input_Window Ecore_Input_Window;
19typedef struct _Ecore_Input_Seat_State Ecore_Input_Seat_State;
20
21struct _Ecore_Input_Window 19struct _Ecore_Input_Window
22{ 20{
23 Evas *evas; 21 Evas *evas;
24 void *window; 22 void *window;
25 Ecore_Input_Seat_State *device_states; 23 Ecore_Event_Mouse_Move_Cb move_mouse;
26 Ecore_Event_Mouse_Move_Cb move_mouse; 24 Ecore_Event_Multi_Move_Cb move_multi;
27 Ecore_Event_Multi_Move_Cb move_multi; 25 Ecore_Event_Multi_Down_Cb down_multi;
28 Ecore_Event_Multi_Down_Cb down_multi; 26 Ecore_Event_Multi_Up_Cb up_multi;
29 Ecore_Event_Multi_Up_Cb up_multi; 27 Ecore_Event_Direct_Input_Cb direct;
30 Ecore_Event_Direct_Input_Cb direct; 28 int ignore_event;
31 int device_states_num;
32 int ignore_event;
33};
34
35struct _Ecore_Input_Seat_State
36{
37 Evas_Device *seat;
38 unsigned int modifiers;
39 unsigned int invalid;
40}; 29};
41 30
42typedef enum _Ecore_Input_State { 31typedef enum _Ecore_Input_State {
@@ -289,9 +278,9 @@ _ecore_event_evas_push_mouse_move(Ecore_Event_Mouse_Move *e)
289 } 278 }
290} 279}
291 280
292static void 281EAPI void
293_ecore_event_evas_seat_modifier_lock_update(Evas *e, unsigned int modifiers, 282ecore_event_evas_seat_modifier_lock_update(Evas *e, unsigned int modifiers,
294 Evas_Device *seat) 283 Evas_Device *seat)
295{ 284{
296 if (modifiers & ECORE_EVENT_MODIFIER_SHIFT) 285 if (modifiers & ECORE_EVENT_MODIFIER_SHIFT)
297 evas_seat_key_modifier_on(e, "Shift", seat); 286 evas_seat_key_modifier_on(e, "Shift", seat);
@@ -337,102 +326,10 @@ _ecore_event_evas_seat_modifier_lock_update(Evas *e, unsigned int modifiers,
337 else evas_seat_key_lock_off(e, "Shift_Lock", seat); 326 else evas_seat_key_lock_off(e, "Shift_Lock", seat);
338} 327}
339 328
340static void
341_ecore_event_evas_modifier_lock_invalidate(Ecore_Input_Window *w)
342{
343 int i;
344
345 if (!w) return;
346 for (i = 0; i < w->device_states_num; i++) w->device_states[i].invalid = 1;
347}
348
349typedef struct
350{
351 const Evas *evas;
352 Ecore_Input_Window *w;
353} Find_Foreach_Data;
354
355static Eina_Bool
356_ecore_event_evas_window_evas_find_foreach_cb(const Eina_Hash *hash EINA_UNUSED,
357 const void *key EINA_UNUSED,
358 void *data, void *fdata)
359{
360 Ecore_Input_Window *w = data;
361 Find_Foreach_Data *foreach_data = fdata;
362
363 if (foreach_data->evas == w->evas)
364 {
365 foreach_data->w = w;
366 return EINA_FALSE;
367 }
368 return EINA_TRUE;
369}
370
371static Ecore_Input_Window *
372_ecore_event_evas_window_evas_find(const Evas *evas)
373{
374 Find_Foreach_Data fdata;
375
376 fdata.evas = evas;
377 fdata.w = NULL;
378 eina_hash_foreach(_window_hash,
379 _ecore_event_evas_window_evas_find_foreach_cb,
380 &fdata);
381 return fdata.w;
382}
383
384EAPI void
385ecore_event_evas_seat_modifier_lock_update(Evas *e, unsigned int modifiers,
386 Evas_Device *seat)
387{
388 _ecore_event_evas_modifier_lock_invalidate
389 (_ecore_event_evas_window_evas_find(e));
390 _ecore_event_evas_seat_modifier_lock_update(e, modifiers, seat);
391}
392
393EAPI void 329EAPI void
394ecore_event_evas_modifier_lock_update(Evas *e, unsigned int modifiers) 330ecore_event_evas_modifier_lock_update(Evas *e, unsigned int modifiers)
395{ 331{
396 _ecore_event_evas_modifier_lock_invalidate 332 ecore_event_evas_seat_modifier_lock_update(e, modifiers, NULL);
397 (_ecore_event_evas_window_evas_find(e));
398 _ecore_event_evas_seat_modifier_lock_update(e, modifiers, NULL);
399}
400
401static void
402_ecore_event_evas_modifier_lock_update(Ecore_Input_Window *w,
403 unsigned int modifiers,
404 Evas_Device *seat)
405{
406 Ecore_Input_Seat_State *states;
407 int i;
408
409 for (i = 0; i < w->device_states_num; i++)
410 {
411 if (w->device_states[i].seat == seat)
412 {
413 if ((w->device_states[i].invalid) ||
414 (modifiers != w->device_states[i].modifiers))
415 {
416 w->device_states[i].invalid = 0;
417 w->device_states[i].modifiers = modifiers;
418 ecore_event_evas_seat_modifier_lock_update
419 (w->evas, modifiers, seat);
420 }
421 return;
422 }
423 }
424 w->device_states_num++;
425 states = realloc(w->device_states, w->device_states_num);
426 if (!states)
427 {
428 w->device_states_num--;
429 return;
430 }
431 states[w->device_states_num - 1].seat = seat;
432 states[w->device_states_num - 1].modifiers = modifiers;
433 states[w->device_states_num - 1].invalid = 0;
434 w->device_states = states;
435 _ecore_event_evas_seat_modifier_lock_update(w->evas, modifiers, seat);
436} 333}
437 334
438EAPI void 335EAPI void
@@ -469,14 +366,6 @@ ecore_event_window_register(Ecore_Window id, void *window, Evas *evas,
469 evas_key_lock_add(evas, "Scroll_Lock"); 366 evas_key_lock_add(evas, "Scroll_Lock");
470} 367}
471 368
472static void
473_ecore_evas_input_win_free(void *data)
474{
475 Ecore_Input_Window *w = data;
476 free(w->device_states);
477 free(w);
478}
479
480EAPI void 369EAPI void
481ecore_event_window_unregister(Ecore_Window id) 370ecore_event_window_unregister(Ecore_Window id)
482{ 371{
@@ -531,8 +420,9 @@ _ecore_event_evas_key(Ecore_Event_Key *e, Ecore_Event_Press press)
531 420
532 lookup = _ecore_event_window_match(e->event_window); 421 lookup = _ecore_event_window_match(e->event_window);
533 if (!lookup) return ECORE_CALLBACK_PASS_ON; 422 if (!lookup) return ECORE_CALLBACK_PASS_ON;
534 _ecore_event_evas_modifier_lock_update 423 ecore_event_evas_seat_modifier_lock_update(lookup->evas,
535 (lookup, e->modifiers, efl_input_device_seat_get(e->dev)); 424 e->modifiers,
425 efl_input_device_seat_get(e->dev));
536 if (press == ECORE_DOWN) 426 if (press == ECORE_DOWN)
537 { 427 {
538 if (!lookup->direct || 428 if (!lookup->direct ||
@@ -641,8 +531,9 @@ _ecore_event_evas_mouse_button(Ecore_Event_Mouse_Button *e, Ecore_Event_Press pr
641 531
642 if (e->multi.device == 0) 532 if (e->multi.device == 0)
643 { 533 {
644 _ecore_event_evas_modifier_lock_update 534 ecore_event_evas_seat_modifier_lock_update(lookup->evas,
645 (lookup, e->modifiers, efl_input_device_seat_get(e->dev)); 535 e->modifiers,
536 efl_input_device_seat_get(e->dev));
646 if (press == ECORE_DOWN) 537 if (press == ECORE_DOWN)
647 { 538 {
648 if (!lookup->direct || 539 if (!lookup->direct ||
@@ -722,8 +613,9 @@ ecore_event_evas_mouse_move(void *data EINA_UNUSED, int type EINA_UNUSED, void *
722 if (e->multi.device == 0) 613 if (e->multi.device == 0)
723 { 614 {
724 _ecore_event_evas_push_mouse_move(e); 615 _ecore_event_evas_push_mouse_move(e);
725 _ecore_event_evas_modifier_lock_update 616 ecore_event_evas_seat_modifier_lock_update(lookup->evas,
726 (lookup, e->modifiers, efl_input_device_seat_get(e->dev)); 617 e->modifiers,
618 efl_input_device_seat_get(e->dev));
727 if (!lookup->direct || 619 if (!lookup->direct ||
728 !lookup->direct(lookup->window, ECORE_EVENT_MOUSE_MOVE, e)) 620 !lookup->direct(lookup->window, ECORE_EVENT_MOUSE_MOVE, e))
729 { 621 {
@@ -782,8 +674,9 @@ _ecore_event_evas_mouse_io(Ecore_Event_Mouse_IO *e, Ecore_Event_IO io)
782 674
783 lookup = _ecore_event_window_match(e->event_window); 675 lookup = _ecore_event_window_match(e->event_window);
784 if (!lookup) return ECORE_CALLBACK_PASS_ON; 676 if (!lookup) return ECORE_CALLBACK_PASS_ON;
785 _ecore_event_evas_modifier_lock_update 677 ecore_event_evas_seat_modifier_lock_update(lookup->evas,
786 (lookup, e->modifiers, efl_input_device_seat_get(e->dev)); 678 e->modifiers,
679 efl_input_device_seat_get(e->dev));
787 switch (io) 680 switch (io)
788 { 681 {
789 case ECORE_IN: 682 case ECORE_IN:
@@ -829,8 +722,8 @@ ecore_event_evas_mouse_wheel(void *data EINA_UNUSED, int type EINA_UNUSED, void
829 e = event; 722 e = event;
830 lookup = _ecore_event_window_match(e->event_window); 723 lookup = _ecore_event_window_match(e->event_window);
831 if (!lookup) return ECORE_CALLBACK_PASS_ON; 724 if (!lookup) return ECORE_CALLBACK_PASS_ON;
832 _ecore_event_evas_modifier_lock_update 725 ecore_event_evas_seat_modifier_lock_update(lookup->evas, e->modifiers,
833 (lookup, e->modifiers, efl_input_device_seat_get(e->dev)); 726 efl_input_device_seat_get(e->dev));
834 if (!lookup->direct || 727 if (!lookup->direct ||
835 !lookup->direct(lookup->window, ECORE_EVENT_MOUSE_WHEEL, e)) 728 !lookup->direct(lookup->window, ECORE_EVENT_MOUSE_WHEEL, e))
836 { 729 {
@@ -927,7 +820,7 @@ ecore_event_evas_init(void)
927 ecore_event_evas_mouse_button_cancel, 820 ecore_event_evas_mouse_button_cancel,
928 NULL); 821 NULL);
929 822
930 _window_hash = eina_hash_pointer_new(_ecore_evas_input_win_free); 823 _window_hash = eina_hash_pointer_new(free);
931 824
932 if (getenv("ECORE_INPUT_FIX")) 825 if (getenv("ECORE_INPUT_FIX"))
933 { 826 {