summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-03-13 17:37:32 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-03-13 17:37:32 +0900
commit3a9d54085b8751cbd0bca4698a8ff702d9bdc7b4 (patch)
tree022fcb4b5ef5c5df962482f301531cef6f01e073
parentf06600fc292cb82d48719e1b089080376f885f70 (diff)
ecore-evas reduce modifier modification on every event to cut cpu
this only modifiers modifiers if the modifier mask changed. it stores it per seat and matches up before deciding to actually modifier the modifiers. this SHOULD fix T5252 @fix
-rw-r--r--src/lib/ecore_input_evas/ecore_input_evas.c163
1 files changed, 135 insertions, 28 deletions
diff --git a/src/lib/ecore_input_evas/ecore_input_evas.c b/src/lib/ecore_input_evas/ecore_input_evas.c
index 7866bd5d9a..1748167289 100644
--- a/src/lib/ecore_input_evas/ecore_input_evas.c
+++ b/src/lib/ecore_input_evas/ecore_input_evas.c
@@ -15,17 +15,28 @@
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
19struct _Ecore_Input_Window 21struct _Ecore_Input_Window
20{ 22{
21 Evas *evas; 23 Evas *evas;
22 void *window; 24 void *window;
23 Ecore_Event_Mouse_Move_Cb move_mouse; 25 Ecore_Input_Seat_State *device_states;
24 Ecore_Event_Multi_Move_Cb move_multi; 26 Ecore_Event_Mouse_Move_Cb move_mouse;
25 Ecore_Event_Multi_Down_Cb down_multi; 27 Ecore_Event_Multi_Move_Cb move_multi;
26 Ecore_Event_Multi_Up_Cb up_multi; 28 Ecore_Event_Multi_Down_Cb down_multi;
27 Ecore_Event_Direct_Input_Cb direct; 29 Ecore_Event_Multi_Up_Cb up_multi;
28 int ignore_event; 30 Ecore_Event_Direct_Input_Cb direct;
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;
29}; 40};
30 41
31typedef enum _Ecore_Input_State { 42typedef enum _Ecore_Input_State {
@@ -278,9 +289,9 @@ _ecore_event_evas_push_mouse_move(Ecore_Event_Mouse_Move *e)
278 } 289 }
279} 290}
280 291
281EAPI void 292static void
282ecore_event_evas_seat_modifier_lock_update(Evas *e, unsigned int modifiers, 293_ecore_event_evas_seat_modifier_lock_update(Evas *e, unsigned int modifiers,
283 Evas_Device *seat) 294 Evas_Device *seat)
284{ 295{
285 if (modifiers & ECORE_EVENT_MODIFIER_SHIFT) 296 if (modifiers & ECORE_EVENT_MODIFIER_SHIFT)
286 evas_seat_key_modifier_on(e, "Shift", seat); 297 evas_seat_key_modifier_on(e, "Shift", seat);
@@ -326,10 +337,102 @@ ecore_event_evas_seat_modifier_lock_update(Evas *e, unsigned int modifiers,
326 else evas_seat_key_lock_off(e, "Shift_Lock", seat); 337 else evas_seat_key_lock_off(e, "Shift_Lock", seat);
327} 338}
328 339
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
329EAPI void 393EAPI void
330ecore_event_evas_modifier_lock_update(Evas *e, unsigned int modifiers) 394ecore_event_evas_modifier_lock_update(Evas *e, unsigned int modifiers)
331{ 395{
332 ecore_event_evas_seat_modifier_lock_update(e, modifiers, NULL); 396 _ecore_event_evas_modifier_lock_invalidate
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);
333} 436}
334 437
335EAPI void 438EAPI void
@@ -366,6 +469,14 @@ ecore_event_window_register(Ecore_Window id, void *window, Evas *evas,
366 evas_key_lock_add(evas, "Scroll_Lock"); 469 evas_key_lock_add(evas, "Scroll_Lock");
367} 470}
368 471
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
369EAPI void 480EAPI void
370ecore_event_window_unregister(Ecore_Window id) 481ecore_event_window_unregister(Ecore_Window id)
371{ 482{
@@ -420,9 +531,8 @@ _ecore_event_evas_key(Ecore_Event_Key *e, Ecore_Event_Press press)
420 531
421 lookup = _ecore_event_window_match(e->event_window); 532 lookup = _ecore_event_window_match(e->event_window);
422 if (!lookup) return ECORE_CALLBACK_PASS_ON; 533 if (!lookup) return ECORE_CALLBACK_PASS_ON;
423 ecore_event_evas_seat_modifier_lock_update(lookup->evas, 534 _ecore_event_evas_modifier_lock_update
424 e->modifiers, 535 (lookup, e->modifiers, efl_input_device_seat_get(e->dev));
425 efl_input_device_seat_get(e->dev));
426 if (press == ECORE_DOWN) 536 if (press == ECORE_DOWN)
427 { 537 {
428 if (!lookup->direct || 538 if (!lookup->direct ||
@@ -531,9 +641,8 @@ _ecore_event_evas_mouse_button(Ecore_Event_Mouse_Button *e, Ecore_Event_Press pr
531 641
532 if (e->multi.device == 0) 642 if (e->multi.device == 0)
533 { 643 {
534 ecore_event_evas_seat_modifier_lock_update(lookup->evas, 644 _ecore_event_evas_modifier_lock_update
535 e->modifiers, 645 (lookup, e->modifiers, efl_input_device_seat_get(e->dev));
536 efl_input_device_seat_get(e->dev));
537 if (press == ECORE_DOWN) 646 if (press == ECORE_DOWN)
538 { 647 {
539 if (!lookup->direct || 648 if (!lookup->direct ||
@@ -613,9 +722,8 @@ ecore_event_evas_mouse_move(void *data EINA_UNUSED, int type EINA_UNUSED, void *
613 if (e->multi.device == 0) 722 if (e->multi.device == 0)
614 { 723 {
615 _ecore_event_evas_push_mouse_move(e); 724 _ecore_event_evas_push_mouse_move(e);
616 ecore_event_evas_seat_modifier_lock_update(lookup->evas, 725 _ecore_event_evas_modifier_lock_update
617 e->modifiers, 726 (lookup, e->modifiers, efl_input_device_seat_get(e->dev));
618 efl_input_device_seat_get(e->dev));
619 if (!lookup->direct || 727 if (!lookup->direct ||
620 !lookup->direct(lookup->window, ECORE_EVENT_MOUSE_MOVE, e)) 728 !lookup->direct(lookup->window, ECORE_EVENT_MOUSE_MOVE, e))
621 { 729 {
@@ -674,9 +782,8 @@ _ecore_event_evas_mouse_io(Ecore_Event_Mouse_IO *e, Ecore_Event_IO io)
674 782
675 lookup = _ecore_event_window_match(e->event_window); 783 lookup = _ecore_event_window_match(e->event_window);
676 if (!lookup) return ECORE_CALLBACK_PASS_ON; 784 if (!lookup) return ECORE_CALLBACK_PASS_ON;
677 ecore_event_evas_seat_modifier_lock_update(lookup->evas, 785 _ecore_event_evas_modifier_lock_update
678 e->modifiers, 786 (lookup, e->modifiers, efl_input_device_seat_get(e->dev));
679 efl_input_device_seat_get(e->dev));
680 switch (io) 787 switch (io)
681 { 788 {
682 case ECORE_IN: 789 case ECORE_IN:
@@ -722,8 +829,8 @@ ecore_event_evas_mouse_wheel(void *data EINA_UNUSED, int type EINA_UNUSED, void
722 e = event; 829 e = event;
723 lookup = _ecore_event_window_match(e->event_window); 830 lookup = _ecore_event_window_match(e->event_window);
724 if (!lookup) return ECORE_CALLBACK_PASS_ON; 831 if (!lookup) return ECORE_CALLBACK_PASS_ON;
725 ecore_event_evas_seat_modifier_lock_update(lookup->evas, e->modifiers, 832 _ecore_event_evas_modifier_lock_update
726 efl_input_device_seat_get(e->dev)); 833 (lookup, e->modifiers, efl_input_device_seat_get(e->dev));
727 if (!lookup->direct || 834 if (!lookup->direct ||
728 !lookup->direct(lookup->window, ECORE_EVENT_MOUSE_WHEEL, e)) 835 !lookup->direct(lookup->window, ECORE_EVENT_MOUSE_WHEEL, e))
729 { 836 {
@@ -820,7 +927,7 @@ ecore_event_evas_init(void)
820 ecore_event_evas_mouse_button_cancel, 927 ecore_event_evas_mouse_button_cancel,
821 NULL); 928 NULL);
822 929
823 _window_hash = eina_hash_pointer_new(free); 930 _window_hash = eina_hash_pointer_new(_ecore_evas_input_win_free);
824 931
825 if (getenv("ECORE_INPUT_FIX")) 932 if (getenv("ECORE_INPUT_FIX"))
826 { 933 {