diff --git a/plugin/src/Caelestia/Components/lazylistview.cpp b/plugin/src/Caelestia/Components/lazylistview.cpp index 88703a7f..b8c37976 100644 --- a/plugin/src/Caelestia/Components/lazylistview.cpp +++ b/plugin/src/Caelestia/Components/lazylistview.cpp @@ -422,13 +422,15 @@ void LazyListView::relayout() { qreal y = 0; bool hasLayoutItem = false; for (auto& record : m_layout) { - record.targetY = y; const qreal layoutH = record.heightKnown ? record.height : effectiveEstimatedHeight(); if (layoutH > 0) { if (hasLayoutItem) y += m_spacing; hasLayoutItem = true; + record.targetY = y; y += layoutH; + } else { + record.targetY = y; } } @@ -653,10 +655,16 @@ LazyListView::DelegateEntry LazyListView::createDelegate(int modelIndex) { if (wasKnown) untrackHeight(oldH); trackHeight(h); - // Relayout immediately so layoutHeight/contentHeight update - // synchronously for parent bindings, then polish for delegate sync. - relayout(); - polish(); + // Batch relayout: multiple height changes in the same event loop + // iteration are coalesced into a single relayout + polish. + if (!m_relayoutPending) { + m_relayoutPending = true; + QTimer::singleShot(0, this, [this] { + m_relayoutPending = false; + relayout(); + polish(); + }); + } } return; } diff --git a/plugin/src/Caelestia/Components/lazylistview.hpp b/plugin/src/Caelestia/Components/lazylistview.hpp index f3f92208..7147169c 100644 --- a/plugin/src/Caelestia/Components/lazylistview.hpp +++ b/plugin/src/Caelestia/Components/lazylistview.hpp @@ -281,6 +281,7 @@ private: int m_activeAnimations = 0; bool m_componentComplete = false; + bool m_relayoutPending = false; QSet m_pendingAddAnimations; QList m_modelConnections;