diff options
| author | Nathan Ollerenshaw <chrome@stupendous.net> | 2026-03-15 08:06:10 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-15 10:06:10 -0500 |
| commit | df55752241c81fe4faa73aa77b775eb12b3e3fa4 (patch) | |
| tree | 4b4b9b338a5a30e70f3105c8eca54e443d0f128a /src/layout/algorithm/tiled/scrolling/ScrollTapeController.cpp | |
| parent | 9bf8fe7a5278b5f366384d73d87844a165c16b7a (diff) | |
algo/scroll: fix std::clamp assertion crash on resume from suspend (#13737)
Diffstat (limited to 'src/layout/algorithm/tiled/scrolling/ScrollTapeController.cpp')
| -rw-r--r-- | src/layout/algorithm/tiled/scrolling/ScrollTapeController.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/layout/algorithm/tiled/scrolling/ScrollTapeController.cpp b/src/layout/algorithm/tiled/scrolling/ScrollTapeController.cpp index 93a7dac1..6cd7da9c 100644 --- a/src/layout/algorithm/tiled/scrolling/ScrollTapeController.cpp +++ b/src/layout/algorithm/tiled/scrolling/ScrollTapeController.cpp @@ -240,7 +240,17 @@ void CScrollTapeController::fitStrip(size_t stripIndex, const CBox& usableArea, const double stripStart = calculateStripStart(stripIndex, usableArea, fullscreenOnOne); const double stripSize = calculateStripSize(stripIndex, usableArea, fullscreenOnOne); - m_offset = std::clamp(m_offset, stripStart - usablePrimary + stripSize, stripStart); + const double lo = stripStart - usablePrimary + stripSize; + const double hi = stripStart; + + if (lo > hi) { + // strip is wider than viewport (e.g. during monitor reconnection after suspend), + // center the strip instead of hitting the std::clamp assertion + m_offset = stripStart - (usablePrimary - stripSize) / 2.0; + return; + } + + m_offset = std::clamp(m_offset, lo, hi); } bool CScrollTapeController::isStripVisible(size_t stripIndex, const CBox& usableArea, bool fullscreenOnOne, bool full) const { |
