From f768e405faabd5c2048bcf4021db2b1c49601f31 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Tue, 18 Jun 2024 13:11:35 +0400 Subject: [PATCH] Use RpWidget::shownValue instead of QWindow::visibleChanged --- Telegram/SourceFiles/history/history_widget.cpp | 9 ++++----- Telegram/SourceFiles/window/main_window.cpp | 12 +++++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index e81fc1bc22..b19c0222ff 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -378,11 +378,10 @@ HistoryWidget::HistoryWidget( _field->setEnabled(shown); }, _field->lifetime()); #endif // Q_OS_MAC - connect( - controller->widget()->windowHandle(), - &QWindow::visibleChanged, - this, - [=] { windowIsVisibleChanged(); }); + controller->widget()->shownValue( + ) | rpl::skip(1) | rpl::start_with_next([=] { + windowIsVisibleChanged(); + }, lifetime()); initTabbedSelector(); diff --git a/Telegram/SourceFiles/window/main_window.cpp b/Telegram/SourceFiles/window/main_window.cpp index a8b6cf861d..77ce6d20f1 100644 --- a/Telegram/SourceFiles/window/main_window.cpp +++ b/Telegram/SourceFiles/window/main_window.cpp @@ -358,6 +358,13 @@ MainWindow::MainWindow(not_null controller) }); }, lifetime()); + shownValue( + ) | rpl::skip(1) | rpl::start_with_next([=](bool visible) { + InvokeQueued(this, [=] { + handleVisibleChanged(visible); + }); + }, lifetime()); + body()->sizeValue( ) | rpl::start_with_next([=](QSize size) { updateControlsGeometry(); @@ -457,11 +464,6 @@ void MainWindow::init() { &QWindow::windowStateChanged, this, [=](Qt::WindowState state) { handleStateChanged(state); }); - connect( - windowHandle(), - &QWindow::visibleChanged, - this, - [=](bool visible) { handleVisibleChanged(visible); }); updatePalette();