This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository efl.
View the commit online.
commit d9c36080921653672d5feb4ee3c07d344877b1d6
Author: Cedric BAIL <[email protected]>
AuthorDate: Mon Oct 26 12:50:55 2026 -0600
elementary: a collection view keeps its last row's item for focus
A collection view keeps the item of its last row at hand for focus
(focus.last), and asks for it when the model is set and whenever the
row count changes. Neither request was ever made. _request_add hands
back the request it is building rather than putting it in the list,
and both callers flushed the list without it, leaking it; the one made
when the count changes also asked for row "count", one past the end.
So focus.last was simply the highest row realized so far.
Both requests now go out, for the real last row. Doing that exposed
what would have gone wrong had they ever worked: the idle pass lets
go of every item far from the screen, the last row's among them, and
the factory hands a released item to the next row it builds -- with
focus.last still pointing at it. The last row's item is now kept out
of sight like a selected row's, and focus.last and focus.previously
are forgotten whenever their item is let go of, so neither can name an
item that shows another row.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
src/lib/elementary/efl_ui_collection_view.c | 31 ++++++--
src/tests/elementary/efl_ui_test_collection_view.c | 83 ++++++++++++++++++++++
2 files changed, 108 insertions(+), 6 deletions(-)
diff --git a/src/lib/elementary/efl_ui_collection_view.c b/src/lib/elementary/efl_ui_collection_view.c
index c4e1fbcb5b..fdab2ac274 100644
--- a/src/lib/elementary/efl_ui_collection_view.c
+++ b/src/lib/elementary/efl_ui_collection_view.c
@@ -269,6 +269,17 @@ _entity_cleanup(Efl_Ui_Collection_View *obj, Efl_Ui_Factory *factory,
entities[0] = item->entity;
if (!entities[0]) return ;
+ /* An item let go of may be handed to another row next. Focus must not
+ come back to it as if it still showed this one. */
+ {
+ MY_DATA_GET(obj, pd);
+
+ if (pd && (pd->focus.last == entities[0]))
+ efl_replace(&pd->focus.last, NULL);
+ if (pd && (pd->focus.previously == entities[0]))
+ efl_replace(&pd->focus.previously, NULL);
+ }
+
efl_event_callback_array_del(entities[0], active_item_cbs(), obj);
efl_replace(&item->entity, NULL);
efl_event_callback_call(obj, EFL_UI_COLLECTION_VIEW_EVENT_ITEM_UNREALIZED, entities[0]);
@@ -1432,11 +1443,13 @@ _row_selected(Efl_Model *model)
}
/* A selected row keeps its item while it is off screen, so that what
- last_selected hands out stays the object the application was given. */
+ last_selected hands out stays the object the application was given. So
+ does the last row, which focus enters the view on from below. */
static Eina_Bool
-_lookup_kept(Efl_Ui_Collection_Item_Lookup *lookup)
+_lookup_kept(Efl_Ui_Collection_View_Data *pd, Efl_Ui_Collection_Item_Lookup *lookup)
{
- return lookup->item.entity && _row_selected(lookup->item.model);
+ if (!lookup->item.entity) return EINA_FALSE;
+ return (lookup->item.entity == pd->focus.last) || _row_selected(lookup->item.model);
}
// An RbTree has the nice property of sorting content. The smaller than the root being in
@@ -1512,7 +1525,7 @@ _idle_cb(void *data, const Efl_Event *event EINA_UNUSED)
eina_array_step_set(&gone, sizeof (Eina_Array), 16);
EINA_ARRAY_ITER_NEXT(&mark, i, lookup, iterator)
{
- if (_lookup_kept(lookup))
+ if (_lookup_kept(pd, lookup))
efl_gfx_entity_visible_set(lookup->item.entity, EINA_FALSE);
else
eina_array_push(&gone, lookup);
@@ -1983,8 +1996,12 @@ _efl_model_count_changed(void *data, const Efl_Event *event EINA_UNUSED)
}
pd->last_count = count;
- // The last item is not the last item anymore
- requests = _request_add(requests, &request, count, EINA_TRUE);
+ // The last item is not the last item anymore: fetch the one that is
+ if (count)
+ {
+ requests = _request_add(requests, &request, count - 1, EINA_TRUE);
+ if (request) requests = eina_list_append(requests, request);
+ }
requests = _batch_request_flush(requests, data, pd);
// We are not triggering efl_ui_position_manager_entity_data_access_set as it is can
@@ -2326,6 +2343,8 @@ _efl_ui_collection_view_model_changed(void *data, const Efl_Event *event)
uint64_t index = efl_model_children_count_get(model) - 1;
requests = _request_add(requests, &request, index, EINA_TRUE);
+ /* _request_add hands back the request it is building, not listed yet. */
+ if (request) requests = eina_list_append(requests, request);
}
// Flush all pending request
diff --git a/src/tests/elementary/efl_ui_test_collection_view.c b/src/tests/elementary/efl_ui_test_collection_view.c
index e90eee0909..63052ddc38 100644
--- a/src/tests/elementary/efl_ui_test_collection_view.c
+++ b/src/tests/elementary/efl_ui_test_collection_view.c
@@ -259,6 +259,88 @@ EFL_START_TEST(test_efl_ui_collection_view_last_selected_is_an_item)
}
EFL_END_TEST
+static void
+_realized_track(void *data, const Efl_Event *ev)
+{
+ Eina_List **realized = data;
+
+ *realized = eina_list_append(*realized, ev->info);
+}
+
+static void
+_unrealized_track(void *data, const Efl_Event *ev)
+{
+ Eina_List **realized = data;
+
+ *realized = eina_list_remove(*realized, ev->info);
+}
+
+/* The item showing row index, among those the view has realized and not let
+ go of. */
+static Eo *
+_realized_row(Eina_List *realized, int index)
+{
+ Eina_List *l;
+ Eo *item;
+
+ EINA_LIST_FOREACH(realized, l, item)
+ {
+ if (_item_row(item) == index) return item;
+ }
+ return NULL;
+}
+
+/* Focus coming into a view from below lands on its last row, so the view
+ keeps an item for that row, out of sight while the top is shown -- and
+ for the new last row once rows are added. */
+EFL_START_TEST(test_efl_ui_collection_view_last_row_kept)
+{
+ Eina_List *realized = NULL;
+ Efl_Ui_Win *win;
+ Efl_Model *model;
+ Efl_Ui_List_View *lv;
+ Efl_Ui_Factory *fl;
+ Eo *last;
+ int i;
+
+ win = win_add(NULL, "win", EFL_UI_WIN_TYPE_BASIC);
+ efl_gfx_entity_size_set(win, EINA_SIZE2D(100, 100));
+
+ model = _make_model(win);
+ fl = efl_add(EFL_UI_LAYOUT_FACTORY_CLASS, win,
+ efl_ui_property_bind(efl_added, "text", "title"),
+ efl_ui_widget_factory_item_class_set(efl_added, EFL_UI_LIST_DEFAULT_ITEM_CLASS));
+ lv = efl_add(EFL_UI_LIST_VIEW_CLASS, win,
+ efl_event_callback_add(efl_added, EFL_UI_COLLECTION_VIEW_EVENT_ITEM_REALIZED,
+ _realized_track, &realized),
+ efl_event_callback_add(efl_added, EFL_UI_COLLECTION_VIEW_EVENT_ITEM_UNREALIZED,
+ _unrealized_track, &realized),
+ efl_ui_collection_view_factory_set(efl_added, fl),
+ efl_ui_view_model_set(efl_added, model));
+ efl_content_set(win, lv);
+ get_me_to_those_events(lv);
+ for (i = 0; i < 50; i++)
+ {
+ ecore_main_loop_iterate();
+ }
+
+ last = _realized_row(realized, NUM_ITEMS - 1);
+ ck_assert_ptr_nonnull(last);
+ ck_assert(!efl_gfx_entity_visible_get(last));
+
+ efl_model_child_add(model);
+ for (i = 0; i < 50; i++)
+ {
+ ecore_main_loop_iterate();
+ }
+ ck_assert_ptr_nonnull(_realized_row(realized, NUM_ITEMS));
+
+ efl_event_callback_del(lv, EFL_UI_COLLECTION_VIEW_EVENT_ITEM_REALIZED, _realized_track, &realized);
+ efl_event_callback_del(lv, EFL_UI_COLLECTION_VIEW_EVENT_ITEM_UNREALIZED, _unrealized_track, &realized);
+ eina_list_free(realized);
+}
+EFL_END_TEST
+
/* The sizes the position manager caches and the sizes it places must agree
while the window resizes the view. */
EFL_START_TEST(test_efl_ui_collection_view_sizes_agree)
@@ -314,5 +396,6 @@ void efl_ui_test_collection_view(TCase *tc)
tcase_add_test(tc, efl_ui_collection_view_manager_twice);
tcase_add_test(tc, test_efl_ui_collection_view_select);
tcase_add_test(tc, test_efl_ui_collection_view_last_selected_is_an_item);
+ tcase_add_test(tc, test_efl_ui_collection_view_last_row_kept);
tcase_add_test(tc, test_efl_ui_collection_view_sizes_agree);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.