if (node->type == NODE_TYPE_ONLY_LOGICAL && !node->redirect_manager && pd->root != node)
{
- ERR(" %p is logical, cannot be focused", obj);
- return;
+ Node *target = NULL;
+
+ F_DBG(" %p is logical, fetching the next subnode that is either a redirect or a regular", obj);
+
+ //important! if there are no children _next would return the parent of node which will exceed the limit of children of node
+ if (node->tree.children)
+ {
+ target = node;
+
+ //try to find a child that is not logical or has a redirect manager
+ while (target && target->type == NODE_TYPE_ONLY_LOGICAL && !target->redirect_manager)
+ {
+ target = _next(target);
+
+ //abort if we are exceeding the childrens of node
+ if (target == node) target = NULL;
+ }
+
+ F_DBG("Found node %p", target);
+ }
+
+ //check if we have found anything
+ if (target)
+ {
+ node = target;
+ }
+ else
+ {
+ ERR("Could not fetch a node located at %p", node->focusable);
+ return;
+ }
}
if (pd->redirect)
elm_shutdown();
}
END_TEST
+
+START_TEST(logical_shift)
+{
+ Efl_Ui_Focus_Manager *m;
+
+ elm_init(1, NULL);
+
+ TEST_OBJ_NEW(root, 0, 0, 10, 10);
+ TEST_OBJ_NEW(child, 0, 0, 10, 10);
+ TEST_OBJ_NEW(sub, 0, 0, 10, 10);
+ TEST_OBJ_NEW(sub_sub, 0, 0, 10, 10);
+ TEST_OBJ_NEW(sub_child, 0, 0, 10, 10);
+
+ m = efl_add(EFL_UI_FOCUS_MANAGER_CALC_CLASS, NULL,
+ efl_ui_focus_manager_root_set(efl_added, root)
+ );
+
+ efl_ui_focus_manager_calc_register(m, child, root, NULL);
+ efl_ui_focus_manager_calc_register_logical(m, sub, root, NULL);
+ efl_ui_focus_manager_calc_register_logical(m, sub_sub, sub, NULL);
+ efl_ui_focus_manager_calc_register(m, sub_child, sub, NULL);
+
+ efl_ui_focus_manager_focus_set(m, root);
+ ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), child);
+
+ efl_ui_focus_manager_focus_set(m, sub);
+ ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), sub_child);
+
+ efl_ui_focus_manager_focus_set(m, sub_sub);
+ ck_assert_ptr_eq(efl_ui_focus_manager_focus_get(m), sub_child);
+
+ elm_shutdown();
+}
+END_TEST
+
void elm_test_focus(TCase *tc)
{
tcase_add_test(tc, focus_register_twice);
tcase_add_test(tc, redirect_param);
tcase_add_test(tc, invalid_args_check);
tcase_add_test(tc, order_check);
+ tcase_add_test(tc, logical_shift);
}