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
246246
247247 #include "AboutUtil.h"
248248
249+#include <DisableDeferred.h>
250+
249251 #if defined(Q_OS_WIN)
250252 #include <VersionHelpers.h>
251253
@@ -289,13 +291,6 @@ static const QString DISABLE_WATCHDOG_FLAG{ "HIFI_DISABLE_WATCHDOG" }; · 37 unmodified lines
289291 static bool DISABLE_WATCHDOG = nsightActive() || QProcessEnvironment::systemEnvironment().contains(DISABLE_WATCHDOG_FLAG);
290292 #endif
291293
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−
299294 #if !defined(Q_OS_ANDROID)
300295 static const uint32_t MAX_CONCURRENT_RESOURCE_DOWNLOADS = 16;
301296 #else
@@ -759,6 +754,11 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { · 457 unmodified lines
759754 bool isStore = cmdOptionExists(argc, const_cast<const char**>(argv), OCULUS_STORE_ARG);
760755 qApp->setProperty(hifi::properties::OCULUS_STORE, isStore);
761756
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+
762762 // Ignore any previous crashes if running from command line with a test script.
763763 bool inTestMode { false };
764764 for (int i = 0; i < argc; ++i) {
@@ -1065,6 +1065,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 300 unmodified lines
10651065 connect(PluginManager::getInstance().data(), &PluginManager::inputDeviceRunningChanged,
10661066 controllerScriptingInterface, &controller::ScriptingInterface::updateRunningInputDevices);
10671067
1068+ EntityTree::setEntityClicksCapturedOperator([this] {
1069+ return _controllerScriptingInterface->areEntityClicksCaptured();
1070+ });
1071+
10681072 _entityClipboard->createRootElement();
10691073
10701074 #ifdef Q_OS_WIN
@@ -1079,6 +1083,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 8 unmodified lines
10791083 QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "fonts/FiraSans-SemiBold.ttf");
10801084 QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "fonts/Raleway-Light.ttf");
10811085 QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "fonts/Raleway-Regular.ttf");
1086+ QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "fonts/rawline-500.ttf");
10821087 QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "fonts/Raleway-Bold.ttf");
10831088 QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "fonts/Raleway-SemiBold.ttf");
10841089 QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "fonts/Cairo-SemiBold.ttf");
@@ -1766,6 +1771,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 681 unmodified lines
17661771 #endif
17671772 });
17681773
1774+
17691775 // Setup the _keyboardMouseDevice, _touchscreenDevice, _touchscreenVirtualPadDevice and the user input mapper with the default bindings
17701776 userInputMapper->registerDevice(_keyboardMouseDevice->getInputDevice());
17711777 // 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
23502356 } else {
23512357 QObject::connect(webSurface.data(), &hifi::qml::OffscreenSurface::rootContextCreated, rootItemLoadedFunctor);
23522358 }
2359+ auto surfaceContext = webSurface->getSurfaceContext();
2360+ surfaceContext->setContextProperty("KeyboardScriptingInterface", DependencyManager::get<KeyboardScriptingInterface>().data());
23532361 } else {
23542362 // FIXME: the tablet should use the OffscreenQmlSurfaceCache
23552363 webSurface = QSharedPointer<OffscreenQmlSurface>(new OffscreenQmlSurface(), [](OffscreenQmlSurface* webSurface) {
@@ -2421,6 +2429,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 65 unmodified lines
24212429 connect(&AndroidHelper::instance(), &AndroidHelper::beforeEnterBackground, this, &Application::beforeEnterBackground);
24222430 connect(&AndroidHelper::instance(), &AndroidHelper::enterBackground, this, &Application::enterBackground);
24232431 connect(&AndroidHelper::instance(), &AndroidHelper::enterForeground, this, &Application::enterForeground);
2432+ connect(&AndroidHelper::instance(), &AndroidHelper::toggleAwayMode, this, &Application::toggleAwayMode);
24242433 AndroidHelper::instance().notifyLoadComplete();
24252434 #endif
24262435 pauseUntilLoginDetermined();
@@ -3031,6 +3040,10 @@ void Application::initializeUi() { · 604 unmodified lines
30313040 };
30323041 OffscreenQmlSurface::addWhitelistContextHandler({
30333042 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" },
30343047 }, platformInfoCallback);
30353048
30363049 QmlContextCallback ttsCallback = [](QQmlContext* context) {
@@ -3285,6 +3298,7 @@ void Application::setupQmlSurface(QQmlContext* surfaceContext, bool setAdditiona · 248 unmodified lines
32853298 surfaceContext->setContextProperty("MyAvatar", DependencyManager::get<AvatarManager>()->getMyAvatar().get());
32863299 surfaceContext->setContextProperty("Entities", DependencyManager::get<EntityScriptingInterface>().data());
32873300 surfaceContext->setContextProperty("Snapshot", DependencyManager::get<Snapshot>().data());
3301+ surfaceContext->setContextProperty("KeyboardScriptingInterface", DependencyManager::get<KeyboardScriptingInterface>().data());
32883302
32893303 if (setAdditionalContextProperties) {
32903304 auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
@@ -3295,7 +3309,6 @@ void Application::setupQmlSurface(QQmlContext* surfaceContext, bool setAdditiona · 4 unmodified lines
32953309
32963310 surfaceContext->setContextProperty("Settings", SettingsScriptingInterface::getInstance());
32973311 surfaceContext->setContextProperty("MenuInterface", MenuScriptingInterface::getInstance());
3298− surfaceContext->setContextProperty("KeyboardScriptingInterface", DependencyManager::get<KeyboardScriptingInterface>().data());
32993312
33003313 surfaceContext->setContextProperty("Account", AccountServicesScriptingInterface::getInstance()); // DEPRECATED - TO BE REMOVED
33013314 surfaceContext->setContextProperty("GlobalServices", AccountServicesScriptingInterface::getInstance()); // DEPRECATED - TO BE REMOVED
@@ -3671,8 +3684,8 @@ void Application::handleSandboxStatus(QNetworkReply* reply) { · 369 unmodified lines
36713684 // If this is a first run we short-circuit the address passed in
36723685 if (_firstRun.get()) {
36733686 #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;
36763689 #endif
36773690 _firstRun.set(false);
36783691
@@ -3783,9 +3796,12 @@ std::map<QString, QString> Application::prepareServerlessDomainContents(QUrl dom · 104 unmodified lines
37833796 tmpTree->reaverageOctreeElements();
37843797 tmpTree->sendEntities(&_entityEditSender, getEntities()->getTree(), 0, 0, 0);
37853798 }
3799+ std::map<QString, QString> namedPaths = tmpTree->getNamedPaths();
37863800
3787− return tmpTree->getNamedPaths();
3801+ // we must manually eraseAllOctreeElements(false) else the tmpTree will mem-leak
3802+ tmpTree->eraseAllOctreeElements(false);
37883803
3804+ return namedPaths;
37893805 }
37903806
37913807 void Application::loadServerlessDomain(QUrl domainURL) {
@@ -4396,7 +4412,6 @@ void Application::mouseMoveEvent(QMouseEvent* event) { · 604 unmodified lines
43964412 if (compositor.getReticleVisible() || !isHMDMode() || !compositor.getReticleOverDesktop() ||
43974413 getOverlays().getOverlayAtPoint(glm::vec2(transformedPos.x(), transformedPos.y())) != UNKNOWN_ENTITY_ID) {
43984414 getEntities()->mouseMoveEvent(&mappedEvent);
4399− getOverlays().mouseMoveEvent(&mappedEvent);
44004415 }
44014416
44024417 _controllerScriptingInterface->emitMouseMoveEvent(&mappedEvent); // send events to any registered scripts
@@ -4430,14 +4445,8 @@ void Application::mousePressEvent(QMouseEvent* event) { · 27 unmodified lines
44304445 #endif
44314446
44324447 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);
44414450
44424451 _controllerScriptingInterface->emitMousePressEvent(&mappedEvent); // send events to any registered scripts
44434452
@@ -4476,11 +4485,7 @@ void Application::mouseDoublePressEvent(QMouseEvent* event) { · 32 unmodified lines
44764485 transformedPos,
44774486 event->screenPos(), event->button(),
44784487 event->buttons(), event->modifiers());
4479−
4480− if (!_controllerScriptingInterface->areEntityClicksCaptured()) {
4481− getEntities()->mouseDoublePressEvent(&mappedEvent);
4482− }
4483− getOverlays().mouseDoublePressEvent(&mappedEvent);
4488+ getEntities()->mouseDoublePressEvent(&mappedEvent);
44844489
44854490 // if one of our scripts have asked to capture this event, then stop processing it
44864491 if (_controllerScriptingInterface->isMouseCaptured()) {
@@ -4505,7 +4510,6 @@ void Application::mouseReleaseEvent(QMouseEvent* event) { · 18 unmodified lines
45054510 event->buttons(), event->modifiers());
45064511
45074512 getEntities()->mouseReleaseEvent(&mappedEvent);
4508− getOverlays().mouseReleaseEvent(&mappedEvent);
45094513
45104514 _controllerScriptingInterface->emitMouseReleaseEvent(&mappedEvent); // send events to any registered scripts
45114515
@@ -4989,6 +4993,15 @@ void Application::idle() { · 477 unmodified lines
49894993 }
49904994 }
49914995
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+
49925005 {
49935006 PerformanceTimer perfTimer("pluginIdle");
49945007 PerformanceWarning warn(showWarnings, "Application::idle()... pluginIdle()");
@@ -5771,6 +5784,11 @@ void Application::reloadResourceCaches() { · 776 unmodified lines
57715784
57725785 DependencyManager::get<NodeList>()->reset(); // Force redownload of .fst models
57735786
5787+ DependencyManager::get<ScriptEngines>()->reloadAllScripts();
5788+ getOffscreenUI()->clearCache();
5789+
5790+ DependencyManager::get<Keyboard>()->createKeyboard();
5791+
57745792 getMyAvatar()->resetFullAvatarURL();
57755793 }
57765794
@@ -5817,7 +5835,7 @@ void Application::setKeyboardFocusEntity(const QUuid& id) { · 40 unmodified lines
58175835 if (qApp->getLoginDialogPoppedUp() && !_loginDialogID.isNull()) {
58185836 if (id == _loginDialogID) {
58195837 emit loginDialogFocusEnabled();
5820− } else {
5838+ } else if (!_keyboardFocusWaitingOnRenderable) {
58215839 // that's the only entity we want in focus;
58225840 return;
58235841 }
@@ -5834,7 +5852,10 @@ void Application::setKeyboardFocusEntity(const QUuid& id) { · 10 unmodified lines
58345852 if (properties.getVisible()) {
58355853 auto entities = getEntities();
58365854 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()) {
58385859 entities->setProxyWindow(entityId, _window->windowHandle());
58395860 if (_keyboardMouseDevice->isActive()) {
58405861 _keyboardMouseDevice->pluginFocusOutEvent();
@@ -6938,7 +6959,7 @@ void Application::clearDomainOctreeDetails(bool clearAll) { · 1097 unmodified lines
69386959 });
69396960
69406961 // reset the model renderer
6941− clearAll ? getEntities()->clear() : getEntities()->clearNonLocalEntities();
6962+ clearAll ? getEntities()->clear() : getEntities()->clearDomainAndNonOwnedEntities();
69426963
69436964 auto skyStage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage();
69446965
@@ -9145,6 +9166,8 @@ void Application::beforeEnterBackground() { · 2200 unmodified lines
91459166 clearDomainOctreeDetails();
91469167 }
91479168
9169+
9170+
91489171 void Application::enterBackground() {
91499172 QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(),
91509173 "stop", Qt::BlockingQueuedConnection);
@@ -9168,6 +9191,15 @@ void Application::enterForeground() { · 17 unmodified lines
91689191 auto nodeList = DependencyManager::get<NodeList>();
91699192 nodeList->setSendDomainServerCheckInEnabled(true);
91709193 }
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+
91719202 #endif
91729203
9204+
91739205 #include "Application.moc"