summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-07-04 15:24:22 +0200
committerMarcel Hollerbach <mail@bu5hm4n.de>2019-07-04 20:41:23 +0200
commita94c72f4dec91153d45b5e98bdb169b56fe0132b (patch)
tree03407b11a360fa14a971b0191978d65c9a84a441
parente776f5f0d7b6292d32c29ccb4fffe3f20063d53d (diff)
efl_ui_widget: optimize focus
this commit ensures 2 things: 1. This ensures that the parent is not evaluated when there was no state changed, this cuts down roughly 30% of the calls to full_eval 2. This ensures that we only listen to parent manager changes when we are actaully registered. This reduces the amount spend in event emission a lot.
-rw-r--r--src/lib/elementary/efl_ui_widget.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/lib/elementary/efl_ui_widget.c b/src/lib/elementary/efl_ui_widget.c
index 70b8c828e5..91fccee918 100644
--- a/src/lib/elementary/efl_ui_widget.c
+++ b/src/lib/elementary/efl_ui_widget.c
@@ -303,13 +303,16 @@ static void _full_eval(Eo *obj, Elm_Widget_Smart_Data *pd);
303static void 303static void
304_manager_changed_cb(void *data, const Efl_Event *event EINA_UNUSED) 304_manager_changed_cb(void *data, const Efl_Event *event EINA_UNUSED)
305{ 305{
306 if (!efl_alive_get(data))
307 return;
308
306 ELM_WIDGET_DATA_GET(data, pd); 309 ELM_WIDGET_DATA_GET(data, pd);
307 310
308 _full_eval(data, pd); 311 _full_eval(data, pd);
309} 312}
310 313
311static Efl_Ui_Focus_Object* 314static Efl_Ui_Focus_Object*
312_focus_manager_eval(Eo *obj, Elm_Widget_Smart_Data *pd) 315_focus_manager_eval(Eo *obj, Elm_Widget_Smart_Data *pd, Eina_Bool want, Eina_Bool should)
313{ 316{
314 Evas_Object *provider = NULL; 317 Evas_Object *provider = NULL;
315 Evas_Object *parent; 318 Evas_Object *parent;
@@ -326,7 +329,7 @@ _focus_manager_eval(Eo *obj, Elm_Widget_Smart_Data *pd)
326 provider = parent; 329 provider = parent;
327 } 330 }
328 331
329 if (new != pd->manager.manager ) 332 if (new != pd->manager.manager)
330 { 333 {
331 old = pd->manager.manager; 334 old = pd->manager.manager;
332 335
@@ -335,8 +338,12 @@ _focus_manager_eval(Eo *obj, Elm_Widget_Smart_Data *pd)
335 338
336 pd->manager.manager = new; 339 pd->manager.manager = new;
337 pd->manager.provider = provider; 340 pd->manager.provider = provider;
338 341 }
339 if (pd->manager.provider) 342 if (pd->manager.provider)
343 {
344 if (!want && !should)
345 efl_event_callback_del(pd->manager.provider, EFL_UI_FOCUS_OBJECT_EVENT_FOCUS_MANAGER_CHANGED, _manager_changed_cb, obj);
346 else
340 efl_event_callback_add(pd->manager.provider, EFL_UI_FOCUS_OBJECT_EVENT_FOCUS_MANAGER_CHANGED, _manager_changed_cb, obj); 347 efl_event_callback_add(pd->manager.provider, EFL_UI_FOCUS_OBJECT_EVENT_FOCUS_MANAGER_CHANGED, _manager_changed_cb, obj);
341 } 348 }
342 349
@@ -457,7 +464,7 @@ _focus_state_eval(Eo *obj, Elm_Widget_Smart_Data *pd, Eina_Bool should, Eina_Boo
457} 464}
458 465
459static Efl_Ui_Focus_Object* 466static Efl_Ui_Focus_Object*
460_logical_parent_eval(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *pd, Eina_Bool should) 467_logical_parent_eval(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *pd, Eina_Bool should, Eina_Bool *state_change_to_parent)
461{ 468{
462 Efl_Ui_Widget *parent; 469 Efl_Ui_Widget *parent;
463 Efl_Ui_Focus_Parent_Provider *provider; 470 Efl_Ui_Focus_Parent_Provider *provider;
@@ -494,6 +501,10 @@ _logical_parent_eval(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *pd, Eina_Bool s
494 { 501 {
495 ELM_WIDGET_DATA_GET_OR_RETURN(parent, parent_wd, NULL); 502 ELM_WIDGET_DATA_GET_OR_RETURN(parent, parent_wd, NULL);
496 parent_wd->logical.child_count ++; 503 parent_wd->logical.child_count ++;
504 if (parent_wd->logical.child_count == 1)
505 {
506 *state_change_to_parent = EINA_TRUE;
507 }
497 } 508 }
498 pd->logical.parent = parent; 509 pd->logical.parent = parent;
499 efl_weak_ref(&pd->logical.parent); 510 efl_weak_ref(&pd->logical.parent);
@@ -508,12 +519,11 @@ _full_eval(Eo *obj, Elm_Widget_Smart_Data *pd)
508{ 519{
509 Efl_Ui_Focus_Object *old_parent; 520 Efl_Ui_Focus_Object *old_parent;
510 Efl_Ui_Focus_Object *old_registered_parent, *old_registered_manager; 521 Efl_Ui_Focus_Object *old_registered_parent, *old_registered_manager;
511 Eina_Bool should, want_full; 522 Eina_Bool should, want_full, state_change_to_parent = EINA_FALSE;
512
513 523
514 _eval_registration_candidate(obj, pd, &should, &want_full); 524 _eval_registration_candidate(obj, pd, &should, &want_full);
515 525
516 old_parent = _logical_parent_eval(obj, pd, should); 526 old_parent = _logical_parent_eval(obj, pd, should, &state_change_to_parent);
517 527
518 if (efl_isa(old_parent, EFL_UI_WIDGET_CLASS)) 528 if (efl_isa(old_parent, EFL_UI_WIDGET_CLASS))
519 { 529 {
@@ -522,13 +532,13 @@ _full_eval(Eo *obj, Elm_Widget_Smart_Data *pd)
522 _full_eval(old_parent, old_pd); 532 _full_eval(old_parent, old_pd);
523 } 533 }
524 534
525 if (efl_isa(pd->logical.parent, EFL_UI_WIDGET_CLASS)) 535 if (state_change_to_parent && efl_isa(pd->logical.parent, EFL_UI_WIDGET_CLASS))
526 { 536 {
527 ELM_WIDGET_DATA_GET(pd->logical.parent, new_pd); 537 ELM_WIDGET_DATA_GET(pd->logical.parent, new_pd);
528 _full_eval(pd->logical.parent, new_pd); 538 _full_eval(pd->logical.parent, new_pd);
529 } 539 }
530 540
531 _focus_manager_eval(obj, pd); 541 _focus_manager_eval(obj, pd, want_full, should);
532 542
533 old_registered_parent = pd->focus.parent; 543 old_registered_parent = pd->focus.parent;
534 old_registered_manager = pd->focus.manager; 544 old_registered_manager = pd->focus.manager;