Moved ScreenIsLocked variable from facades to application.

This commit is contained in:
23rd 2021-05-27 17:47:51 +03:00
parent 2ed3543b53
commit 16db8468fa
9 changed files with 20 additions and 15 deletions

View file

@ -590,6 +590,14 @@ void Application::startEmojiImageLoader() {
}, _lifetime); }, _lifetime);
} }
void Application::setScreenIsLocked(bool locked) {
_screenIsLocked = locked;
}
bool Application::screenIsLocked() const {
return _screenIsLocked;
}
void Application::setDefaultFloatPlayerDelegate( void Application::setDefaultFloatPlayerDelegate(
not_null<Media::Player::FloatDelegate*> delegate) { not_null<Media::Player::FloatDelegate*> delegate) {
Expects(!_defaultFloatPlayerDelegate == !_floatPlayers); Expects(!_defaultFloatPlayerDelegate == !_floatPlayers);

View file

@ -280,6 +280,10 @@ public:
void call_handleObservables(); void call_handleObservables();
// Global runtime variables.
void setScreenIsLocked(bool locked);
bool screenIsLocked() const;
protected: protected:
bool eventFilter(QObject *object, QEvent *event) override; bool eventFilter(QObject *object, QEvent *event) override;
@ -360,6 +364,7 @@ private:
const QImage _logoNoMargin; const QImage _logoNoMargin;
rpl::variable<bool> _passcodeLock; rpl::variable<bool> _passcodeLock;
bool _screenIsLocked = false;
crl::time _shouldLockAt = 0; crl::time _shouldLockAt = 0;
base::Timer _autoLockTimer; base::Timer _autoLockTimer;

View file

@ -21,7 +21,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_app_config.h" #include "main/main_app_config.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "facades.h" // Global::ScreenIsLocked.
namespace Core { namespace Core {
namespace { namespace {
@ -134,7 +133,7 @@ void UiIntegration::activationFromTopPanel() {
} }
bool UiIntegration::screenIsLocked() { bool UiIntegration::screenIsLocked() {
return Global::ScreenIsLocked(); return Core::App().screenIsLocked();
} }
QString UiIntegration::timeFormat() { QString UiIntegration::timeFormat() {

View file

@ -338,8 +338,6 @@ namespace Global {
namespace internal { namespace internal {
struct Data { struct Data {
bool ScreenIsLocked = false;
bool TryIPv6 = !Platform::IsWindows(); bool TryIPv6 = !Platform::IsWindows();
std::vector<MTP::ProxyData> ProxiesList; std::vector<MTP::ProxyData> ProxiesList;
MTP::ProxyData SelectedProxy; MTP::ProxyData SelectedProxy;
@ -370,8 +368,6 @@ void finish() {
GlobalData = nullptr; GlobalData = nullptr;
} }
DefineVar(Global, bool, ScreenIsLocked);
DefineVar(Global, bool, TryIPv6); DefineVar(Global, bool, TryIPv6);
DefineVar(Global, std::vector<MTP::ProxyData>, ProxiesList); DefineVar(Global, std::vector<MTP::ProxyData>, ProxiesList);
DefineVar(Global, MTP::ProxyData, SelectedProxy); DefineVar(Global, MTP::ProxyData, SelectedProxy);

View file

@ -95,8 +95,6 @@ bool started();
void start(); void start();
void finish(); void finish();
DeclareVar(bool, ScreenIsLocked);
DeclareVar(bool, TryIPv6); DeclareVar(bool, TryIPv6);
DeclareVar(std::vector<MTP::ProxyData>, ProxiesList); DeclareVar(std::vector<MTP::ProxyData>, ProxiesList);
DeclareVar(MTP::ProxyData, SelectedProxy); DeclareVar(MTP::ProxyData, SelectedProxy);

View file

@ -192,11 +192,11 @@ private:
} }
- (void) screenIsLocked:(NSNotification *)aNotification { - (void) screenIsLocked:(NSNotification *)aNotification {
Global::SetScreenIsLocked(true); Core::App().setScreenIsLocked(true);
} }
- (void) screenIsUnlocked:(NSNotification *)aNotification { - (void) screenIsUnlocked:(NSNotification *)aNotification {
Global::SetScreenIsLocked(false); Core::App().setScreenIsLocked(false);
} }
- (void) windowWillEnterFullScreen:(NSNotification *)aNotification { - (void) windowWillEnterFullScreen:(NSNotification *)aNotification {

View file

@ -19,7 +19,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/core_settings.h" #include "core/core_settings.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "facades.h" // Global::ScreenIsLocked.
#include "windows_quiethours_h.h" #include "windows_quiethours_h.h"
#include <Shobjidl.h> #include <Shobjidl.h>
@ -425,7 +424,7 @@ bool SkipAudioForCustom() {
return (UserNotificationState == QUNS_NOT_PRESENT) return (UserNotificationState == QUNS_NOT_PRESENT)
|| (UserNotificationState == QUNS_PRESENTATION_MODE) || (UserNotificationState == QUNS_PRESENTATION_MODE)
|| Global::ScreenIsLocked(); || Core::App().screenIsLocked();
} }
bool SkipToastForCustom() { bool SkipToastForCustom() {

View file

@ -236,9 +236,9 @@ bool EventFilter::mainWindowEvent(
case WM_WTSSESSION_CHANGE: { case WM_WTSSESSION_CHANGE: {
if (wParam == WTS_SESSION_LOGOFF || wParam == WTS_SESSION_LOCK) { 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) { } else if (wParam == WTS_SESSION_LOGON || wParam == WTS_SESSION_UNLOCK) {
Global::SetScreenIsLocked(false); Core::App().setScreenIsLocked(false);
} }
} return false; } return false;

View file

@ -745,7 +745,7 @@ void NativeManager::doShowNotification(
} }
bool NativeManager::forceHideDetails() const { bool NativeManager::forceHideDetails() const {
return Global::ScreenIsLocked(); return Core::App().screenIsLocked();
} }
System::~System() = default; System::~System() = default;