mirror of
https://github.com/overte-org/overte.git
synced 2025-04-16 13:56:24 +02:00
mac sleep monitor checkpoint
This commit is contained in:
parent
4c145386e5
commit
8d3dc52ac0
3 changed files with 94 additions and 0 deletions
|
@ -257,6 +257,10 @@ extern "C" {
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
#include "MacHelper.h"
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_ANDROID)
|
||||
#include <android/log.h>
|
||||
#include "AndroidHelper.h"
|
||||
|
@ -960,6 +964,9 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) {
|
|||
DependencyManager::set<KeyboardScriptingInterface>();
|
||||
DependencyManager::set<GrabManager>();
|
||||
DependencyManager::set<AvatarPackager>();
|
||||
#ifdef Q_OS_MAC
|
||||
DependencyManager::set<MacHelper>();
|
||||
#endif
|
||||
|
||||
QString setBookmarkValue = getCmdOption(argc, constArgv, "--setBookmark");
|
||||
if (!setBookmarkValue.isEmpty()) {
|
||||
|
@ -2829,17 +2836,20 @@ void Application::cleanupBeforeQuit() {
|
|||
}
|
||||
|
||||
Application::~Application() {
|
||||
qCInfo(interfaceapp) << "HRS FIXME Quit 1";
|
||||
// remove avatars from physics engine
|
||||
auto avatarManager = DependencyManager::get<AvatarManager>();
|
||||
avatarManager->clearOtherAvatars();
|
||||
auto myCharacterController = getMyAvatar()->getCharacterController();
|
||||
myCharacterController->clearDetailedMotionStates();
|
||||
qCInfo(interfaceapp) << "HRS FIXME Quit 2";
|
||||
|
||||
PhysicsEngine::Transaction transaction;
|
||||
avatarManager->buildPhysicsTransaction(transaction);
|
||||
_physicsEngine->processTransaction(transaction);
|
||||
avatarManager->handleProcessedPhysicsTransaction(transaction);
|
||||
avatarManager->deleteAllAvatars();
|
||||
qCInfo(interfaceapp) << "HRS FIXME Quit 3";
|
||||
|
||||
_physicsEngine->setCharacterController(nullptr);
|
||||
|
||||
|
@ -2850,9 +2860,15 @@ Application::~Application() {
|
|||
// shutdown graphics engine
|
||||
_graphicsEngine.shutdown();
|
||||
|
||||
qCInfo(interfaceapp) << "HRS FIXME Quit 4";
|
||||
_gameWorkload.shutdown();
|
||||
qCInfo(interfaceapp) << "HRS FIXME Quit 5";
|
||||
|
||||
DependencyManager::destroy<Preferences>();
|
||||
qCInfo(interfaceapp) << "HRS FIXME Quit 6";
|
||||
#ifdef Q_OS_MAC
|
||||
DependencyManager::destroy<MacHelper>();
|
||||
#endif
|
||||
|
||||
_entityClipboard->eraseAllOctreeElements();
|
||||
_entityClipboard.reset();
|
||||
|
|
57
interface/src/MacHelper.cpp
Executable file
57
interface/src/MacHelper.cpp
Executable file
|
@ -0,0 +1,57 @@
|
|||
//
|
||||
// MacHelper.h
|
||||
// interface/src
|
||||
//
|
||||
// Created by Howard Stearns
|
||||
// Copyright 2019 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "InterfaceLogging.h"
|
||||
#include "MacHelper.h"
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
#include <IOKit/pwr_mgt/IOPMLib.h>
|
||||
#include <IOKit/IOMessage.h>
|
||||
|
||||
io_connect_t root_port;
|
||||
IONotificationPortRef notifyPortRef;
|
||||
io_object_t notifierObject;
|
||||
void* refCon;
|
||||
|
||||
void sleepHandler(void* refCon, io_service_t service, natural_t messageType, void* messageArgument) {
|
||||
qCInfo(interfaceapp) << "HRS FIXME sleepHandler.";
|
||||
if (messageType == kIOMessageSystemHasPoweredOn) {
|
||||
qCInfo(interfaceapp) << "HRS FIXME Waking up from sleep or hybernation.";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
MacHelper::MacHelper() {
|
||||
qCInfo(interfaceapp) << "HRS FIXME Start MacHelper.";
|
||||
#ifdef Q_OS_MAC
|
||||
root_port = IORegisterForSystemPower(refCon, ¬ifyPortRef, sleepHandler, ¬ifierObject);
|
||||
if (root_port == 0) {
|
||||
qCWarning(interfaceapp) << "IORegisterForSystemPower failed";
|
||||
} else {
|
||||
qCDebug(interfaceapp) << "HRS FIXME IORegisterForSystemPower OK";
|
||||
}
|
||||
CFRunLoopAddSource(CFRunLoopGetCurrent(),
|
||||
IONotificationPortGetRunLoopSource(notifyPortRef),
|
||||
kCFRunLoopCommonModes);
|
||||
#endif
|
||||
}
|
||||
|
||||
MacHelper::~MacHelper() {
|
||||
qCInfo(interfaceapp) << "HRS FIXME End MacHelper.";
|
||||
#ifdef Q_OS_MAC
|
||||
CFRunLoopRemoveSource(CFRunLoopGetCurrent(),
|
||||
IONotificationPortGetRunLoopSource(notifyPortRef),
|
||||
kCFRunLoopCommonModes);
|
||||
IODeregisterForSystemPower(¬ifierObject);
|
||||
IOServiceClose(root_port);
|
||||
IONotificationPortDestroy(notifyPortRef);
|
||||
#endif
|
||||
}
|
21
interface/src/MacHelper.h
Executable file
21
interface/src/MacHelper.h
Executable file
|
@ -0,0 +1,21 @@
|
|||
//
|
||||
// MacHelper.h
|
||||
// interface/src
|
||||
//
|
||||
// Created by Howard Stearns
|
||||
// Copyright 2019 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "DependencyManager.h"
|
||||
|
||||
class MacHelper : public Dependency {
|
||||
public:
|
||||
MacHelper();
|
||||
~MacHelper();
|
||||
};
|
||||
|
Loading…
Reference in a new issue