diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake index aaca33ab1c..45cef27727 100644 --- a/cmake/compiler.cmake +++ b/cmake/compiler.cmake @@ -34,7 +34,7 @@ if (WIN32) list(APPEND CMAKE_PREFIX_PATH "${WINDOW_SDK_PATH}") # /wd4351 disables warning C4351: new behavior: elements of array will be default initialized - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /wd4351") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP${HIFI_MAX_BUILD_CORES} /wd4351") # /LARGEADDRESSAWARE enables 32-bit apps to use more than 2GB of memory. # Caveats: http://stackoverflow.com/questions/2288728/drawbacks-of-using-largeaddressaware-for-32-bit-windows-executables # TODO: Remove when building 64-bit. diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 090cdd52b6..e0ac3df30d 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -58,6 +58,7 @@ #include #include +#include #include #include #include @@ -257,10 +258,6 @@ extern "C" { } #endif -#ifdef Q_OS_MAC -#include "MacHelper.h" -#endif - #if defined(Q_OS_ANDROID) #include #include "AndroidHelper.h" @@ -552,13 +549,6 @@ public: return true; } - if (message->message == WM_POWERBROADCAST) { - if (message->wParam == PBT_APMRESUMEAUTOMATIC) { - qCInfo(interfaceapp) << "Waking up from sleep or hybernation."; - QMetaObject::invokeMethod(DependencyManager::get().data(), "noteAwakening", Qt::QueuedConnection); - } - } - if (message->message == WM_COPYDATA) { COPYDATASTRUCT* pcds = (COPYDATASTRUCT*)(message->lParam); QUrl url = QUrl((const char*)(pcds->lpData)); @@ -964,9 +954,12 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { DependencyManager::set(); DependencyManager::set(); DependencyManager::set(); -#ifdef Q_OS_MAC - DependencyManager::set(); -#endif + PlatformHelper::setup(); + + QObject::connect(PlatformHelper::instance(), &PlatformHelper::systemWillWake, [] { + QMetaObject::invokeMethod(DependencyManager::get().data(), "noteAwakening", Qt::QueuedConnection); + }); + QString setBookmarkValue = getCmdOption(argc, constArgv, "--setBookmark"); if (!setBookmarkValue.isEmpty()) { @@ -1172,6 +1165,17 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo deadlockWatchdogThread->setMainThreadID(QThread::currentThreadId()); deadlockWatchdogThread->start(); + // Pause the deadlock watchdog when we sleep, or it might + // trigger a false positive when we wake back up + auto platformHelper = PlatformHelper::instance(); + + connect(platformHelper, &PlatformHelper::systemWillSleep, [] { + DeadlockWatchdogThread::pause(); + }); + + connect(platformHelper, &PlatformHelper::systemWillWake, [] { + DeadlockWatchdogThread::resume(); + }); // Main thread timer to keep the watchdog updated QTimer* watchdogUpdateTimer = new QTimer(this); @@ -2868,9 +2872,7 @@ Application::~Application() { _gameWorkload.shutdown(); DependencyManager::destroy(); -#ifdef Q_OS_MAC - DependencyManager::destroy(); -#endif + PlatformHelper::shutdown(); _entityClipboard->eraseAllOctreeElements(); _entityClipboard.reset(); @@ -3562,6 +3564,9 @@ void Application::setupQmlSurface(QQmlContext* surfaceContext, bool setAdditiona surfaceContext->setContextProperty("WalletScriptingInterface", DependencyManager::get().data()); surfaceContext->setContextProperty("ResourceRequestObserver", DependencyManager::get().data()); surfaceContext->setContextProperty("PlatformInfo", PlatformInfoScriptingInterface::getInstance()); + // This `module` context property is blank for the QML scripting interface so that we don't get log errors when importing + // certain JS files from both scripts (in the JS context) and QML (in the QML context). + surfaceContext->setContextProperty("module", ""); } } diff --git a/interface/src/MacHelper.cpp b/interface/src/MacHelper.cpp deleted file mode 100755 index 8527f02918..0000000000 --- a/interface/src/MacHelper.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// -// 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" -#include - -#ifdef Q_OS_MAC -#include -#include - -// The type definitions in these variables come from IOKit, which includes a definition of Duration that conflicts with ours. -// So... we include these definitions here rather than in the .h, as the .h is included in Application.cpp which -// uses Duration. -static io_connect_t root_port; -static IONotificationPortRef notifyPortRef; -static io_object_t notifierObject; -static void* refCon; - -static void sleepHandler(void* refCon, io_service_t service, natural_t messageType, void* messageArgument) { - if (messageType == kIOMessageSystemHasPoweredOn) { - qCInfo(interfaceapp) << "Waking up from sleep or hybernation."; - QMetaObject::invokeMethod(DependencyManager::get().data(), "noteAwakening", Qt::QueuedConnection); - } -} -#endif - -MacHelper::MacHelper() { -#ifdef Q_OS_MAC - root_port = IORegisterForSystemPower(refCon, ¬ifyPortRef, sleepHandler, ¬ifierObject); - if (root_port == 0) { - qCWarning(interfaceapp) << "IORegisterForSystemPower failed"; - return; - } - CFRunLoopAddSource(CFRunLoopGetCurrent(), - IONotificationPortGetRunLoopSource(notifyPortRef), - kCFRunLoopCommonModes); -#endif -} - -MacHelper::~MacHelper() { -#ifdef Q_OS_MAC - CFRunLoopRemoveSource(CFRunLoopGetCurrent(), - IONotificationPortGetRunLoopSource(notifyPortRef), - kCFRunLoopCommonModes); - IODeregisterForSystemPower(¬ifierObject); - IOServiceClose(root_port); - IONotificationPortDestroy(notifyPortRef); -#endif -} diff --git a/interface/src/MacHelper.h b/interface/src/MacHelper.h deleted file mode 100755 index 52ad4d3e55..0000000000 --- a/interface/src/MacHelper.h +++ /dev/null @@ -1,21 +0,0 @@ -// -// 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(); -}; - diff --git a/interface/src/scripting/Audio.cpp b/interface/src/scripting/Audio.cpp index 8d9e57ad93..ba392f0cd1 100644 --- a/interface/src/scripting/Audio.cpp +++ b/interface/src/scripting/Audio.cpp @@ -101,8 +101,8 @@ void Audio::setMutedDesktop(bool isMuted) { } } }); - if (!isMuted && _settingsLoaded) { - // Disable Push-To-Talk if muted is changed to false. Settings also need to be loaded. + if (!isMuted && _settingsLoaded && !_pushingToTalk) { + // If the user is not pushing to talk and muted is changed to false, disable Push-To-Talk. Settings also need to be loaded. setPTTDesktop(isMuted); } if (changed) { @@ -132,8 +132,8 @@ void Audio::setMutedHMD(bool isMuted) { } } }); - if (!isMuted && _settingsLoaded) { - // Disable Push-To-Talk if muted is changed to false. Settings also need to be loaded. + if (!isMuted && _settingsLoaded && !_pushingToTalk) { + // If the user is not pushing to talk and muted is changed to false, disable Push-To-Talk. Settings also need to be loaded. setPTTHMD(isMuted); } if (changed) { diff --git a/interface/src/ui/InteractiveWindow.cpp b/interface/src/ui/InteractiveWindow.cpp index e1f89ef558..9145b12d30 100644 --- a/interface/src/ui/InteractiveWindow.cpp +++ b/interface/src/ui/InteractiveWindow.cpp @@ -225,6 +225,7 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap QObject::connect(_dockWidget.get(), SIGNAL(onResizeEvent()), this, SLOT(emitMainWindowResizeEvent())); _dockWidget->setSource(QUrl(sourceUrl)); + _dockWidget->setObjectName("DockedWidget"); mainWindow->addDockWidget(dockArea, _dockWidget.get()); } else { auto offscreenUi = DependencyManager::get(); @@ -283,6 +284,7 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap if (!KNOWN_SCHEMES.contains(sourceURL.scheme(), Qt::CaseInsensitive)) { sourceURL = QUrl::fromLocalFile(sourceURL.toString()).toString(); } + object->setObjectName("InteractiveWindow"); object->setProperty(SOURCE_PROPERTY, sourceURL); }); } diff --git a/launchers/darwin/CMakeLists.txt b/launchers/darwin/CMakeLists.txt index fa4c9d5f45..b495893b97 100644 --- a/launchers/darwin/CMakeLists.txt +++ b/launchers/darwin/CMakeLists.txt @@ -45,6 +45,8 @@ set(src_files src/CustomUI.m src/NSTask+NSTaskExecveAdditions.h src/NSTask+NSTaskExecveAdditions.m + src/HQDefaults.h + src/HQDefaults.m src/main.mm nib/Window.xib nib/SplashScreen.xib @@ -118,6 +120,10 @@ add_custom_command(TARGET ${PROJECT_NAME} PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/images "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${APP_NAME}.app/Contents/Resources/") +add_custom_command(TARGET ${PROJECT_NAME} PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_SOURCE_DIR}/data/HQDefaults.plist "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${APP_NAME}.app/Contents/Resources/") + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND updater COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/updater" "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${APP_NAME}.app/Contents/Resources/") @@ -146,3 +152,17 @@ set(DMG_SUBFOLDER_ICON "${CMAKE_SOURCE_DIR}/cmake/installer/install-folder.rsrc" set(CPACK_GENERATOR "DragNDrop") include(CPack) + +include(FindXCTest) + +include_directories(${CMAKE_SOURCE_DIR}/src) + +xctest_add_bundle(HQLauncherTests HQLauncher + ${CMAKE_SOURCE_DIR}/src/HQDefaults.m + ${CMAKE_SOURCE_DIR}/tests/HQDefaultsTests.m + ${CMAKE_SOURCE_DIR}/tests/Info.plist +) + +set_target_properties(HQLauncherTests PROPERTIES + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/tests/Info.plist + ) diff --git a/launchers/darwin/data/HQDefaults.plist b/launchers/darwin/data/HQDefaults.plist new file mode 100644 index 0000000000..98a29664c9 --- /dev/null +++ b/launchers/darwin/data/HQDefaults.plist @@ -0,0 +1,14 @@ + + + + + + name + thunderURL + defaultValue + https://thunder.highfidelity.com + environmentVariable + HIFI_THUNDER_URL + + + diff --git a/launchers/darwin/nib/DisplayNameScreen.xib b/launchers/darwin/nib/DisplayNameScreen.xib index 9862c3773b..77cc3b2222 100644 --- a/launchers/darwin/nib/DisplayNameScreen.xib +++ b/launchers/darwin/nib/DisplayNameScreen.xib @@ -81,7 +81,7 @@