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.
This commit is contained in:
John Preston 2023-08-18 18:03:35 +02:00
parent b3580f7987
commit a6d7e3f545

View file

@ -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() {