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
5858
5959 #include <shared/FileUtils.h>
6060 #include <shared/QtHelpers.h>
61+#include <shared/PlatformHelper.h>
6162 #include <shared/GlobalAppProperties.h>
6263 #include <StatTracker.h>
6364 #include <Trace.h>
@@ -257,10 +258,6 @@ extern "C" { · 193 unmodified lines
257258 }
258259 #endif
259260
260−#ifdef Q_OS_MAC
261−#include "MacHelper.h"
262−#endif
263−
264261 #if defined(Q_OS_ANDROID)
265262 #include <android/log.h>
266263 #include "AndroidHelper.h"
@@ -552,13 +549,6 @@ public: · 285 unmodified lines
552549 return true;
553550 }
554551
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−
562552 if (message->message == WM_COPYDATA) {
563553 COPYDATASTRUCT* pcds = (COPYDATASTRUCT*)(message->lParam);
564554 QUrl url = QUrl((const char*)(pcds->lpData));
@@ -964,9 +954,12 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { · 399 unmodified lines
964954 DependencyManager::set<KeyboardScriptingInterface>();
965955 DependencyManager::set<GrabManager>();
966956 DependencyManager::set<AvatarPackager>();
967−#ifdef Q_OS_MAC
968− DependencyManager::set<MacHelper>();
969−#endif
957+ PlatformHelper::setup();
958+
959+ QObject::connect(DependencyManager::get<PlatformHelper>().get(), &PlatformHelper::systemWillWake, [] {
960+ QMetaObject::invokeMethod(DependencyManager::get<NodeList>().data(), "noteAwakening", Qt::QueuedConnection);
961+ });
962+
970963
971964 QString setBookmarkValue = getCmdOption(argc, constArgv, "--setBookmark");
972965 if (!setBookmarkValue.isEmpty()) {
@@ -1172,6 +1165,17 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 199 unmodified lines
11721165 deadlockWatchdogThread->setMainThreadID(QThread::currentThreadId());
11731166 deadlockWatchdogThread->start();
11741167
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+ });
11751179
11761180 // Main thread timer to keep the watchdog updated
11771181 QTimer* watchdogUpdateTimer = new QTimer(this);
@@ -2869,9 +2873,7 @@ Application::~Application() { · 1691 unmodified lines
28692873 _gameWorkload.shutdown();
28702874
28712875 DependencyManager::destroy<Preferences>();
2872−#ifdef Q_OS_MAC
2873− DependencyManager::destroy<MacHelper>();
2874−#endif
2876+ PlatformHelper::shutdown();
28752877
28762878 _entityClipboard->eraseAllOctreeElements();
28772879 _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