History

Merge branch 'master' of https://github.com/highfidelity/hifi into project-freeloco

r3tk0n committed 7 years ago

Commit 39342b92 parents ce2e0c7 c0240d2321 files · +10278 −2523Browse files

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

Unified · Split

interface/src/Application.cpp+61−29
@@ -246,6 +246,8 @@ · 245 unmodified lines
246 246
247#include "AboutUtil.h"247#include "AboutUtil.h"
248 248
249#include <DisableDeferred.h>
250
249#if defined(Q_OS_WIN)251#if defined(Q_OS_WIN)
250#include <VersionHelpers.h>252#include <VersionHelpers.h>
251 253
@@ -289,13 +291,6 @@ static const QString DISABLE_WATCHDOG_FLAG{ "HIFI_DISABLE_WATCHDOG" }; · 37 unmodified lines
289static bool DISABLE_WATCHDOG = nsightActive() || QProcessEnvironment::systemEnvironment().contains(DISABLE_WATCHDOG_FLAG);291static bool DISABLE_WATCHDOG = nsightActive() || QProcessEnvironment::systemEnvironment().contains(DISABLE_WATCHDOG_FLAG);
290#endif292#endif
291 293
292#if defined(USE_GLES)
293static bool DISABLE_DEFERRED = true;
294#else
295static const QString RENDER_FORWARD{ "HIFI_RENDER_FORWARD" };
296static bool DISABLE_DEFERRED = QProcessEnvironment::systemEnvironment().contains(RENDER_FORWARD);
297#endif
298
299#if !defined(Q_OS_ANDROID)294#if !defined(Q_OS_ANDROID)
300static const uint32_t MAX_CONCURRENT_RESOURCE_DOWNLOADS = 16;295static const uint32_t MAX_CONCURRENT_RESOURCE_DOWNLOADS = 16;
301#else296#else
@@ -759,6 +754,11 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { · 457 unmodified lines
759 bool isStore = cmdOptionExists(argc, const_cast<const char**>(argv), OCULUS_STORE_ARG);754 bool isStore = cmdOptionExists(argc, const_cast<const char**>(argv), OCULUS_STORE_ARG);
760 qApp->setProperty(hifi::properties::OCULUS_STORE, isStore);755 qApp->setProperty(hifi::properties::OCULUS_STORE, isStore);
761 756
757 // emulate standalone device
758 static const auto STANDALONE_ARG = "--standalone";
759 bool isStandalone = cmdOptionExists(argc, const_cast<const char**>(argv), STANDALONE_ARG);
760 qApp->setProperty(hifi::properties::STANDALONE, isStandalone);
761
762 // Ignore any previous crashes if running from command line with a test script.762 // Ignore any previous crashes if running from command line with a test script.
763 bool inTestMode { false };763 bool inTestMode { false };
764 for (int i = 0; i < argc; ++i) {764 for (int i = 0; i < argc; ++i) {
@@ -1065,6 +1065,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 300 unmodified lines
1065 connect(PluginManager::getInstance().data(), &PluginManager::inputDeviceRunningChanged,1065 connect(PluginManager::getInstance().data(), &PluginManager::inputDeviceRunningChanged,
1066 controllerScriptingInterface, &controller::ScriptingInterface::updateRunningInputDevices);1066 controllerScriptingInterface, &controller::ScriptingInterface::updateRunningInputDevices);
1067 1067
1068 EntityTree::setEntityClicksCapturedOperator([this] {
1069 return _controllerScriptingInterface->areEntityClicksCaptured();
1070 });
1071
1068 _entityClipboard->createRootElement();1072 _entityClipboard->createRootElement();
1069 1073
1070#ifdef Q_OS_WIN1074#ifdef Q_OS_WIN
@@ -1079,6 +1083,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 8 unmodified lines
1079 QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "fonts/FiraSans-SemiBold.ttf");1083 QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "fonts/FiraSans-SemiBold.ttf");
1080 QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "fonts/Raleway-Light.ttf");1084 QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "fonts/Raleway-Light.ttf");
1081 QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "fonts/Raleway-Regular.ttf");1085 QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "fonts/Raleway-Regular.ttf");
1086 QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "fonts/rawline-500.ttf");
1082 QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "fonts/Raleway-Bold.ttf");1087 QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "fonts/Raleway-Bold.ttf");
1083 QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "fonts/Raleway-SemiBold.ttf");1088 QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "fonts/Raleway-SemiBold.ttf");
1084 QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "fonts/Cairo-SemiBold.ttf");1089 QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "fonts/Cairo-SemiBold.ttf");
@@ -1766,6 +1771,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 681 unmodified lines
1766#endif1771#endif
1767 });1772 });
1768 1773
1774
1769 // Setup the _keyboardMouseDevice, _touchscreenDevice, _touchscreenVirtualPadDevice and the user input mapper with the default bindings1775 // Setup the _keyboardMouseDevice, _touchscreenDevice, _touchscreenVirtualPadDevice and the user input mapper with the default bindings
1770 userInputMapper->registerDevice(_keyboardMouseDevice->getInputDevice());1776 userInputMapper->registerDevice(_keyboardMouseDevice->getInputDevice());
1771 // if the _touchscreenDevice is not supported it will not be registered1777 // if the _touchscreenDevice is not supported it will not be registered
@@ -2350,6 +2356,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 578 unmodified lines
2350 } else {2356 } else {
2351 QObject::connect(webSurface.data(), &hifi::qml::OffscreenSurface::rootContextCreated, rootItemLoadedFunctor);2357 QObject::connect(webSurface.data(), &hifi::qml::OffscreenSurface::rootContextCreated, rootItemLoadedFunctor);
2352 }2358 }
2359 auto surfaceContext = webSurface->getSurfaceContext();
2360 surfaceContext->setContextProperty("KeyboardScriptingInterface", DependencyManager::get<KeyboardScriptingInterface>().data());
2353 } else {2361 } else {
2354 // FIXME: the tablet should use the OffscreenQmlSurfaceCache2362 // FIXME: the tablet should use the OffscreenQmlSurfaceCache
2355 webSurface = QSharedPointer<OffscreenQmlSurface>(new OffscreenQmlSurface(), [](OffscreenQmlSurface* webSurface) {2363 webSurface = QSharedPointer<OffscreenQmlSurface>(new OffscreenQmlSurface(), [](OffscreenQmlSurface* webSurface) {
@@ -2421,6 +2429,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 65 unmodified lines
2421 connect(&AndroidHelper::instance(), &AndroidHelper::beforeEnterBackground, this, &Application::beforeEnterBackground);2429 connect(&AndroidHelper::instance(), &AndroidHelper::beforeEnterBackground, this, &Application::beforeEnterBackground);
2422 connect(&AndroidHelper::instance(), &AndroidHelper::enterBackground, this, &Application::enterBackground);2430 connect(&AndroidHelper::instance(), &AndroidHelper::enterBackground, this, &Application::enterBackground);
2423 connect(&AndroidHelper::instance(), &AndroidHelper::enterForeground, this, &Application::enterForeground);2431 connect(&AndroidHelper::instance(), &AndroidHelper::enterForeground, this, &Application::enterForeground);
2432 connect(&AndroidHelper::instance(), &AndroidHelper::toggleAwayMode, this, &Application::toggleAwayMode);
2424 AndroidHelper::instance().notifyLoadComplete();2433 AndroidHelper::instance().notifyLoadComplete();
2425#endif2434#endif
2426 pauseUntilLoginDetermined();2435 pauseUntilLoginDetermined();
@@ -3031,6 +3040,10 @@ void Application::initializeUi() { · 604 unmodified lines
3031 };3040 };
3032 OffscreenQmlSurface::addWhitelistContextHandler({3041 OffscreenQmlSurface::addWhitelistContextHandler({
3033 QUrl{ "hifi/commerce/marketplace/Marketplace.qml" },3042 QUrl{ "hifi/commerce/marketplace/Marketplace.qml" },
3043 QUrl{ "hifi/commerce/purchases/Purchases.qml" },
3044 QUrl{ "hifi/commerce/wallet/Wallet.qml" },
3045 QUrl{ "hifi/commerce/wallet/WalletHome.qml" },
3046 QUrl{ "hifi/tablet/TabletAddressDialog.qml" },
3034 }, platformInfoCallback);3047 }, platformInfoCallback);
3035 3048
3036 QmlContextCallback ttsCallback = [](QQmlContext* context) {3049 QmlContextCallback ttsCallback = [](QQmlContext* context) {
@@ -3285,6 +3298,7 @@ void Application::setupQmlSurface(QQmlContext* surfaceContext, bool setAdditiona · 248 unmodified lines
3285 surfaceContext->setContextProperty("MyAvatar", DependencyManager::get<AvatarManager>()->getMyAvatar().get());3298 surfaceContext->setContextProperty("MyAvatar", DependencyManager::get<AvatarManager>()->getMyAvatar().get());
3286 surfaceContext->setContextProperty("Entities", DependencyManager::get<EntityScriptingInterface>().data());3299 surfaceContext->setContextProperty("Entities", DependencyManager::get<EntityScriptingInterface>().data());
3287 surfaceContext->setContextProperty("Snapshot", DependencyManager::get<Snapshot>().data());3300 surfaceContext->setContextProperty("Snapshot", DependencyManager::get<Snapshot>().data());
3301 surfaceContext->setContextProperty("KeyboardScriptingInterface", DependencyManager::get<KeyboardScriptingInterface>().data());
3288 3302
3289 if (setAdditionalContextProperties) {3303 if (setAdditionalContextProperties) {
3290 auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();3304 auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
@@ -3295,7 +3309,6 @@ void Application::setupQmlSurface(QQmlContext* surfaceContext, bool setAdditiona · 4 unmodified lines
3295 3309
3296 surfaceContext->setContextProperty("Settings", SettingsScriptingInterface::getInstance());3310 surfaceContext->setContextProperty("Settings", SettingsScriptingInterface::getInstance());
3297 surfaceContext->setContextProperty("MenuInterface", MenuScriptingInterface::getInstance());3311 surfaceContext->setContextProperty("MenuInterface", MenuScriptingInterface::getInstance());
3298 surfaceContext->setContextProperty("KeyboardScriptingInterface", DependencyManager::get<KeyboardScriptingInterface>().data());
3299 3312
3300 surfaceContext->setContextProperty("Account", AccountServicesScriptingInterface::getInstance()); // DEPRECATED - TO BE REMOVED3313 surfaceContext->setContextProperty("Account", AccountServicesScriptingInterface::getInstance()); // DEPRECATED - TO BE REMOVED
3301 surfaceContext->setContextProperty("GlobalServices", AccountServicesScriptingInterface::getInstance()); // DEPRECATED - TO BE REMOVED3314 surfaceContext->setContextProperty("GlobalServices", AccountServicesScriptingInterface::getInstance()); // DEPRECATED - TO BE REMOVED
@@ -3671,8 +3684,8 @@ void Application::handleSandboxStatus(QNetworkReply* reply) { · 369 unmodified lines
3671 // If this is a first run we short-circuit the address passed in3684 // If this is a first run we short-circuit the address passed in
3672 if (_firstRun.get()) {3685 if (_firstRun.get()) {
3673#if !defined(Q_OS_ANDROID)3686#if !defined(Q_OS_ANDROID)
3674 DependencyManager::get<AddressManager>()->goToEntry();3687 DependencyManager::get<AddressManager>()->goToEntry();
3675 sentTo = SENT_TO_ENTRY;3688 sentTo = SENT_TO_ENTRY;
3676#endif3689#endif
3677 _firstRun.set(false);3690 _firstRun.set(false);
3678 3691
@@ -3783,9 +3796,12 @@ std::map<QString, QString> Application::prepareServerlessDomainContents(QUrl dom · 104 unmodified lines
3783 tmpTree->reaverageOctreeElements();3796 tmpTree->reaverageOctreeElements();
3784 tmpTree->sendEntities(&_entityEditSender, getEntities()->getTree(), 0, 0, 0);3797 tmpTree->sendEntities(&_entityEditSender, getEntities()->getTree(), 0, 0, 0);
3785 }3798 }
3799 std::map<QString, QString> namedPaths = tmpTree->getNamedPaths();
3786 3800
3787 return tmpTree->getNamedPaths();3801 // we must manually eraseAllOctreeElements(false) else the tmpTree will mem-leak
3802 tmpTree->eraseAllOctreeElements(false);
3788 3803
3804 return namedPaths;
3789}3805}
3790 3806
3791void Application::loadServerlessDomain(QUrl domainURL) {3807void Application::loadServerlessDomain(QUrl domainURL) {
@@ -4396,7 +4412,6 @@ void Application::mouseMoveEvent(QMouseEvent* event) { · 604 unmodified lines
4396 if (compositor.getReticleVisible() || !isHMDMode() || !compositor.getReticleOverDesktop() ||4412 if (compositor.getReticleVisible() || !isHMDMode() || !compositor.getReticleOverDesktop() ||
4397 getOverlays().getOverlayAtPoint(glm::vec2(transformedPos.x(), transformedPos.y())) != UNKNOWN_ENTITY_ID) {4413 getOverlays().getOverlayAtPoint(glm::vec2(transformedPos.x(), transformedPos.y())) != UNKNOWN_ENTITY_ID) {
4398 getEntities()->mouseMoveEvent(&mappedEvent);4414 getEntities()->mouseMoveEvent(&mappedEvent);
4399 getOverlays().mouseMoveEvent(&mappedEvent);
4400 }4415 }
4401 4416
4402 _controllerScriptingInterface->emitMouseMoveEvent(&mappedEvent); // send events to any registered scripts4417 _controllerScriptingInterface->emitMouseMoveEvent(&mappedEvent); // send events to any registered scripts
@@ -4430,14 +4445,8 @@ void Application::mousePressEvent(QMouseEvent* event) { · 27 unmodified lines
4430#endif4445#endif
4431 4446
4432 QMouseEvent mappedEvent(event->type(), transformedPos, event->screenPos(), event->button(), event->buttons(), event->modifiers());4447 QMouseEvent mappedEvent(event->type(), transformedPos, event->screenPos(), event->button(), event->buttons(), event->modifiers());
4433 std::pair<float, QUuid> entityResult;4448 QUuid result = getEntities()->mousePressEvent(&mappedEvent);
4434 if (!_controllerScriptingInterface->areEntityClicksCaptured()) {4449 setKeyboardFocusEntity(getEntities()->wantsKeyboardFocus(result) ? result : UNKNOWN_ENTITY_ID);
4435 entityResult = getEntities()->mousePressEvent(&mappedEvent);
4436 }
4437 std::pair<float, QUuid> overlayResult = getOverlays().mousePressEvent(&mappedEvent);
4438
4439 QUuid focusedEntity = entityResult.first < overlayResult.first ? entityResult.second : overlayResult.second;
4440 setKeyboardFocusEntity(getEntities()->wantsKeyboardFocus(focusedEntity) ? focusedEntity : UNKNOWN_ENTITY_ID);
4441 4450
4442 _controllerScriptingInterface->emitMousePressEvent(&mappedEvent); // send events to any registered scripts4451 _controllerScriptingInterface->emitMousePressEvent(&mappedEvent); // send events to any registered scripts
4443 4452
@@ -4476,11 +4485,7 @@ void Application::mouseDoublePressEvent(QMouseEvent* event) { · 32 unmodified lines
4476 transformedPos,4485 transformedPos,
4477 event->screenPos(), event->button(),4486 event->screenPos(), event->button(),
4478 event->buttons(), event->modifiers());4487 event->buttons(), event->modifiers());
4479 4488 getEntities()->mouseDoublePressEvent(&mappedEvent);
4480 if (!_controllerScriptingInterface->areEntityClicksCaptured()) {
4481 getEntities()->mouseDoublePressEvent(&mappedEvent);
4482 }
4483 getOverlays().mouseDoublePressEvent(&mappedEvent);
4484 4489
4485 // if one of our scripts have asked to capture this event, then stop processing it4490 // if one of our scripts have asked to capture this event, then stop processing it
4486 if (_controllerScriptingInterface->isMouseCaptured()) {4491 if (_controllerScriptingInterface->isMouseCaptured()) {
@@ -4505,7 +4510,6 @@ void Application::mouseReleaseEvent(QMouseEvent* event) { · 18 unmodified lines
4505 event->buttons(), event->modifiers());4510 event->buttons(), event->modifiers());
4506 4511
4507 getEntities()->mouseReleaseEvent(&mappedEvent);4512 getEntities()->mouseReleaseEvent(&mappedEvent);
4508 getOverlays().mouseReleaseEvent(&mappedEvent);
4509 4513
4510 _controllerScriptingInterface->emitMouseReleaseEvent(&mappedEvent); // send events to any registered scripts4514 _controllerScriptingInterface->emitMouseReleaseEvent(&mappedEvent); // send events to any registered scripts
4511 4515
@@ -4989,6 +4993,15 @@ void Application::idle() { · 477 unmodified lines
4989 }4993 }
4990 }4994 }
4991 4995
4996 {
4997 if (_keyboardFocusWaitingOnRenderable && getEntities()->renderableForEntityId(_keyboardFocusedEntity.get())) {
4998 QUuid entityId = _keyboardFocusedEntity.get();
4999 setKeyboardFocusEntity(UNKNOWN_ENTITY_ID);
5000 _keyboardFocusWaitingOnRenderable = false;
5001 setKeyboardFocusEntity(entityId);
5002 }
5003 }
5004
4992 {5005 {
4993 PerformanceTimer perfTimer("pluginIdle");5006 PerformanceTimer perfTimer("pluginIdle");
4994 PerformanceWarning warn(showWarnings, "Application::idle()... pluginIdle()");5007 PerformanceWarning warn(showWarnings, "Application::idle()... pluginIdle()");
@@ -5771,6 +5784,11 @@ void Application::reloadResourceCaches() { · 776 unmodified lines
5771 5784
5772 DependencyManager::get<NodeList>()->reset(); // Force redownload of .fst models5785 DependencyManager::get<NodeList>()->reset(); // Force redownload of .fst models
5773 5786
5787 DependencyManager::get<ScriptEngines>()->reloadAllScripts();
5788 getOffscreenUI()->clearCache();
5789
5790 DependencyManager::get<Keyboard>()->createKeyboard();
5791
5774 getMyAvatar()->resetFullAvatarURL();5792 getMyAvatar()->resetFullAvatarURL();
5775}5793}
5776 5794
@@ -5817,7 +5835,7 @@ void Application::setKeyboardFocusEntity(const QUuid& id) { · 40 unmodified lines
5817 if (qApp->getLoginDialogPoppedUp() && !_loginDialogID.isNull()) {5835 if (qApp->getLoginDialogPoppedUp() && !_loginDialogID.isNull()) {
5818 if (id == _loginDialogID) {5836 if (id == _loginDialogID) {
5819 emit loginDialogFocusEnabled();5837 emit loginDialogFocusEnabled();
5820 } else {5838 } else if (!_keyboardFocusWaitingOnRenderable) {
5821 // that's the only entity we want in focus;5839 // that's the only entity we want in focus;
5822 return;5840 return;
5823 }5841 }
@@ -5834,7 +5852,10 @@ void Application::setKeyboardFocusEntity(const QUuid& id) { · 10 unmodified lines
5834 if (properties.getVisible()) {5852 if (properties.getVisible()) {
5835 auto entities = getEntities();5853 auto entities = getEntities();
5836 auto entityId = _keyboardFocusedEntity.get();5854 auto entityId = _keyboardFocusedEntity.get();
5837 if (entities->wantsKeyboardFocus(entityId)) {5855 auto entityItemRenderable = entities->renderableForEntityId(entityId);
5856 if (!entityItemRenderable) {
5857 _keyboardFocusWaitingOnRenderable = true;
5858 } else if (entityItemRenderable->wantsKeyboardFocus()) {
5838 entities->setProxyWindow(entityId, _window->windowHandle());5859 entities->setProxyWindow(entityId, _window->windowHandle());
5839 if (_keyboardMouseDevice->isActive()) {5860 if (_keyboardMouseDevice->isActive()) {
5840 _keyboardMouseDevice->pluginFocusOutEvent();5861 _keyboardMouseDevice->pluginFocusOutEvent();
@@ -6938,7 +6959,7 @@ void Application::clearDomainOctreeDetails(bool clearAll) { · 1097 unmodified lines
6938 });6959 });
6939 6960
6940 // reset the model renderer6961 // reset the model renderer
6941 clearAll ? getEntities()->clear() : getEntities()->clearNonLocalEntities();6962 clearAll ? getEntities()->clear() : getEntities()->clearDomainAndNonOwnedEntities();
6942 6963
6943 auto skyStage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage();6964 auto skyStage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage();
6944 6965
@@ -9145,6 +9166,8 @@ void Application::beforeEnterBackground() { · 2200 unmodified lines
9145 clearDomainOctreeDetails();9166 clearDomainOctreeDetails();
9146}9167}
9147 9168
9169
9170
9148void Application::enterBackground() {9171void Application::enterBackground() {
9149 QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(),9172 QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(),
9150 "stop", Qt::BlockingQueuedConnection);9173 "stop", Qt::BlockingQueuedConnection);
@@ -9168,6 +9191,15 @@ void Application::enterForeground() { · 17 unmodified lines
9168 auto nodeList = DependencyManager::get<NodeList>();9191 auto nodeList = DependencyManager::get<NodeList>();
9169 nodeList->setSendDomainServerCheckInEnabled(true);9192 nodeList->setSendDomainServerCheckInEnabled(true);
9170}9193}
9194
9195
9196void Application::toggleAwayMode(){
9197 QKeyEvent event = QKeyEvent (QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier);
9198 QCoreApplication::sendEvent (this, &event);
9199}
9200
9201
9171#endif9202#endif
9172 9203
9204
9173#include "Application.moc"9205#include "Application.moc"