From 427fc4c8f7c8b92cca900e0270718f83fcb16e35 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 11 Jul 2023 19:18:20 +0400 Subject: [PATCH] Fix painting glitch in elastic scroll. --- ui/widgets/elastic_scroll.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ui/widgets/elastic_scroll.cpp b/ui/widgets/elastic_scroll.cpp index 255ce12..532fabb 100644 --- a/ui/widgets/elastic_scroll.cpp +++ b/ui/widgets/elastic_scroll.cpp @@ -895,10 +895,25 @@ void ElasticScroll::applyScrollTo(int position, bool synthMouseMove) { } const auto weak = Ui::MakeWeak(this); _dirtyState = true; + const auto was = _widget->geometry(); _widget->move( _vertical ? _widget->x() : -position, _vertical ? -position : _widget->y()); if (weak) { + const auto now = _widget->geometry(); + const auto wasFrom = _vertical ? was.y() : was.x(); + const auto wasTill = wasFrom + + (_vertical ? was.height() : was.width()); + const auto nowFrom = _vertical ? now.y() : now.x(); + const auto nowTill = nowFrom + + (_vertical ? now.height() : now.width()); + const auto mySize = _vertical ? height() : width(); + if ((wasFrom > 0 && wasFrom < mySize) + || (wasTill > 0 && wasTill < mySize) + || (nowFrom > 0 && nowFrom < mySize) + || (nowTill > 0 && nowTill < mySize)) { + update(); + } if (_dirtyState) { updateState(); }