mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 23:27:09 +02:00
Fix layer height updating in poll results.
This commit is contained in:
parent
4062912a98
commit
823fc25fa8
2 changed files with 34 additions and 14 deletions
|
@ -82,7 +82,11 @@ void LayerWidget::setupHeightConsumers() {
|
|||
|
||||
_content->scrollTillBottomChanges(
|
||||
) | rpl::filter([this] {
|
||||
return !_inResize;
|
||||
if (!_inResize) {
|
||||
return true;
|
||||
}
|
||||
_pendingResize = true;
|
||||
return false;
|
||||
}) | rpl::start_with_next([this] {
|
||||
resizeToWidth(width());
|
||||
}, lifetime());
|
||||
|
@ -125,8 +129,11 @@ void LayerWidget::setContentHeight(int height) {
|
|||
if (_contentHeight == height) {
|
||||
return;
|
||||
}
|
||||
|
||||
_contentHeight = height;
|
||||
if (_content && !_inResize) {
|
||||
if (_inResize) {
|
||||
_pendingResize = true;
|
||||
} else if (_content) {
|
||||
resizeToWidth(width());
|
||||
}
|
||||
}
|
||||
|
@ -240,9 +247,29 @@ int LayerWidget::resizeGetHeight(int newWidth) {
|
|||
if (!parentWidget() || !_content) {
|
||||
return 0;
|
||||
}
|
||||
_inResize = true;
|
||||
auto guard = gsl::finally([&] { _inResize = false; });
|
||||
constexpr auto kMaxAttempts = 5;
|
||||
auto attempts = 0;
|
||||
while (true) {
|
||||
_inResize = true;
|
||||
const auto newGeometry = countGeometry(newWidth);
|
||||
_inResize = false;
|
||||
if (!_pendingResize) {
|
||||
const auto oldGeometry = geometry();
|
||||
if (newGeometry != oldGeometry) {
|
||||
_content->forceContentRepaint();
|
||||
}
|
||||
if (newGeometry.topLeft() != oldGeometry.topLeft()) {
|
||||
move(newGeometry.topLeft());
|
||||
}
|
||||
floatPlayerUpdatePositions();
|
||||
return newGeometry.height();
|
||||
}
|
||||
_pendingResize = false;
|
||||
Assert(attempts++ < kMaxAttempts);
|
||||
}
|
||||
}
|
||||
|
||||
QRect LayerWidget::countGeometry(int newWidth) {
|
||||
auto parentSize = parentWidget()->size();
|
||||
auto windowWidth = parentSize.width();
|
||||
auto windowHeight = parentSize.height();
|
||||
|
@ -282,16 +309,7 @@ int LayerWidget::resizeGetHeight(int newWidth) {
|
|||
contentHeight,
|
||||
}, expanding, additionalScroll);
|
||||
|
||||
auto newGeometry = QRect(newLeft, newTop, newWidth, desiredHeight);
|
||||
if (newGeometry != geometry()) {
|
||||
_content->forceContentRepaint();
|
||||
}
|
||||
if (newGeometry.topLeft() != geometry().topLeft()) {
|
||||
move(newGeometry.topLeft());
|
||||
}
|
||||
|
||||
floatPlayerUpdatePositions();
|
||||
return desiredHeight;
|
||||
return QRect(newLeft, newTop, newWidth, desiredHeight);
|
||||
}
|
||||
|
||||
void LayerWidget::doSetInnerFocus() {
|
||||
|
|
|
@ -69,6 +69,7 @@ private:
|
|||
|
||||
void setupHeightConsumers();
|
||||
void setContentHeight(int height);
|
||||
[[nodiscard]] QRect countGeometry(int newWidth);
|
||||
|
||||
not_null<Window::SessionController*> _controller;
|
||||
object_ptr<WrapWidget> _content;
|
||||
|
@ -80,6 +81,7 @@ private:
|
|||
Ui::Animations::Simple _savedHeightAnimation;
|
||||
bool _heightAnimated = false;
|
||||
bool _inResize = false;
|
||||
bool _pendingResize = false;
|
||||
bool _tillBottom = false;
|
||||
|
||||
bool _floatPlayerDelegateRestored = false;
|
||||
|
|
Loading…
Add table
Reference in a new issue