Update online after the window active status.

I hope this fixes #26059.
This commit is contained in:
John Preston 2023-03-21 16:22:38 +04:00
parent f0a96d0aad
commit 58c5bb7247
4 changed files with 8 additions and 10 deletions

View File

@ -115,16 +115,7 @@ MainWindow::MainWindow(not_null<Window::Controller*> controller)
void MainWindow::initHook() { void MainWindow::initHook() {
Platform::MainWindow::initHook(); Platform::MainWindow::initHook();
QCoreApplication::instance()->installEventFilter(this); QCoreApplication::instance()->installEventFilter(this);
// Non-queued activeChanged handlers must use QtSignalProducer.
connect(
windowHandle(),
&QWindow::activeChanged,
this,
[=] { checkActivation(); },
Qt::QueuedConnection);
} }
void MainWindow::applyInitialWorkMode() { void MainWindow::applyInitialWorkMode() {

View File

@ -60,7 +60,7 @@ public:
MainWidget *sessionContent() const; MainWidget *sessionContent() const;
void checkActivation(); void checkActivation() override;
[[nodiscard]] bool markingAsRead() const; [[nodiscard]] bool markingAsRead() const;
bool takeThirdSectionFromLayer(); bool takeThirdSectionFromLayer();

View File

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/ */
#include "window/main_window.h" #include "window/main_window.h"
#include "api/api_updates.h"
#include "storage/localstorage.h" #include "storage/localstorage.h"
#include "platform/platform_specific.h" #include "platform/platform_specific.h"
#include "ui/platform/ui_platform_window.h" #include "ui/platform/ui_platform_window.h"
@ -512,9 +513,13 @@ void MainWindow::handleStateChanged(Qt::WindowState state) {
} }
void MainWindow::handleActiveChanged() { void MainWindow::handleActiveChanged() {
checkActivation();
if (isActiveWindow()) { if (isActiveWindow()) {
Core::App().windowActivated(&controller()); Core::App().windowActivated(&controller());
} }
if (const auto controller = sessionController()) {
controller->session().updates().updateOnline();
}
} }
void MainWindow::handleVisibleChanged(bool visible) { void MainWindow::handleVisibleChanged(bool visible) {

View File

@ -148,6 +148,8 @@ protected:
void handleActiveChanged(); void handleActiveChanged();
void handleVisibleChanged(bool visible); void handleVisibleChanged(bool visible);
virtual void checkActivation() {
}
virtual void initHook() { virtual void initHook() {
} }