summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2018-12-03 16:28:05 +0100
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2018-12-17 09:12:22 +0100
commit2df601d589ad405ddb54626d991807be65f74e57 (patch)
tree328dcab05115ae285cb9a9812fbacc4bd4cd0f93
parentdfc9cd8a6735b5fa77ca953ad7d7e4ec50ee495a (diff)
elm_focus: implement legacy targets for logical widgets
they are now handled. The list of parents is walked until a possible candidate is found or the parent chain is the same then in the next focused element. fix T7389 Reviewed-by: YeongJong Lee <yj34.lee@samsung.com> Differential Revision: https://phab.enlightenment.org/D7404
-rw-r--r--src/lib/elementary/elm_focus_legacy.c61
1 files changed, 54 insertions, 7 deletions
diff --git a/src/lib/elementary/elm_focus_legacy.c b/src/lib/elementary/elm_focus_legacy.c
index 8075ab2233..fdf6b4e2a5 100644
--- a/src/lib/elementary/elm_focus_legacy.c
+++ b/src/lib/elementary/elm_focus_legacy.c
@@ -173,6 +173,38 @@ elm_object_focus_cycle(Evas_Object *obj,
173 elm_object_focus_next(obj, dir); 173 elm_object_focus_next(obj, dir);
174} 174}
175 175
176static Evas_Object*
177_get_legacy_target(Evas_Object *eo, Elm_Widget_Smart_Data *pd, Elm_Focus_Direction dir)
178{
179 Evas_Object *result = NULL;
180
181 #define MAP(direction, field) if (dir == EFL_UI_FOCUS_DIRECTION_ ##direction && pd->legacy_focus.item_ ##field) result = elm_object_item_widget_get(pd->legacy_focus.item_ ##field);
182 MAPPING()
183 #undef MAP
184
185 if (!result)
186 {
187 #define MAP(direction, field) if (dir == EFL_UI_FOCUS_DIRECTION_ ##direction && pd->legacy_focus.field) result = pd->legacy_focus.field;
188 MAPPING()
189 #undef MAP
190 }
191
192 return result;
193}
194
195static Eina_Array*
196_focus_parent_chain_gen(Efl_Ui_Focus_Object *obj)
197{
198 Eina_Array *result = eina_array_new(5);
199
200 for (Eo *parent = obj; parent; parent = efl_ui_focus_object_focus_parent_get(parent))
201 {
202 eina_array_push(result, parent);
203 }
204
205 return result;
206}
207
176EAPI void 208EAPI void
177elm_object_focus_next(Evas_Object *obj, 209elm_object_focus_next(Evas_Object *obj,
178 Elm_Focus_Direction dir) 210 Elm_Focus_Direction dir)
@@ -194,16 +226,31 @@ elm_object_focus_next(Evas_Object *obj,
194 Efl_Ui_Focus_Object *legacy_target = NULL; 226 Efl_Ui_Focus_Object *legacy_target = NULL;
195 ELM_WIDGET_DATA_GET_OR_RETURN(logical, pd_logical); 227 ELM_WIDGET_DATA_GET_OR_RETURN(logical, pd_logical);
196 228
197 229 legacy_target = _get_legacy_target(obj, pd_logical, dir);
198 #define MAP(direction, field) if (dir == EFL_UI_FOCUS_DIRECTION_ ##direction && pd_logical->legacy_focus.item_ ##field) legacy_target = elm_object_item_widget_get(pd_logical->legacy_focus.item_ ##field);
199 MAPPING()
200 #undef MAP
201 230
202 if (!legacy_target) 231 if (!legacy_target)
203 { 232 {
204 #define MAP(direction, field) if (dir == EFL_UI_FOCUS_DIRECTION_ ##direction && pd_logical->legacy_focus.field) legacy_target = pd_logical->legacy_focus.field; 233 Eina_Array *old_chain = _focus_parent_chain_gen(logical);
205 MAPPING() 234 Eina_Array *new_chain = _focus_parent_chain_gen(efl_ui_focus_manager_request_move(top, dir, NULL, EINA_FALSE));
206 #undef MAP 235
236 //first pop off all elements that are the same
237 while (eina_array_count(new_chain) > 0 && eina_array_count(old_chain) > 0 &&
238 eina_array_data_get(new_chain, (int)eina_array_count(new_chain) -1) == eina_array_data_get(old_chain, (int)eina_array_count(old_chain) - 1))
239 {
240 eina_array_pop(new_chain);
241 eina_array_pop(old_chain);
242 }
243
244 for (unsigned int i = 0; i < eina_array_count(old_chain); ++i)
245 {
246 Evas_Object *parent = eina_array_data_get(old_chain, i);
247 if (!elm_widget_is(parent)) continue;
248 ELM_WIDGET_DATA_GET_OR_RETURN(parent, pd);
249 legacy_target = _get_legacy_target(parent, pd, dir);
250 if (legacy_target) break;
251 }
252 eina_array_free(new_chain);
253 eina_array_free(old_chain);
207 } 254 }
208 255
209 if (legacy_target) 256 if (legacy_target)