diff options
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 { |
