From df55752241c81fe4faa73aa77b775eb12b3e3fa4 Mon Sep 17 00:00:00 2001 From: Nathan Ollerenshaw Date: Sun, 15 Mar 2026 08:06:10 -0700 Subject: algo/scroll: fix std::clamp assertion crash on resume from suspend (#13737) --- src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp') diff --git a/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp b/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp index a64edb3a..5de27b97 100644 --- a/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp +++ b/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp @@ -795,6 +795,11 @@ void CScrollingAlgorithm::resizeTarget(const Vector2D& delta, SP target } void CScrollingAlgorithm::recalculate() { + // guard against recalculation during transitional monitor states + // (e.g. monitor reconnecting after suspend where workspace/monitor may not be ready) + if (!m_parent || !m_parent->space() || !m_parent->space()->workspace() || !m_parent->space()->workspace()->m_monitor) + return; + if (Desktop::focusState()->window()) { const auto TARGET = Desktop::focusState()->window()->layoutTarget(); @@ -1516,6 +1521,12 @@ CBox CScrollingAlgorithm::usableArea() { return box; box.translate(-m_parent->space()->workspace()->m_monitor->m_position); + + // ensure dimensions are never zero or negative, which can happen during + // monitor transitions (e.g. reconnection after suspend with stale reserved areas) + box.w = std::max(box.w, 1.0); + box.h = std::max(box.h, 1.0); + return box; } -- cgit v1.2.3