From 16db8468fa149bb574375250f4cf4953818ae3b5 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Thu, 27 May 2021 17:47:51 +0300 Subject: [PATCH] Moved ScreenIsLocked variable from facades to application. --- Telegram/SourceFiles/core/application.cpp | 8 ++++++++ Telegram/SourceFiles/core/application.h | 5 +++++ Telegram/SourceFiles/core/ui_integration.cpp | 3 +-- Telegram/SourceFiles/facades.cpp | 4 ---- Telegram/SourceFiles/facades.h | 2 -- Telegram/SourceFiles/platform/mac/main_window_mac.mm | 4 ++-- .../platform/win/notifications_manager_win.cpp | 3 +-- .../SourceFiles/platform/win/windows_event_filter.cpp | 4 ++-- Telegram/SourceFiles/window/notifications_manager.cpp | 2 +- 9 files changed, 20 insertions(+), 15 deletions(-) diff --git a/Telegram/SourceFiles/core/application.cpp b/Telegram/SourceFiles/core/application.cpp index 8479b51e83..d9c5338f7f 100644 --- a/Telegram/SourceFiles/core/application.cpp +++ b/Telegram/SourceFiles/core/application.cpp @@ -590,6 +590,14 @@ void Application::startEmojiImageLoader() { }, _lifetime); } +void Application::setScreenIsLocked(bool locked) { + _screenIsLocked = locked; +} + +bool Application::screenIsLocked() const { + return _screenIsLocked; +} + void Application::setDefaultFloatPlayerDelegate( not_null delegate) { Expects(!_defaultFloatPlayerDelegate == !_floatPlayers); diff --git a/Telegram/SourceFiles/core/application.h b/Telegram/SourceFiles/core/application.h index a091ecfb33..8ca5e61657 100644 --- a/Telegram/SourceFiles/core/application.h +++ b/Telegram/SourceFiles/core/application.h @@ -280,6 +280,10 @@ public: void call_handleObservables(); + // Global runtime variables. + void setScreenIsLocked(bool locked); + bool screenIsLocked() const; + protected: bool eventFilter(QObject *object, QEvent *event) override; @@ -360,6 +364,7 @@ private: const QImage _logoNoMargin; rpl::variable _passcodeLock; + bool _screenIsLocked = false; crl::time _shouldLockAt = 0; base::Timer _autoLockTimer; diff --git a/Telegram/SourceFiles/core/ui_integration.cpp b/Telegram/SourceFiles/core/ui_integration.cpp index 81bf27ab5a..0639c928e9 100644 --- a/Telegram/SourceFiles/core/ui_integration.cpp +++ b/Telegram/SourceFiles/core/ui_integration.cpp @@ -21,7 +21,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "main/main_session.h" #include "main/main_app_config.h" #include "mainwindow.h" -#include "facades.h" // Global::ScreenIsLocked. namespace Core { namespace { @@ -134,7 +133,7 @@ void UiIntegration::activationFromTopPanel() { } bool UiIntegration::screenIsLocked() { - return Global::ScreenIsLocked(); + return Core::App().screenIsLocked(); } QString UiIntegration::timeFormat() { diff --git a/Telegram/SourceFiles/facades.cpp b/Telegram/SourceFiles/facades.cpp index 9b1a235e93..cb83787306 100644 --- a/Telegram/SourceFiles/facades.cpp +++ b/Telegram/SourceFiles/facades.cpp @@ -338,8 +338,6 @@ namespace Global { namespace internal { struct Data { - bool ScreenIsLocked = false; - bool TryIPv6 = !Platform::IsWindows(); std::vector ProxiesList; MTP::ProxyData SelectedProxy; @@ -370,8 +368,6 @@ void finish() { GlobalData = nullptr; } -DefineVar(Global, bool, ScreenIsLocked); - DefineVar(Global, bool, TryIPv6); DefineVar(Global, std::vector, ProxiesList); DefineVar(Global, MTP::ProxyData, SelectedProxy); diff --git a/Telegram/SourceFiles/facades.h b/Telegram/SourceFiles/facades.h index f88b7b17b8..38b69dd04b 100644 --- a/Telegram/SourceFiles/facades.h +++ b/Telegram/SourceFiles/facades.h @@ -95,8 +95,6 @@ bool started(); void start(); void finish(); -DeclareVar(bool, ScreenIsLocked); - DeclareVar(bool, TryIPv6); DeclareVar(std::vector, ProxiesList); DeclareVar(MTP::ProxyData, SelectedProxy); diff --git a/Telegram/SourceFiles/platform/mac/main_window_mac.mm b/Telegram/SourceFiles/platform/mac/main_window_mac.mm index 44cc8bc5a4..4de1fe0c91 100644 --- a/Telegram/SourceFiles/platform/mac/main_window_mac.mm +++ b/Telegram/SourceFiles/platform/mac/main_window_mac.mm @@ -192,11 +192,11 @@ private: } - (void) screenIsLocked:(NSNotification *)aNotification { - Global::SetScreenIsLocked(true); + Core::App().setScreenIsLocked(true); } - (void) screenIsUnlocked:(NSNotification *)aNotification { - Global::SetScreenIsLocked(false); + Core::App().setScreenIsLocked(false); } - (void) windowWillEnterFullScreen:(NSNotification *)aNotification { diff --git a/Telegram/SourceFiles/platform/win/notifications_manager_win.cpp b/Telegram/SourceFiles/platform/win/notifications_manager_win.cpp index f9b3fd167e..b8d8f8ae04 100644 --- a/Telegram/SourceFiles/platform/win/notifications_manager_win.cpp +++ b/Telegram/SourceFiles/platform/win/notifications_manager_win.cpp @@ -19,7 +19,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "core/core_settings.h" #include "main/main_session.h" #include "mainwindow.h" -#include "facades.h" // Global::ScreenIsLocked. #include "windows_quiethours_h.h" #include @@ -425,7 +424,7 @@ bool SkipAudioForCustom() { return (UserNotificationState == QUNS_NOT_PRESENT) || (UserNotificationState == QUNS_PRESENTATION_MODE) - || Global::ScreenIsLocked(); + || Core::App().screenIsLocked(); } bool SkipToastForCustom() { diff --git a/Telegram/SourceFiles/platform/win/windows_event_filter.cpp b/Telegram/SourceFiles/platform/win/windows_event_filter.cpp index 29affd3ffe..60d17ff591 100644 --- a/Telegram/SourceFiles/platform/win/windows_event_filter.cpp +++ b/Telegram/SourceFiles/platform/win/windows_event_filter.cpp @@ -236,9 +236,9 @@ bool EventFilter::mainWindowEvent( case WM_WTSSESSION_CHANGE: { if (wParam == WTS_SESSION_LOGOFF || wParam == WTS_SESSION_LOCK) { - Global::SetScreenIsLocked(true); + Core::App().setScreenIsLocked(true); } else if (wParam == WTS_SESSION_LOGON || wParam == WTS_SESSION_UNLOCK) { - Global::SetScreenIsLocked(false); + Core::App().setScreenIsLocked(false); } } return false; diff --git a/Telegram/SourceFiles/window/notifications_manager.cpp b/Telegram/SourceFiles/window/notifications_manager.cpp index d8a755b6e6..4b3c083928 100644 --- a/Telegram/SourceFiles/window/notifications_manager.cpp +++ b/Telegram/SourceFiles/window/notifications_manager.cpp @@ -745,7 +745,7 @@ void NativeManager::doShowNotification( } bool NativeManager::forceHideDetails() const { - return Global::ScreenIsLocked(); + return Core::App().screenIsLocked(); } System::~System() = default;