diff --git a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp index 59a94d585..df5d902c2 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp @@ -55,7 +55,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_send_action.h" #include "chat_helpers/emoji_interactions.h" #include "base/unixtime.h" -#include "base/event_filter.h" #include "support/support_helper.h" #include "apiwrap.h" #include "api/api_chat_participants.h" @@ -233,16 +232,6 @@ TopBarWidget::TopBarWidget( updateConnectingState(); }, lifetime()); - base::install_event_filter( - this, - window()->windowHandle(), - [=](not_null e) { - if (e->type() == QEvent::Expose) { - updateConnectingState(); - } - return base::EventFilterResult::Continue; - }); - setCursor(style::cur_pointer); } @@ -254,7 +243,8 @@ Main::Session &TopBarWidget::session() const { void TopBarWidget::updateConnectingState() { const auto state = _controller->session().mtp().dcstate(); - const auto exposed = window()->windowHandle()->isExposed(); + const auto exposed = window()->windowHandle() + && window()->windowHandle()->isExposed(); if (state == MTP::ConnectedState || !exposed) { if (_connecting) { _connecting = nullptr; @@ -271,6 +261,7 @@ void TopBarWidget::updateConnectingState() { void TopBarWidget::connectingAnimationCallback() { if (!anim::Disabled()) { + updateConnectingState(); update(); } } @@ -436,6 +427,7 @@ void TopBarWidget::paintEvent(QPaintEvent *e) { if (_animatingMode) { return; } + updateConnectingState(); Painter p(this); const auto selectedButtonsTop = countSelectedButtonsTop( diff --git a/Telegram/SourceFiles/window/window_connecting_widget.cpp b/Telegram/SourceFiles/window/window_connecting_widget.cpp index a7b1f3a1f..9940287fa 100644 --- a/Telegram/SourceFiles/window/window_connecting_widget.cpp +++ b/Telegram/SourceFiles/window/window_connecting_widget.cpp @@ -7,7 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "window/window_connecting_widget.h" -#include "base/event_filter.h" #include "ui/widgets/buttons.h" #include "ui/effects/radial_animation.h" #include "ui/painter.h" @@ -37,6 +36,8 @@ class Progress : public Ui::RpWidget { public: Progress(QWidget *parent); + rpl::producer<> animationStepRequests() const; + protected: void paintEvent(QPaintEvent *e) override; @@ -44,6 +45,7 @@ private: void animationStep(); Ui::InfiniteRadialAnimation _animation; + rpl::event_stream<> _animationStepRequests; }; @@ -71,10 +73,15 @@ void Progress::paintEvent(QPaintEvent *e) { void Progress::animationStep() { if (!anim::Disabled()) { + _animationStepRequests.fire({}); update(); } } +rpl::producer<> Progress::animationStepRequests() const { + return _animationStepRequests.events(); +} + } // namespace class ConnectionState::Widget : public Ui::AbstractButton { @@ -109,7 +116,7 @@ private: const not_null _account; Layout _currentLayout; base::unique_qptr _retry; - QPointer _progress; + QPointer _progress; QPointer _proxyIcon; rpl::event_stream<> _refreshStateRequests; @@ -210,14 +217,6 @@ ConnectionState::ConnectionState( rpl::producer shown) : _account(account) , _parent(parent) -, _exposeFilter(base::install_event_filter( - parent->window()->windowHandle(), - [=](not_null e) { - if (e->type() == QEvent::Expose) { - refreshState(); - } - return base::EventFilterResult::Continue; - })) , _refreshTimer([=] { refreshState(); }) , _currentLayout(computeLayout(_state)) { rpl::combine( @@ -241,7 +240,9 @@ ConnectionState::ConnectionState( }, _lifetime); } - Core::App().settings().proxy().connectionTypeValue( + rpl::combine( + Core::App().settings().proxy().connectionTypeValue(), + rpl::single(QRect()) | rpl::then(_parent->paintRequest()) ) | rpl::start_with_next([=] { refreshState(); }, _lifetime); @@ -301,7 +302,8 @@ void ConnectionState::setBottomSkip(int skip) { void ConnectionState::refreshState() { using Checker = Core::UpdateChecker; const auto state = [&]() -> State { - const auto exposed = _parent->window()->windowHandle()->isExposed(); + const auto exposed = _parent->window()->windowHandle() + && _parent->window()->windowHandle()->isExposed(); const auto under = _widget && _widget->isOver(); const auto ready = (Checker().state() == Checker::State::Ready); const auto state = _account->mtp().dcstate(); @@ -501,6 +503,11 @@ ConnectionState::Widget::Widget( addClickHandler([=] { Ui::show(ProxiesBoxController::CreateOwningBox(account)); }); + + _progress->animationStepRequests( + ) | rpl::start_with_next([=] { + _refreshStateRequests.fire({}); + }, _progress->lifetime()); } void ConnectionState::Widget::onStateChanged( diff --git a/Telegram/SourceFiles/window/window_connecting_widget.h b/Telegram/SourceFiles/window/window_connecting_widget.h index 7813ce5ad..891a91072 100644 --- a/Telegram/SourceFiles/window/window_connecting_widget.h +++ b/Telegram/SourceFiles/window/window_connecting_widget.h @@ -80,7 +80,6 @@ private: const not_null _account; not_null _parent; - base::unique_qptr _exposeFilter; rpl::variable _bottomSkip; base::unique_qptr _widget; bool _forceHidden = false;