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 52094ae1b348b5017b92297b1628b8a9c332428b
Author: Cedric BAIL <[email protected]>
AuthorDate: Sun Nov 15 20:37:14 2026 -0600
elementary: position_manager_grid: max min size drops with its item
An item removed without building the groups again left the biggest
minimum size as it was (a comment said it was ignored), so the grid kept
cells of a size nothing had any more, until some full build. The size is
now asked for again, once, in the job that follows the removals, for
those that did not make a full build anyway.
The way a plain item that ends a group is left out of the next line
(which the full build has always done) is not changed, and is said where
it is.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
src/lib/elementary/efl_ui_position_manager_grid.c | 57 +++++++++++++++-
src/tests/elementary/efl_ui_test_collection_view.c | 75 ++++++++++++++++++++++
2 files changed, 130 insertions(+), 2 deletions(-)
diff --git a/src/lib/elementary/efl_ui_position_manager_grid.c b/src/lib/elementary/efl_ui_position_manager_grid.c
index 64ecfbcfb7..94dc67900d 100644
--- a/src/lib/elementary/efl_ui_position_manager_grid.c
+++ b/src/lib/elementary/efl_ui_position_manager_grid.c
@@ -40,6 +40,8 @@ typedef struct {
Eina_Bool group_cache_dirty;
Eina_Bool size_cache_dirty;
+ // An item that may have been the biggest went, and the groups were not built again
+ Eina_Bool min_size_dirty : 1;
} Efl_Ui_Position_Manager_Grid_Data;
typedef struct {
@@ -68,6 +70,7 @@ _group_cache_require(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_Grid_Data *pd)
return;
pd->max_min_size = EINA_SIZE2D(0, 0);
+ pd->min_size_dirty = EINA_FALSE;
pd->group_cache_dirty = EINA_FALSE;
if (pd->group_cache)
@@ -97,6 +100,9 @@ _group_cache_require(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_Grid_Data *pd)
}
else if (size_buffer[buffer_id].element_depth == 0 && line.real_group)
{
+ // (a known quirk, left as it is: the plain item that ends a group
+ // is not counted in the line that is started here, which has 0
+ // items until the next plain item)
eina_inarray_push(pd->group_cache, &line);
line.real_group = EINA_FALSE;
line.group_header_size = EINA_SIZE2D(0, 0);
@@ -175,6 +181,39 @@ _group_cache_remove(Efl_Ui_Position_Manager_Grid_Data *pd, unsigned int idx)
return EINA_FALSE;
}
+// The biggest minimum size of the items, asked for again: an item that goes may
+// have been the one that gave it, and the sizes are not kept to tell.
+static void
+_min_size_recompute(Efl_Ui_Position_Manager_Grid_Data *pd)
+{
+ Efl_Ui_Position_Manager_Size_Batch_Entity size_buffer[100];
+ Efl_Ui_Position_Manager_Size_Batch_Result size_result;
+ Eina_Size2D max = EINA_SIZE2D(0, 0);
+ unsigned int i = 0;
+
+ while (i < pd->size)
+ {
+ unsigned int j, filled;
+
+ size_result = _batch_request_size(pd->callbacks, i, pd->size, MIN(100, pd->size - i),
+ EINA_TRUE, size_buffer);
+ filled = MIN(size_result.filled_items, 100);
+ // (what is not told is not known: the biggest is then the one that was)
+ if (!filled) return;
+ for (j = 0; j < filled; j++)
+ {
+ max.w = MAX(max.w, size_buffer[j].size.w);
+ max.h = MAX(max.h, size_buffer[j].size.h);
+ }
+ i += filled;
+ }
+ if ((max.w != pd->max_min_size.w) || (max.h != pd->max_min_size.h))
+ {
+ pd->max_min_size = max;
+ pd->size_cache_dirty = EINA_TRUE;
+ }
+}
+
static void
_size_cache_require(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_Grid_Data *pd)
{
@@ -640,6 +679,16 @@ _rebuild_job_cb(Eo *obj, void *data, const Eina_Value v)
{
Efl_Ui_Position_Manager_Grid_Data *pd = data;
+ if (pd->min_size_dirty)
+ {
+ pd->min_size_dirty = EINA_FALSE;
+ // (a full build of the groups finds it by itself)
+ if (!pd->group_cache_dirty)
+ {
+ _min_size_recompute(pd);
+ _flush_min_size(obj, pd);
+ }
+ }
_flush_abs_size(obj, pd);
_reposition_content(obj, pd);
@@ -692,12 +741,16 @@ _efl_ui_position_manager_grid_efl_ui_position_manager_entity_item_removed(Eo *ob
{
Eina_Bool clean = !pd->group_cache_dirty;
- //we ignore here that we might loose the item giving the current max min size
EINA_SAFETY_ON_FALSE_RETURN(pd->size > 0);
pd->size --;
_group_cache_invalidate(obj, pd);
if (clean && _group_cache_remove(pd, removed_index))
- pd->group_cache_dirty = EINA_FALSE;
+ {
+ pd->group_cache_dirty = EINA_FALSE;
+ // The item may have been the one that gave the biggest minimum size,
+ // which is looked for again with the others that went in the meantime.
+ pd->min_size_dirty = EINA_TRUE;
+ }
pd->prev_run.start_id = MIN(pd->prev_run.start_id, pd->size);
pd->prev_run.end_id = MIN(pd->prev_run.end_id, pd->size);
_schedule_recalc_abs_size(obj, pd);
diff --git a/src/tests/elementary/efl_ui_test_collection_view.c b/src/tests/elementary/efl_ui_test_collection_view.c
index c31fa0fb1f..a191a4cbda 100644
--- a/src/tests/elementary/efl_ui_test_collection_view.c
+++ b/src/tests/elementary/efl_ui_test_collection_view.c
@@ -1816,6 +1816,80 @@ EFL_START_TEST(test_efl_ui_collection_view_exact_model_renumbered)
}
EFL_END_TEST
+/* The grid has the size of its biggest item for all of them, and an item that
+ goes may have been it: what it gives once it is gone is the biggest of those
+ that are left. */
+static Efl_Ui_Position_Manager_Size_Batch_Result
+_gridw_size_cb(void *data EINA_UNUSED, Efl_Ui_Position_Manager_Size_Call_Config conf,
+ Eina_Rw_Slice memory)
+{
+ Efl_Ui_Position_Manager_Size_Batch_Entity *sizes = memory.mem;
+ Efl_Ui_Position_Manager_Size_Batch_Result result = { 0 };
+ unsigned int i, limit = conf.range.end_id - conf.range.start_id;
+
+ for (i = 0; (i < limit) && conf.range.start_id + i < _cache_count; i++)
+ {
+ sizes[i].size = EINA_SIZE2D(_cache_sizes[conf.range.start_id + i], 30);
+ sizes[i].element_depth = 0;
+ sizes[i].depth_leader = EINA_FALSE;
+ }
+ result.filled_items = i;
+ return result;
+}
+
+static int _gridw_min_w = -1;
+
+static void
+_gridw_min_size(void *data EINA_UNUSED, const Efl_Event *ev)
+{
+ Eina_Size2D *size = ev->info;
+
+ _gridw_min_w = size->w;
+}
+
+EFL_START_TEST(test_efl_ui_position_manager_grid_min_size_goes_down)
+{
+ Efl_Ui_Win *win;
+ Efl_Ui_Position_Manager_Entity *manager;
+ static const int widths[] = { 40, 90, 60, 50, 90 };
+ unsigned int i;
+
+ win = win_add(NULL, "win", EFL_UI_WIN_TYPE_BASIC);
+ _cache_dummy = efl_add(EFL_UI_BUTTON_CLASS, win);
+ _cache_count = EINA_C_ARRAY_LENGTH(widths);
+ for (i = 0; i < _cache_count; i++)
+ {
+ _cache_sizes[i] = widths[i];
+ }
+ manager = efl_add(EFL_UI_POSITION_MANAGER_GRID_CLASS, win,
+ efl_ui_layout_orientation_set(efl_added, EFL_UI_LAYOUT_ORIENTATION_VERTICAL));
+ efl_event_callback_add(manager, EFL_UI_POSITION_MANAGER_ENTITY_EVENT_CONTENT_MIN_SIZE_CHANGED,
+ _gridw_min_size, NULL);
+ _gridw_min_w = -1;
+ efl_ui_position_manager_data_access_v1_data_access_set(manager, win, NULL, _cache_object_cb, NULL,
+ NULL, _gridw_size_cb, NULL, _cache_count);
+ efl_ui_position_manager_entity_viewport_set(manager, EINA_RECT(0, 0, 200, 300));
+ ecore_main_loop_iterate();
+ ck_assert_int_eq(efl_ui_position_manager_entity_position_single_item(manager, 0).w, 90);
+
+ // One of the two biggest goes: nothing changes
+ memmove(_cache_sizes + 1, _cache_sizes + 2, 3 * sizeof (int));
+ _cache_count--;
+ efl_ui_position_manager_entity_item_removed(manager, 1, _cache_dummy);
+ ecore_main_loop_iterate();
+ ck_assert_int_eq(efl_ui_position_manager_entity_position_single_item(manager, 0).w, 90);
+
+ // The last of them
+ _cache_count--;
+ efl_ui_position_manager_entity_item_removed(manager, _cache_count, _cache_dummy);
+ ecore_main_loop_iterate();
+ ck_assert_int_eq(efl_ui_position_manager_entity_position_single_item(manager, 0).w, 60);
+ ck_assert_int_eq(_gridw_min_w, 60);
+
+ efl_del(manager);
+}
+EFL_END_TEST
+
void efl_ui_test_collection_view(TCase *tc)
{
tcase_add_test(tc, test_efl_ui_collection_view_basic);
@@ -1845,4 +1919,5 @@ void efl_ui_test_collection_view(TCase *tc)
tcase_add_test(tc, test_efl_ui_collection_view_many_single_adds_idle);
tcase_add_test(tc, test_efl_ui_collection_view_many_single_adds_grid);
tcase_add_test(tc, test_efl_ui_collection_view_exact_model_renumbered);
+ tcase_add_test(tc, test_efl_ui_position_manager_grid_min_size_goes_down);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.