diff --git a/Telegram/SourceFiles/mainwindow.cpp b/Telegram/SourceFiles/mainwindow.cpp index a3f9343c8..65daf78ed 100644 --- a/Telegram/SourceFiles/mainwindow.cpp +++ b/Telegram/SourceFiles/mainwindow.cpp @@ -115,16 +115,7 @@ MainWindow::MainWindow(not_null controller) void MainWindow::initHook() { Platform::MainWindow::initHook(); - QCoreApplication::instance()->installEventFilter(this); - - // Non-queued activeChanged handlers must use QtSignalProducer. - connect( - windowHandle(), - &QWindow::activeChanged, - this, - [=] { checkActivation(); }, - Qt::QueuedConnection); } void MainWindow::applyInitialWorkMode() { diff --git a/Telegram/SourceFiles/mainwindow.h b/Telegram/SourceFiles/mainwindow.h index 4ddefd57f..37e501269 100644 --- a/Telegram/SourceFiles/mainwindow.h +++ b/Telegram/SourceFiles/mainwindow.h @@ -60,7 +60,7 @@ public: MainWidget *sessionContent() const; - void checkActivation(); + void checkActivation() override; [[nodiscard]] bool markingAsRead() const; bool takeThirdSectionFromLayer(); diff --git a/Telegram/SourceFiles/window/main_window.cpp b/Telegram/SourceFiles/window/main_window.cpp index f3c36a468..b7169874b 100644 --- a/Telegram/SourceFiles/window/main_window.cpp +++ b/Telegram/SourceFiles/window/main_window.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "window/main_window.h" +#include "api/api_updates.h" #include "storage/localstorage.h" #include "platform/platform_specific.h" #include "ui/platform/ui_platform_window.h" @@ -512,9 +513,13 @@ void MainWindow::handleStateChanged(Qt::WindowState state) { } void MainWindow::handleActiveChanged() { + checkActivation(); if (isActiveWindow()) { Core::App().windowActivated(&controller()); } + if (const auto controller = sessionController()) { + controller->session().updates().updateOnline(); + } } void MainWindow::handleVisibleChanged(bool visible) { diff --git a/Telegram/SourceFiles/window/main_window.h b/Telegram/SourceFiles/window/main_window.h index a6c1ac275..4c7fe7b04 100644 --- a/Telegram/SourceFiles/window/main_window.h +++ b/Telegram/SourceFiles/window/main_window.h @@ -148,6 +148,8 @@ protected: void handleActiveChanged(); void handleVisibleChanged(bool visible); + virtual void checkActivation() { + } virtual void initHook() { }