summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2020-03-21 19:31:10 +0100
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2020-03-21 19:48:46 +0100
commit2677b9d4808b4f99da1b15d12d3bba04b6908aa2 (patch)
tree8ef31a3f08d33b7b43444460afddc0f3f0954871
parente9493fbafc64c567c65a1e6bd98013889027b8ba (diff)
efl_ui_widget: fix tree_unfocusable setting
when setting twice the same value, unsetting the same value would not restore the same state in the tree again. With this commit, we ensure this is working correctly.
-rw-r--r--src/lib/elementary/efl_ui_widget.c21
-rw-r--r--src/tests/elementary/efl_ui_test_widget.c33
2 files changed, 46 insertions, 8 deletions
diff --git a/src/lib/elementary/efl_ui_widget.c b/src/lib/elementary/efl_ui_widget.c
index a58c66b99c..929e53a2e4 100644
--- a/src/lib/elementary/efl_ui_widget.c
+++ b/src/lib/elementary/efl_ui_widget.c
@@ -1748,7 +1748,9 @@ elm_widget_tree_unfocusable_set(Eo *obj, Eina_Bool tree_unfocusable)
1748 Efl_Ui_Widget *subs; 1748 Efl_Ui_Widget *subs;
1749 Elm_Widget_Smart_Data *pd = efl_data_scope_safe_get(obj, MY_CLASS); 1749 Elm_Widget_Smart_Data *pd = efl_data_scope_safe_get(obj, MY_CLASS);
1750 EINA_SAFETY_ON_NULL_RETURN(pd); 1750 EINA_SAFETY_ON_NULL_RETURN(pd);
1751 int distance, parent_counter = (pd->parent_obj ? _tree_unfocusable_counter_get(pd->parent_obj) : 0); 1751 int old_tree_unfocusable, distance, parent_counter = (pd->parent_obj ? _tree_unfocusable_counter_get(pd->parent_obj) : 0);
1752
1753 old_tree_unfocusable = pd->tree_unfocusable;
1752 1754
1753 if (tree_unfocusable) 1755 if (tree_unfocusable)
1754 pd->tree_unfocusable ++; 1756 pd->tree_unfocusable ++;
@@ -1762,15 +1764,18 @@ elm_widget_tree_unfocusable_set(Eo *obj, Eina_Bool tree_unfocusable)
1762 distance = MAX(MIN(tree_unfocusable, 1), 0); 1764 distance = MAX(MIN(tree_unfocusable, 1), 0);
1763 pd->tree_unfocusable = parent_counter + distance; 1765 pd->tree_unfocusable = parent_counter + distance;
1764 } 1766 }
1765 for (unsigned int i = 0; i < eina_array_count(pd->children); ++i) 1767 if (old_tree_unfocusable != pd->tree_unfocusable)
1766 { 1768 {
1767 subs = eina_array_data_get(pd->children, i); 1769 for (unsigned int i = 0; i < eina_array_count(pd->children); ++i)
1768 if (efl_isa(subs, EFL_UI_WIDGET_CLASS)) 1770 {
1769 elm_widget_tree_unfocusable_set(subs, elm_widget_tree_unfocusable_get(obj)); 1771 subs = eina_array_data_get(pd->children, i);
1770 } 1772 if (efl_isa(subs, EFL_UI_WIDGET_CLASS))
1773 elm_widget_tree_unfocusable_set(subs, elm_widget_tree_unfocusable_get(obj));
1774 }
1771 1775
1772 //focus state eval on all children 1776 //focus state eval on all children
1773 _elm_widget_full_eval_children(obj, pd); 1777 _elm_widget_full_eval_children(obj, pd);
1778 }
1774} 1779}
1775 1780
1776/** 1781/**
diff --git a/src/tests/elementary/efl_ui_test_widget.c b/src/tests/elementary/efl_ui_test_widget.c
index 7e55fd1b79..7b260dd40c 100644
--- a/src/tests/elementary/efl_ui_test_widget.c
+++ b/src/tests/elementary/efl_ui_test_widget.c
@@ -332,6 +332,38 @@ EFL_START_TEST(efl_ui_test_widget_win_provider_find)
332} 332}
333EFL_END_TEST 333EFL_END_TEST
334 334
335#define CHECK_UNFOCUSABLE_STATE(x) \
336 ck_assert_int_eq(elm_widget_tree_unfocusable_get(s.box), x); \
337 ck_assert_int_eq(elm_widget_tree_unfocusable_get(s.win), x); \
338 ck_assert_int_eq(elm_widget_tree_unfocusable_get(s.ic), x); \
339 ck_assert_int_eq(elm_widget_tree_unfocusable_get(s.btn1), x); \
340 ck_assert_int_eq(elm_widget_tree_unfocusable_get(s.btn2), x)
341
342
343EFL_START_TEST(efl_ui_test_widget_tree_unfocusable)
344{
345 State s;
346
347 _small_ui(&s);
348 CHECK_UNFOCUSABLE_STATE(0);
349
350 elm_widget_tree_unfocusable_set(s.win, EINA_TRUE);
351 CHECK_UNFOCUSABLE_STATE(1);
352
353 elm_widget_tree_unfocusable_set(s.win, EINA_FALSE);
354 CHECK_UNFOCUSABLE_STATE(0);
355
356 elm_widget_tree_unfocusable_set(s.win, EINA_TRUE);
357 CHECK_UNFOCUSABLE_STATE(1);
358
359 elm_widget_tree_unfocusable_set(s.win, EINA_TRUE);
360 CHECK_UNFOCUSABLE_STATE(1);
361
362 elm_widget_tree_unfocusable_set(s.win, EINA_FALSE);
363 CHECK_UNFOCUSABLE_STATE(0);
364}
365EFL_END_TEST
366
335void efl_ui_test_widget(TCase *tc) 367void efl_ui_test_widget(TCase *tc)
336{ 368{
337 tcase_add_checked_fixture(tc, fail_on_errors_setup, fail_on_errors_teardown); 369 tcase_add_checked_fixture(tc, fail_on_errors_setup, fail_on_errors_teardown);
@@ -346,4 +378,5 @@ void efl_ui_test_widget(TCase *tc)
346 tcase_add_test(tc, efl_ui_test_widget_disabled_parent); 378 tcase_add_test(tc, efl_ui_test_widget_disabled_parent);
347 tcase_add_test(tc, efl_ui_test_widget_disabled_behaviour); 379 tcase_add_test(tc, efl_ui_test_widget_disabled_behaviour);
348 tcase_add_test(tc, efl_ui_test_widget_win_provider_find); 380 tcase_add_test(tc, efl_ui_test_widget_win_provider_find);
381 tcase_add_test(tc, efl_ui_test_widget_tree_unfocusable);
349} 382}