From a6d7e3f5457b29b563941b24cd844ca26ac0d077 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 18 Aug 2023 18:03:35 +0200 Subject: [PATCH] Fix possible render glitch. In some rare cases opening main menu was leading to some widgets showing "over" the background darkening filling. The glitch disappeared on the next repaint, so we trigger this repaint explicitly. The case it was reproducing with 100% rate: in TDesktop with disabled interface animations after showing and hiding of bot keyboard the message input field (widget with OpaquePaintEvent) was painted on top of the backround dark filling below main menu. --- ui/layers/layer_widget.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ui/layers/layer_widget.cpp b/ui/layers/layer_widget.cpp index 2dbab88..b91c2f5 100644 --- a/ui/layers/layer_widget.cpp +++ b/ui/layers/layer_widget.cpp @@ -72,6 +72,7 @@ private: bool _wasAnimating = false; bool _inPaintEvent = false; + bool _repaintIssued = false; Ui::Animations::Simple _a_shown; Ui::Animations::Simple _a_mainMenuShown; Ui::Animations::Simple _a_specialLayerShown; @@ -98,6 +99,7 @@ void LayerStackWidget::BackgroundWidget::setCacheImages( _layerCache = std::move(layerCache); _specialLayerCacheBox = _specialLayerBox; _layerCacheBox = _layerBox; + _repaintIssued = false; setAttribute(Qt::WA_OpaquePaintEvent, !_bodyCache.isNull()); } @@ -143,6 +145,7 @@ void LayerStackWidget::BackgroundWidget::startAnimation(Action action) { } void LayerStackWidget::BackgroundWidget::skipAnimation(Action action) { + _repaintIssued = false; startAnimation(action); finishAnimating(); } @@ -310,6 +313,10 @@ void LayerStackWidget::BackgroundWidget::paintEvent(QPaintEvent *e) { auto sourceRect = style::rtlrect(_mainMenuCache.width() - sourceWidth, 0, sourceWidth, _mainMenuCache.height(), _mainMenuCache.width()); p.drawPixmapLeft(0, 0, shownWidth, height(), width(), _mainMenuCache, sourceRect); } + if (!_repaintIssued && !_a_shown.animating()) { + _repaintIssued = true; + update(); + } } void LayerStackWidget::BackgroundWidget::finishAnimating() {