From b0aeee8b8077b596da06b06ccdfe83f02786d39d Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Fri, 10 Apr 2026 01:10:05 +1000 Subject: [PATCH] fix: allow viewport to be outside of bounds --- plugin/src/Caelestia/Components/lazylistview.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/plugin/src/Caelestia/Components/lazylistview.cpp b/plugin/src/Caelestia/Components/lazylistview.cpp index 27a8a92d..14545578 100644 --- a/plugin/src/Caelestia/Components/lazylistview.cpp +++ b/plugin/src/Caelestia/Components/lazylistview.cpp @@ -453,7 +453,9 @@ QRectF LazyListView::effectiveViewport() const { // During Flickable overshoot the viewport can extend entirely beyond content bounds, // causing all delegates to be culled. Clamp so it always overlaps [0, layoutHeight]. - if (m_layoutHeight > 0) { + // Only needed for the built-in viewport — custom viewports represent the actual + // visible area and may legitimately lie entirely outside the content. + if (!m_useCustomViewport && m_layoutHeight > 0) { const qreal top = std::min(vp.y(), m_layoutHeight); const qreal bottom = std::max(vp.y() + vp.height(), 0.0); if (bottom > top) @@ -470,6 +472,8 @@ QRectF LazyListView::effectiveViewport() const { const qreal bottom = std::min(vp.y() + vp.height(), m_layoutHeight); if (top < bottom) vp = QRectF(vp.x(), top, vp.width(), bottom - top); + else + return {}; } return vp; @@ -480,6 +484,9 @@ std::pair LazyListView::computeVisibleRange() const { return { -1, -1 }; const auto vp = effectiveViewport(); + if (vp.isEmpty()) + return { -1, -1 }; + const qreal vpTop = vp.y(); const qreal vpBottom = vp.y() + vp.height(); @@ -533,7 +540,7 @@ void LazyListView::syncDelegates() { for (auto it = m_delegates.begin(); it != m_delegates.end(); ++it) { if (visibleIndices.contains(it.key())) continue; - if (!it->item) { + if (!it->item || vp.isEmpty()) { toRemove.append(it.key()); continue; }