Showing the changes to interface/src/Application.cpp (1 of 321 files). Show all
Unified · Split
| @@ -246,6 +246,8 @@ · 245 unmodified lines | ||
| 246 | 246 | |
| 247 | 247 | #include "AboutUtil.h" |
| 248 | 248 | |
| 249 | +#include <DisableDeferred.h> | |
| 250 | + | |
| 249 | 251 | #if defined(Q_OS_WIN) |
| 250 | 252 | #include <VersionHelpers.h> |
| 251 | 253 | |
| @@ -289,13 +291,6 @@ static const QString DISABLE_WATCHDOG_FLAG{ "HIFI_DISABLE_WATCHDOG" }; · 37 unmodified lines | ||
| 289 | 291 | static bool DISABLE_WATCHDOG = nsightActive() || QProcessEnvironment::systemEnvironment().contains(DISABLE_WATCHDOG_FLAG); |
| 290 | 292 | #endif |
| 291 | 293 | |
| 292 | −#if defined(USE_GLES) | |
| 293 | −static bool DISABLE_DEFERRED = true; | |
| 294 | −#else | |
| 295 | −static const QString RENDER_FORWARD{ "HIFI_RENDER_FORWARD" }; | |
| 296 | −static bool DISABLE_DEFERRED = QProcessEnvironment::systemEnvironment().contains(RENDER_FORWARD); | |
| 297 | −#endif | |
| 298 | − | |
| 299 | 294 | #if !defined(Q_OS_ANDROID) |
| 300 | 295 | static const uint32_t MAX_CONCURRENT_RESOURCE_DOWNLOADS = 16; |
| 301 | 296 | #else |
| @@ -759,6 +754,11 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { · 457 unmodified lines | ||
| 759 | 754 | bool isStore = cmdOptionExists(argc, const_cast<const char**>(argv), OCULUS_STORE_ARG); |
| 760 | 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 | 762 | // Ignore any previous crashes if running from command line with a test script. |
| 763 | 763 | bool inTestMode { false }; |
| 764 | 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 | 1065 | connect(PluginManager::getInstance().data(), &PluginManager::inputDeviceRunningChanged, |
| 1066 | 1066 | controllerScriptingInterface, &controller::ScriptingInterface::updateRunningInputDevices); |
| 1067 | 1067 | |
| 1068 | + EntityTree::setEntityClicksCapturedOperator([this] { | |
| 1069 | + return _controllerScriptingInterface->areEntityClicksCaptured(); | |
| 1070 | + }); | |
| 1071 | + | |
| 1068 | 1072 | _entityClipboard->createRootElement(); |
| 1069 | 1073 | |
| 1070 | 1074 | #ifdef Q_OS_WIN |
| @@ -1079,6 +1083,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 8 unmodified lines | ||
| 1079 | 1083 | QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "fonts/FiraSans-SemiBold.ttf"); |
| 1080 | 1084 | QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "fonts/Raleway-Light.ttf"); |
| 1081 | 1085 | QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "fonts/Raleway-Regular.ttf"); |
| 1086 | + QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "fonts/rawline-500.ttf"); | |
| 1082 | 1087 | QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "fonts/Raleway-Bold.ttf"); |
| 1083 | 1088 | QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "fonts/Raleway-SemiBold.ttf"); |
| 1084 | 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 | 1771 | #endif |
| 1767 | 1772 | }); |
| 1768 | 1773 | |
| 1774 | + | |
| 1769 | 1775 | // Setup the _keyboardMouseDevice, _touchscreenDevice, _touchscreenVirtualPadDevice and the user input mapper with the default bindings |
| 1770 | 1776 | userInputMapper->registerDevice(_keyboardMouseDevice->getInputDevice()); |
| 1771 | 1777 | // 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 | 2356 | } else { |
| 2351 | 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 | 2361 | } else { |
| 2354 | 2362 | // FIXME: the tablet should use the OffscreenQmlSurfaceCache |
| 2355 | 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 | 2429 | connect(&AndroidHelper::instance(), &AndroidHelper::beforeEnterBackground, this, &Application::beforeEnterBackground); |
| 2422 | 2430 | connect(&AndroidHelper::instance(), &AndroidHelper::enterBackground, this, &Application::enterBackground); |
| 2423 | 2431 | connect(&AndroidHelper::instance(), &AndroidHelper::enterForeground, this, &Application::enterForeground); |
| 2432 | + connect(&AndroidHelper::instance(), &AndroidHelper::toggleAwayMode, this, &Application::toggleAwayMode); | |
| 2424 | 2433 | AndroidHelper::instance().notifyLoadComplete(); |
| 2425 | 2434 | #endif |
| 2426 | 2435 | pauseUntilLoginDetermined(); |
| @@ -3031,6 +3040,10 @@ void Application::initializeUi() { · 604 unmodified lines | ||
| 3031 | 3040 | }; |
| 3032 | 3041 | OffscreenQmlSurface::addWhitelistContextHandler({ |
| 3033 | 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 | 3047 | }, platformInfoCallback); |
| 3035 | 3048 | |
| 3036 | 3049 | QmlContextCallback ttsCallback = [](QQmlContext* context) { |
| @@ -3285,6 +3298,7 @@ void Application::setupQmlSurface(QQmlContext* surfaceContext, bool setAdditiona · 248 unmodified lines | ||
| 3285 | 3298 | surfaceContext->setContextProperty("MyAvatar", DependencyManager::get<AvatarManager>()->getMyAvatar().get()); |
| 3286 | 3299 | surfaceContext->setContextProperty("Entities", DependencyManager::get<EntityScriptingInterface>().data()); |
| 3287 | 3300 | surfaceContext->setContextProperty("Snapshot", DependencyManager::get<Snapshot>().data()); |
| 3301 | + surfaceContext->setContextProperty("KeyboardScriptingInterface", DependencyManager::get<KeyboardScriptingInterface>().data()); | |
| 3288 | 3302 | |
| 3289 | 3303 | if (setAdditionalContextProperties) { |
| 3290 | 3304 | auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>(); |
| @@ -3295,7 +3309,6 @@ void Application::setupQmlSurface(QQmlContext* surfaceContext, bool setAdditiona · 4 unmodified lines | ||
| 3295 | 3309 | |
| 3296 | 3310 | surfaceContext->setContextProperty("Settings", SettingsScriptingInterface::getInstance()); |
| 3297 | 3311 | surfaceContext->setContextProperty("MenuInterface", MenuScriptingInterface::getInstance()); |
| 3298 | − surfaceContext->setContextProperty("KeyboardScriptingInterface", DependencyManager::get<KeyboardScriptingInterface>().data()); | |
| 3299 | 3312 | |
| 3300 | 3313 | surfaceContext->setContextProperty("Account", AccountServicesScriptingInterface::getInstance()); // DEPRECATED - TO BE REMOVED |
| 3301 | 3314 | surfaceContext->setContextProperty("GlobalServices", AccountServicesScriptingInterface::getInstance()); // DEPRECATED - TO BE REMOVED |
| @@ -3671,8 +3684,8 @@ void Application::handleSandboxStatus(QNetworkReply* reply) { · 369 unmodified lines | ||
| 3671 | 3684 | // If this is a first run we short-circuit the address passed in |
| 3672 | 3685 | if (_firstRun.get()) { |
| 3673 | 3686 | #if !defined(Q_OS_ANDROID) |
| 3674 | − DependencyManager::get<AddressManager>()->goToEntry(); | |
| 3675 | − sentTo = SENT_TO_ENTRY; | |
| 3687 | + DependencyManager::get<AddressManager>()->goToEntry(); | |
| 3688 | + sentTo = SENT_TO_ENTRY; | |
| 3676 | 3689 | #endif |
| 3677 | 3690 | _firstRun.set(false); |
| 3678 | 3691 | |
| @@ -3783,9 +3796,12 @@ std::map<QString, QString> Application::prepareServerlessDomainContents(QUrl dom · 104 unmodified lines | ||
| 3783 | 3796 | tmpTree->reaverageOctreeElements(); |
| 3784 | 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 | |
| 3791 | 3807 | void Application::loadServerlessDomain(QUrl domainURL) { |
| @@ -4396,7 +4412,6 @@ void Application::mouseMoveEvent(QMouseEvent* event) { · 604 unmodified lines | ||
| 4396 | 4412 | if (compositor.getReticleVisible() || !isHMDMode() || !compositor.getReticleOverDesktop() || |
| 4397 | 4413 | getOverlays().getOverlayAtPoint(glm::vec2(transformedPos.x(), transformedPos.y())) != UNKNOWN_ENTITY_ID) { |
| 4398 | 4414 | getEntities()->mouseMoveEvent(&mappedEvent); |
| 4399 | − getOverlays().mouseMoveEvent(&mappedEvent); | |
| 4400 | 4415 | } |
| 4401 | 4416 | |
| 4402 | 4417 | _controllerScriptingInterface->emitMouseMoveEvent(&mappedEvent); // send events to any registered scripts |
| @@ -4430,14 +4445,8 @@ void Application::mousePressEvent(QMouseEvent* event) { · 27 unmodified lines | ||
| 4430 | 4445 | #endif |
| 4431 | 4446 | |
| 4432 | 4447 | QMouseEvent mappedEvent(event->type(), transformedPos, event->screenPos(), event->button(), event->buttons(), event->modifiers()); |
| 4433 | − std::pair<float, QUuid> entityResult; | |
| 4434 | − if (!_controllerScriptingInterface->areEntityClicksCaptured()) { | |
| 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); | |
| 4448 | + QUuid result = getEntities()->mousePressEvent(&mappedEvent); | |
| 4449 | + setKeyboardFocusEntity(getEntities()->wantsKeyboardFocus(result) ? result : UNKNOWN_ENTITY_ID); | |
| 4441 | 4450 | |
| 4442 | 4451 | _controllerScriptingInterface->emitMousePressEvent(&mappedEvent); // send events to any registered scripts |
| 4443 | 4452 | |
| @@ -4476,11 +4485,7 @@ void Application::mouseDoublePressEvent(QMouseEvent* event) { · 32 unmodified lines | ||
| 4476 | 4485 | transformedPos, |
| 4477 | 4486 | event->screenPos(), event->button(), |
| 4478 | 4487 | event->buttons(), event->modifiers()); |
| 4479 | − | |
| 4480 | − if (!_controllerScriptingInterface->areEntityClicksCaptured()) { | |
| 4481 | − getEntities()->mouseDoublePressEvent(&mappedEvent); | |
| 4482 | − } | |
| 4483 | − getOverlays().mouseDoublePressEvent(&mappedEvent); | |
| 4488 | + getEntities()->mouseDoublePressEvent(&mappedEvent); | |
| 4484 | 4489 | |
| 4485 | 4490 | // if one of our scripts have asked to capture this event, then stop processing it |
| 4486 | 4491 | if (_controllerScriptingInterface->isMouseCaptured()) { |
| @@ -4505,7 +4510,6 @@ void Application::mouseReleaseEvent(QMouseEvent* event) { · 18 unmodified lines | ||
| 4505 | 4510 | event->buttons(), event->modifiers()); |
| 4506 | 4511 | |
| 4507 | 4512 | getEntities()->mouseReleaseEvent(&mappedEvent); |
| 4508 | − getOverlays().mouseReleaseEvent(&mappedEvent); | |
| 4509 | 4513 | |
| 4510 | 4514 | _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 | 5006 | PerformanceTimer perfTimer("pluginIdle"); |
| 4994 | 5007 | PerformanceWarning warn(showWarnings, "Application::idle()... pluginIdle()"); |
| @@ -5771,6 +5784,11 @@ void Application::reloadResourceCaches() { · 776 unmodified lines | ||
| 5771 | 5784 | |
| 5772 | 5785 | 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 | 5792 | getMyAvatar()->resetFullAvatarURL(); |
| 5775 | 5793 | } |
| 5776 | 5794 | |
| @@ -5817,7 +5835,7 @@ void Application::setKeyboardFocusEntity(const QUuid& id) { · 40 unmodified lines | ||
| 5817 | 5835 | if (qApp->getLoginDialogPoppedUp() && !_loginDialogID.isNull()) { |
| 5818 | 5836 | if (id == _loginDialogID) { |
| 5819 | 5837 | emit loginDialogFocusEnabled(); |
| 5820 | − } else { | |
| 5838 | + } else if (!_keyboardFocusWaitingOnRenderable) { | |
| 5821 | 5839 | // that's the only entity we want in focus; |
| 5822 | 5840 | return; |
| 5823 | 5841 | } |
| @@ -5834,7 +5852,10 @@ void Application::setKeyboardFocusEntity(const QUuid& id) { · 10 unmodified lines | ||
| 5834 | 5852 | if (properties.getVisible()) { |
| 5835 | 5853 | auto entities = getEntities(); |
| 5836 | 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 | 5859 | entities->setProxyWindow(entityId, _window->windowHandle()); |
| 5839 | 5860 | if (_keyboardMouseDevice->isActive()) { |
| 5840 | 5861 | _keyboardMouseDevice->pluginFocusOutEvent(); |
| @@ -6938,7 +6959,7 @@ void Application::clearDomainOctreeDetails(bool clearAll) { · 1097 unmodified lines | ||
| 6938 | 6959 | }); |
| 6939 | 6960 | |
| 6940 | 6961 | // reset the model renderer |
| 6941 | − clearAll ? getEntities()->clear() : getEntities()->clearNonLocalEntities(); | |
| 6962 | + clearAll ? getEntities()->clear() : getEntities()->clearDomainAndNonOwnedEntities(); | |
| 6942 | 6963 | |
| 6943 | 6964 | auto skyStage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage(); |
| 6944 | 6965 | |
| @@ -9145,6 +9166,8 @@ void Application::beforeEnterBackground() { · 2200 unmodified lines | ||
| 9145 | 9166 | clearDomainOctreeDetails(); |
| 9146 | 9167 | } |
| 9147 | 9168 | |
| 9169 | + | |
| 9170 | + | |
| 9148 | 9171 | void Application::enterBackground() { |
| 9149 | 9172 | QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), |
| 9150 | 9173 | "stop", Qt::BlockingQueuedConnection); |
| @@ -9168,6 +9191,15 @@ void Application::enterForeground() { · 17 unmodified lines | ||
| 9168 | 9191 | auto nodeList = DependencyManager::get<NodeList>(); |
| 9169 | 9192 | nodeList->setSendDomainServerCheckInEnabled(true); |
| 9170 | 9193 | } |
| 9194 | + | |
| 9195 | + | |
| 9196 | +void Application::toggleAwayMode(){ | |
| 9197 | + QKeyEvent event = QKeyEvent (QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier); | |
| 9198 | + QCoreApplication::sendEvent (this, &event); | |
| 9199 | +} | |
| 9200 | + | |
| 9201 | + | |
| 9171 | 9202 | #endif |
| 9172 | 9203 | |
| 9204 | + | |
| 9173 | 9205 | #include "Application.moc" |