From 380759a89e88f3f3cc0d4038f3dc5bd5c623160f Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Fri, 24 Feb 2017 15:16:45 +0900 Subject: [PATCH] genlist: Fix rare jump in prepend insert If an item is selected, and another item is insert before the selected item, then we try to lock the genlist view (pan) around the selected item (if it's visible). Unfortunately, every 16 inserts cause a jump by one line in the scroller. That's because the scroll math assumes the block position is known, but since it's a new block it wasn't known. This patch fixes this issue by precalculating the block position. Test scenario: elementary_test -to "Genlist Tree, Insert Relative" Select an item, clikck 50 times on "+ before". The view should not jump. This does not fix fileselector's craziness. @fix --- src/lib/elementary/elm_genlist.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/lib/elementary/elm_genlist.c b/src/lib/elementary/elm_genlist.c index 7a49e47..44252ba 100644 --- a/src/lib/elementary/elm_genlist.c +++ b/src/lib/elementary/elm_genlist.c @@ -4361,6 +4361,8 @@ _item_block_add(Elm_Genlist_Data *sd, newblock: if (it->item->rel) { + // FIXME: Why is this case here??? This doesn't make sense at all! + // There shouldn't be a goto in the first place! itb = calloc(1, sizeof(Item_Block)); if (!itb) return EINA_FALSE; itb->sd = sd; @@ -4536,6 +4538,12 @@ newblock: itbp->items = eina_list_append(itbp->items, it2); it2->item->block = itbp; itbp->count++; + if (!it2->hide) + { + itb->vis_count--; + itbp->num--; + itbp->vis_count++; + } if (it2->realized) itbp->realized = EINA_TRUE; } @@ -4563,6 +4571,13 @@ newblock: itbn->items = eina_list_prepend(itbn->items, it2); it2->item->block = itbn; itbn->count++; + if (!it2->hide) + { + itb->h -= it->item->h; + itb->vis_count--; + itbn->h += it->item->h; + itbn->vis_count++; + } if (it2->realized) itbn->realized = EINA_TRUE; } @@ -4593,9 +4608,21 @@ newblock: itb2->items = eina_list_prepend(itb2->items, it2); it2->item->block = itb2; itb2->count++; + if (!it2->hide) + { + itb->vis_count--; + itb->h -= it2->item->h; + itb2->vis_count++; + itb2->h += it2->item->h; + } if (it2->realized) itb2->realized = EINA_TRUE; } + + itb2->num = itb->num + itb->vis_count; + itb2->x = itb->x; + itb2->w = itb->w; + itb2->y = itb->y + itb->h; } } -- 2.7.4