History

Support platform independent sleep/wake notifications

Brad Davis committed 7 years ago

Commit dfd78a21 parent 03e3f389 files · +263 −96Browse files

Showing the changes to interface/src/Application.cpp (1 of 9 files). Show all

Unified · Split

interface/src/Application.cpp+19−17
@@ -58,6 +58,7 @@ · 57 unmodified lines
58 58
59#include <shared/FileUtils.h>59#include <shared/FileUtils.h>
60#include <shared/QtHelpers.h>60#include <shared/QtHelpers.h>
61#include <shared/PlatformHelper.h>
61#include <shared/GlobalAppProperties.h>62#include <shared/GlobalAppProperties.h>
62#include <StatTracker.h>63#include <StatTracker.h>
63#include <Trace.h>64#include <Trace.h>
@@ -257,10 +258,6 @@ extern "C" { · 193 unmodified lines
257}258}
258#endif259#endif
259 260
260#ifdef Q_OS_MAC
261#include "MacHelper.h"
262#endif
263
264#if defined(Q_OS_ANDROID)261#if defined(Q_OS_ANDROID)
265#include <android/log.h>262#include <android/log.h>
266#include "AndroidHelper.h"263#include "AndroidHelper.h"
@@ -552,13 +549,6 @@ public: · 285 unmodified lines
552 return true;549 return true;
553 }550 }
554 551
555 if (message->message == WM_POWERBROADCAST) {
556 if (message->wParam == PBT_APMRESUMEAUTOMATIC) {
557 qCInfo(interfaceapp) << "Waking up from sleep or hybernation.";
558 QMetaObject::invokeMethod(DependencyManager::get<NodeList>().data(), "noteAwakening", Qt::QueuedConnection);
559 }
560 }
561
562 if (message->message == WM_COPYDATA) {552 if (message->message == WM_COPYDATA) {
563 COPYDATASTRUCT* pcds = (COPYDATASTRUCT*)(message->lParam);553 COPYDATASTRUCT* pcds = (COPYDATASTRUCT*)(message->lParam);
564 QUrl url = QUrl((const char*)(pcds->lpData));554 QUrl url = QUrl((const char*)(pcds->lpData));
@@ -964,9 +954,12 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { · 399 unmodified lines
964 DependencyManager::set<KeyboardScriptingInterface>();954 DependencyManager::set<KeyboardScriptingInterface>();
965 DependencyManager::set<GrabManager>();955 DependencyManager::set<GrabManager>();
966 DependencyManager::set<AvatarPackager>();956 DependencyManager::set<AvatarPackager>();
967#ifdef Q_OS_MAC957 PlatformHelper::setup();
968 DependencyManager::set<MacHelper>();958
969#endif959 QObject::connect(DependencyManager::get<PlatformHelper>().get(), &PlatformHelper::systemWillWake, [] {
960 QMetaObject::invokeMethod(DependencyManager::get<NodeList>().data(), "noteAwakening", Qt::QueuedConnection);
961 });
962
970 963
971 QString setBookmarkValue = getCmdOption(argc, constArgv, "--setBookmark");964 QString setBookmarkValue = getCmdOption(argc, constArgv, "--setBookmark");
972 if (!setBookmarkValue.isEmpty()) {965 if (!setBookmarkValue.isEmpty()) {
@@ -1172,6 +1165,17 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 199 unmodified lines
1172 deadlockWatchdogThread->setMainThreadID(QThread::currentThreadId());1165 deadlockWatchdogThread->setMainThreadID(QThread::currentThreadId());
1173 deadlockWatchdogThread->start();1166 deadlockWatchdogThread->start();
1174 1167
1168 // Pause the deadlock watchdog when we sleep, or it might
1169 // trigger a false positive when we wake back up
1170 auto platformHelper = DependencyManager::get<PlatformHelper>();
1171
1172 connect(platformHelper.get(), &PlatformHelper::systemWillSleep, [] {
1173 DeadlockWatchdogThread::pause();
1174 });
1175
1176 connect(platformHelper.get(), &PlatformHelper::systemWillWake, [] {
1177 DeadlockWatchdogThread::resume();
1178 });
1175 1179
1176 // Main thread timer to keep the watchdog updated1180 // Main thread timer to keep the watchdog updated
1177 QTimer* watchdogUpdateTimer = new QTimer(this);1181 QTimer* watchdogUpdateTimer = new QTimer(this);
@@ -2869,9 +2873,7 @@ Application::~Application() { · 1691 unmodified lines
2869 _gameWorkload.shutdown();2873 _gameWorkload.shutdown();
2870 2874
2871 DependencyManager::destroy<Preferences>();2875 DependencyManager::destroy<Preferences>();
2872#ifdef Q_OS_MAC2876 PlatformHelper::shutdown();
2873 DependencyManager::destroy<MacHelper>();
2874#endif
2875 2877
2876 _entityClipboard->eraseAllOctreeElements();2878 _entityClipboard->eraseAllOctreeElements();
2877 _entityClipboard.reset();2879 _entityClipboard.reset();

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t