History

Merge remote-tracking branch 'upstream/master' into switch

SamGondelman committed 7 years ago

Commit 59e7db22 parents 4a02ab4 4ee393594 files · +2124 −894Browse files

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

Unified · Split

interface/src/Application.cpp+107−58
@@ -136,7 +136,6 @@ · 135 unmodified lines
136136 #include <SoundCacheScriptingInterface.h>
137137 #include <ui/TabletScriptingInterface.h>
138138 #include <ui/ToolbarScriptingInterface.h>
139−#include <InteractiveWindow.h>
140139 #include <Tooltip.h>
141140 #include <udt/PacketHeaders.h>
142141 #include <UserActivityLogger.h>
@@ -213,6 +212,7 @@ · 70 unmodified lines
213212 #include "ui/UpdateDialog.h"
214213 #include "ui/DomainConnectionModel.h"
215214 #include "ui/Keyboard.h"
215+#include "ui/InteractiveWindow.h"
216216 #include "Util.h"
217217 #include "InterfaceParentFinder.h"
218218 #include "ui/OctreeStatsProvider.h"
@@ -374,7 +374,12 @@ const std::vector<std::pair<QString, Application::AcceptURLMethod>> Application: · 155 unmodified lines
374374 class DeadlockWatchdogThread : public QThread {
375375 public:
376376 static const unsigned long HEARTBEAT_UPDATE_INTERVAL_SECS = 1;
377+ // TODO: go back to 2 min across the board, after figuring out the issues with mac
378+#if defined(Q_OS_MAC)
379+ static const unsigned long MAX_HEARTBEAT_AGE_USECS = 600 * USECS_PER_SECOND; // 10 mins with no checkin probably a deadlock, right now, on MAC
380+#else
377381 static const unsigned long MAX_HEARTBEAT_AGE_USECS = 120 * USECS_PER_SECOND; // 2 mins with no checkin probably a deadlock
382+#endif
378383 static const int WARNING_ELAPSED_HEARTBEAT = 500 * USECS_PER_MSEC; // warn if elapsed heartbeat average is large
379384 static const int HEARTBEAT_SAMPLES = 100000; // ~5 seconds worth of samples
380385
@@ -554,7 +559,10 @@ public: · 173 unmodified lines
554559 return true;
555560 }
556561 }
557−
562+ // Attempting to close MIDI interfaces of a hot-unplugged device can result in audio-driver deadlock.
563+ // Detecting MIDI devices that have been added/removed after starting Inteface has been disabled.
564+ // https://support.microsoft.com/en-us/help/4460006/midi-device-app-hangs-when-former-midi-api-is-used
565+#if 0
558566 if (message->message == WM_DEVICECHANGE) {
559567 const float MIN_DELTA_SECONDS = 2.0f; // de-bounce signal
560568 static float lastTriggerTime = 0.0f;
@@ -564,6 +572,7 @@ public: · 3 unmodified lines
564572 Midi::USBchanged(); // re-scan the MIDI bus
565573 }
566574 }
575+#endif
567576 }
568577 return false;
569578 }
@@ -661,9 +670,10 @@ private: · 91 unmodified lines
661670
662671 /**jsdoc
663672 * <p>The <code>Controller.Hardware.Application</code> object has properties representing Interface's state. The property
664− * values are integer IDs, uniquely identifying each output. <em>Read-only.</em> These can be mapped to actions or functions or
665− * <code>Controller.Standard</code> items in a {@link RouteObject} mapping (e.g., using the {@link RouteObject#when} method).
666− * Each data value is either <code>1.0</code> for "true" or <code>0.0</code> for "false".</p>
673+ * values are integer IDs, uniquely identifying each output. <em>Read-only.</em></p>
674+ * <p>These states can be mapped to actions or functions or <code>Controller.Standard</code> items in a {@link RouteObject}
675+ * mapping (e.g., using the {@link RouteObject#when} method). Each data value is either <code>1.0</code> for "true" or
676+ * <code>0.0</code> for "false".</p>
667677 * <table>
668678 * <thead>
669679 * <tr><th>Property</th><th>Type</th><th>Data</th><th>Description</th></tr>
@@ -677,13 +687,17 @@ private: · 7 unmodified lines
677687 * <tr><td><code>CameraIndependent</code></td><td>number</td><td>number</td><td>The camera is in independent mode.</td></tr>
678688 * <tr><td><code>CameraEntity</code></td><td>number</td><td>number</td><td>The camera is in entity mode.</td></tr>
679689 * <tr><td><code>InHMD</code></td><td>number</td><td>number</td><td>The user is in HMD mode.</td></tr>
680− * <tr><td><code>AdvancedMovement</code></td><td>number</td><td>number</td><td>Advanced movement controls are enabled.
681− * </td></tr>
690+ * <tr><td><code>AdvancedMovement</code></td><td>number</td><td>number</td><td>Advanced movement (walking) controls are
691+ * enabled.</td></tr>
692+ * <tr><td><code>StrafeEnabled</code></td><td>number</td><td>number</td><td>Strafing is enabled</td></tr>
682693 * <tr><td><code>LeftHandDominant</code></td><td>number</td><td>number</td><td>Dominant hand set to left.</td></tr>
683694 * <tr><td><code>RightHandDominant</code></td><td>number</td><td>number</td><td>Dominant hand set to right.</td></tr>
684695 * <tr><td><code>SnapTurn</code></td><td>number</td><td>number</td><td>Snap turn is enabled.</td></tr>
685696 * <tr><td><code>Grounded</code></td><td>number</td><td>number</td><td>The user's avatar is on the ground.</td></tr>
686697 * <tr><td><code>NavigationFocused</code></td><td>number</td><td>number</td><td><em>Not used.</em></td></tr>
698+ * <tr><td><code>PlatformWindows</code></td><td>number</td><td>number</td><td>The operating system is Windows.</td></tr>
699+ * <tr><td><code>PlatformMac</code></td><td>number</td><td>number</td><td>The operating system is Mac.</td></tr>
700+ * <tr><td><code>PlatformAndroid</code></td><td>number</td><td>number</td><td>The operating system is Android.</td></tr>
687701 * </tbody>
688702 * </table>
689703 * @typedef {object} Controller.Hardware-Application
@@ -1052,6 +1066,14 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 362 unmodified lines
10521066 }
10531067 }
10541068
1069+ {
1070+ // identify gpu as early as possible to help identify OpenGL initialization errors.
1071+ auto gpuIdent = GPUIdent::getInstance();
1072+ setCrashAnnotation("gpu_name", gpuIdent->getName().toStdString());
1073+ setCrashAnnotation("gpu_driver", gpuIdent->getDriver().toStdString());
1074+ setCrashAnnotation("gpu_memory", std::to_string(gpuIdent->getMemory()));
1075+ }
1076+
10551077 // make sure the debug draw singleton is initialized on the main thread.
10561078 DebugDraw::getInstance().removeMarker("");
10571079
@@ -1327,7 +1349,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 269 unmodified lines
13271349 setCrashAnnotation("avatar", avatarURL.toString().toStdString());
13281350 });
13291351
1330−
13311352 // Inititalize sample before registering
13321353 _sampleSound = DependencyManager::get<SoundCache>()->getSound(PathUtils::resourcesUrl("sounds/sample.wav"));
13331354
@@ -1418,6 +1439,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 84 unmodified lines
14181439 initializeDisplayPlugins();
14191440 qCDebug(interfaceapp, "Initialized Display");
14201441
1442+ if (_displayPlugin && !_displayPlugin->isHmd()) {
1443+ _preferredCursor.set(Cursor::Manager::getIconName(Cursor::Icon::SYSTEM));
1444+ showCursor(Cursor::Manager::lookupIcon(_preferredCursor.get()));
1445+ }
14211446 // An audio device changed signal received before the display plugins are set up will cause a crash,
14221447 // so we defer the setup of the `scripting::Audio` class until this point
14231448 {
@@ -1437,8 +1462,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 13 unmodified lines
14371462 audioScriptingInterface->environmentMuted();
14381463 }
14391464 });
1440− connect(this, &Application::activeDisplayPluginChanged,
1441− reinterpret_cast<scripting::Audio*>(audioScriptingInterface.data()), &scripting::Audio::onContextChanged);
1465+ QSharedPointer<scripting::Audio> scriptingAudioSharedPointer = qSharedPointerDynamicCast<scripting::Audio>(DependencyManager::get<AudioScriptingInterface>());
1466+ if (scriptingAudioSharedPointer) {
1467+ connect(this, &Application::activeDisplayPluginChanged,
1468+ scriptingAudioSharedPointer.data(), &scripting::Audio::onContextChanged);
1469+ }
14421470 }
14431471
14441472 // Create the rendering engine. This can be slow on some machines due to lots of
@@ -1631,7 +1659,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 186 unmodified lines
16311659 connect(userInputMapper.data(), &UserInputMapper::actionEvent, [this](int action, float state) {
16321660 using namespace controller;
16331661 auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
1634− auto audioScriptingInterface = reinterpret_cast<scripting::Audio*>(DependencyManager::get<AudioScriptingInterface>().data());
1662+ QSharedPointer<scripting::Audio> audioScriptingInterface = qSharedPointerDynamicCast<scripting::Audio>(DependencyManager::get<AudioScriptingInterface>());
16351663 {
16361664 auto actionEnum = static_cast<Action>(action);
16371665 int key = Qt::Key_unknown;
@@ -1639,10 +1667,12 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 1 unmodified line
16391667 bool navAxis = false;
16401668 switch (actionEnum) {
16411669 case Action::TOGGLE_PUSHTOTALK:
1642− if (state > 0.0f) {
1643− audioScriptingInterface->setPushingToTalk(true);
1644− } else if (state <= 0.0f) {
1645− audioScriptingInterface->setPushingToTalk(false);
1670+ if (audioScriptingInterface) {
1671+ if (state > 0.0f) {
1672+ audioScriptingInterface->setPushingToTalk(true);
1673+ } else if (state <= 0.0f) {
1674+ audioScriptingInterface->setPushingToTalk(false);
1675+ }
16461676 }
16471677 break;
16481678
@@ -2764,14 +2794,14 @@ Application::~Application() { · 1115 unmodified lines
27642794 avatarManager->handleProcessedPhysicsTransaction(transaction);
27652795
27662796 avatarManager->deleteAllAvatars();
2767−
2797+
27682798 auto myCharacterController = getMyAvatar()->getCharacterController();
27692799 myCharacterController->clearDetailedMotionStates();
2770−
2800+
27712801 myCharacterController->buildPhysicsTransaction(transaction);
27722802 _physicsEngine->processTransaction(transaction);
27732803 myCharacterController->handleProcessedPhysicsTransaction(transaction);
2774−
2804+
27752805 _physicsEngine->setCharacterController(nullptr);
27762806
27772807 // the _shapeManager should have zero references
@@ -2903,7 +2933,7 @@ void Application::initializeGL() { · 125 unmodified lines
29032933
29042934 #if !defined(DISABLE_QML)
29052935 QStringList chromiumFlags;
2906− // Bug 21993: disable microphone and camera input
2936+ // Bug 21993: disable microphone and camera input
29072937 chromiumFlags << "--use-fake-device-for-media-stream";
29082938 // Disable signed distance field font rendering on ATI/AMD GPUs, due to
29092939 // https://highfidelity.manuscript.com/f/cases/13677/Text-showing-up-white-on-Marketplace-app
@@ -3374,6 +3404,7 @@ void Application::setupQmlSurface(QQmlContext* surfaceContext, bool setAdditiona · 464 unmodified lines
33743404 surfaceContext->setContextProperty("KeyboardScriptingInterface", DependencyManager::get<KeyboardScriptingInterface>().data());
33753405
33763406 if (setAdditionalContextProperties) {
3407+ qDebug() << "setting additional context properties!";
33773408 auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
33783409 auto flags = tabletScriptingInterface->getFlags();
33793410
@@ -3588,7 +3619,14 @@ void Application::setPreferAvatarFingerOverStylus(bool value) { · 208 unmodified lines
35883619
35893620 void Application::setPreferredCursor(const QString& cursorName) {
35903621 qCDebug(interfaceapp) << "setPreferredCursor" << cursorName;
3591− _preferredCursor.set(cursorName.isEmpty() ? DEFAULT_CURSOR_NAME : cursorName);
3622+
3623+ if (_displayPlugin && _displayPlugin->isHmd()) {
3624+ _preferredCursor.set(cursorName.isEmpty() ? DEFAULT_CURSOR_NAME : cursorName);
3625+ }
3626+ else {
3627+ _preferredCursor.set(cursorName.isEmpty() ? Cursor::Manager::getIconName(Cursor::Icon::SYSTEM) : cursorName);
3628+ }
3629+
35923630 showCursor(Cursor::Manager::lookupIcon(_preferredCursor.get()));
35933631 }
35943632
@@ -3992,8 +4030,8 @@ bool Application::notify(QObject * object, QEvent * event) { · 397 unmodified lines
39924030 if (thread() == QThread::currentThread()) {
39934031 PROFILE_RANGE_IF_LONGER(app, "notify", 2)
39944032 return QApplication::notify(object, event);
3995− }
3996−
4033+ }
4034+
39974035 return QApplication::notify(object, event);
39984036 }
39994037
@@ -4054,9 +4092,6 @@ bool Application::event(QEvent* event) { · 54 unmodified lines
40544092 case QEvent::KeyRelease:
40554093 keyReleaseEvent(static_cast<QKeyEvent*>(event));
40564094 return true;
4057− case QEvent::FocusIn:
4058− focusInEvent(static_cast<QFocusEvent*>(event));
4059− return true;
40604095 case QEvent::FocusOut:
40614096 focusOutEvent(static_cast<QFocusEvent*>(event));
40624097 return true;
@@ -4099,6 +4134,11 @@ bool Application::eventFilter(QObject* object, QEvent* event) { · 36 unmodified lines
40994134 return true;
41004135 }
41014136
4137+ auto eventType = event->type();
4138+ if (eventType == QEvent::KeyPress || eventType == QEvent::KeyRelease || eventType == QEvent::MouseMove) {
4139+ getRefreshRateManager().resetInactiveTimer();
4140+ }
4141+
41024142 if (event->type() == QEvent::Leave) {
41034143 getApplicationCompositor().handleLeaveEvent();
41044144 }
@@ -4288,6 +4328,10 @@ void Application::keyPressEvent(QKeyEvent* event) { · 183 unmodified lines
42884328 if (isMeta) {
42894329 auto audioClient = DependencyManager::get<AudioClient>();
42904330 audioClient->setMuted(!audioClient->isMuted());
4331+ QSharedPointer<scripting::Audio> audioScriptingInterface = qSharedPointerDynamicCast<scripting::Audio>(DependencyManager::get<AudioScriptingInterface>());
4332+ if (audioScriptingInterface && audioScriptingInterface->getPTT()) {
4333+ audioScriptingInterface->setPushingToTalk(!audioClient->isMuted());
4334+ }
42914335 }
42924336 break;
42934337
@@ -4410,13 +4454,6 @@ void Application::keyReleaseEvent(QKeyEvent* event) { · 116 unmodified lines
44104454
44114455 }
44124456
4413−void Application::focusInEvent(QFocusEvent* event) {
4414− if (!_aboutToQuit && _startUpFinished) {
4415− getRefreshRateManager().setRefreshRateRegime(RefreshRateManager::RefreshRateRegime::RUNNING);
4416− }
4417−}
4418−
4419−
44204457 void Application::focusOutEvent(QFocusEvent* event) {
44214458 auto inputPlugins = PluginManager::getInstance()->getInputPlugins();
44224459 foreach(auto inputPlugin, inputPlugins) {
@@ -4424,10 +4461,6 @@ void Application::focusOutEvent(QFocusEvent* event) { · 1 unmodified line
44244461 inputPlugin->pluginFocusOutEvent();
44254462 }
44264463 }
4427−
4428− if (!_aboutToQuit && _startUpFinished) {
4429− getRefreshRateManager().setRefreshRateRegime(RefreshRateManager::RefreshRateRegime::UNFOCUS);
4430− }
44314464 // FIXME spacemouse code still needs cleanup
44324465 #if 0
44334466 //SpacemouseDevice::getInstance().focusOutEvent();
@@ -5038,7 +5071,7 @@ void Application::idle() { · 604 unmodified lines
50385071 }
50395072 }
50405073 #endif
5041−
5074+
50425075 checkChangeCursor();
50435076
50445077 #if !defined(DISABLE_QML)
@@ -5349,8 +5382,10 @@ void Application::loadSettings() { · 304 unmodified lines
53495382 }
53505383 }
53515384
5352− auto audioScriptingInterface = reinterpret_cast<scripting::Audio*>(DependencyManager::get<AudioScriptingInterface>().data());
5353− audioScriptingInterface->loadData();
5385+ QSharedPointer<scripting::Audio> audioScriptingInterface = qSharedPointerDynamicCast<scripting::Audio>(DependencyManager::get<AudioScriptingInterface>());
5386+ if (audioScriptingInterface) {
5387+ audioScriptingInterface->loadData();
5388+ }
53545389
53555390 getMyAvatar()->loadData();
53565391 _settingsLoaded = true;
@@ -5361,8 +5396,10 @@ void Application::saveSettings() const { · 4 unmodified lines
53615396 DependencyManager::get<AudioClient>()->saveSettings();
53625397 DependencyManager::get<LODManager>()->saveSettings();
53635398
5364− auto audioScriptingInterface = reinterpret_cast<scripting::Audio*>(DependencyManager::get<AudioScriptingInterface>().data());
5365− audioScriptingInterface->saveData();
5399+ QSharedPointer<scripting::Audio> audioScriptingInterface = qSharedPointerDynamicCast<scripting::Audio>(DependencyManager::get<AudioScriptingInterface>());
5400+ if (audioScriptingInterface) {
5401+ audioScriptingInterface->saveData();
5402+ }
53665403
53675404 Menu::getInstance()->saveSettings();
53685405 getMyAvatar()->saveData();
@@ -5596,7 +5633,7 @@ void Application::resumeAfterLoginDialogActionTaken() { · 227 unmodified lines
55965633 _myCamera.setMode(_previousCameraMode);
55975634 cameraModeChanged();
55985635 _startUpFinished = true;
5599− getRefreshRateManager().setRefreshRateRegime(RefreshRateManager::RefreshRateRegime::RUNNING);
5636+ getRefreshRateManager().setRefreshRateRegime(RefreshRateManager::RefreshRateRegime::FOCUS_ACTIVE);
56005637 }
56015638
56025639 void Application::loadAvatarScripts(const QVector<QString>& urls) {
@@ -5801,7 +5838,8 @@ void Application::cameraModeChanged() { · 198 unmodified lines
58015838 Menu::getInstance()->setIsOptionChecked(MenuOption::FullscreenMirror, true);
58025839 break;
58035840 default:
5804− break;
5841+ // we don't have menu items for the others, so just leave it alone.
5842+ return;
58055843 }
58065844 cameraMenuChanged();
58075845 }
@@ -8453,28 +8491,30 @@ bool Application::takeSnapshotOperators(std::queue<SnapshotOperator>& snapshotOp · 2645 unmodified lines
84538491
84548492 void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRatio, const QString& filename) {
84558493 addSnapshotOperator(std::make_tuple([notify, includeAnimated, aspectRatio, filename](const QImage& snapshot) {
8456− QString path = DependencyManager::get<Snapshot>()->saveSnapshot(snapshot, filename, TestScriptingInterface::getInstance()->getTestResultsLocation());
8457−
8458− // If we're not doing an animated snapshot as well...
8459− if (!includeAnimated) {
8460− if (!path.isEmpty()) {
8461− // Tell the dependency manager that the capture of the still snapshot has taken place.
8462− emit DependencyManager::get<WindowScriptingInterface>()->stillSnapshotTaken(path, notify);
8463− }
8464− } else if (!SnapshotAnimated::isAlreadyTakingSnapshotAnimated()) {
8465− qApp->postLambdaEvent([path, aspectRatio] {
8494+ qApp->postLambdaEvent([snapshot, notify, includeAnimated, aspectRatio, filename] {
8495+ QString path = DependencyManager::get<Snapshot>()->saveSnapshot(snapshot, filename, TestScriptingInterface::getInstance()->getTestResultsLocation());
8496+
8497+ // If we're not doing an animated snapshot as well...
8498+ if (!includeAnimated) {
8499+ if (!path.isEmpty()) {
8500+ // Tell the dependency manager that the capture of the still snapshot has taken place.
8501+ emit DependencyManager::get<WindowScriptingInterface>()->stillSnapshotTaken(path, notify);
8502+ }
8503+ } else if (!SnapshotAnimated::isAlreadyTakingSnapshotAnimated()) {
84668504 // Get an animated GIF snapshot and save it
84678505 SnapshotAnimated::saveSnapshotAnimated(path, aspectRatio, DependencyManager::get<WindowScriptingInterface>());
8468− });
8469− }
8506+ }
8507+ });
84708508 }, aspectRatio, true));
84718509 }
84728510
84738511 void Application::takeSecondaryCameraSnapshot(const bool& notify, const QString& filename) {
84748512 addSnapshotOperator(std::make_tuple([notify, filename](const QImage& snapshot) {
8475− QString snapshotPath = DependencyManager::get<Snapshot>()->saveSnapshot(snapshot, filename, TestScriptingInterface::getInstance()->getTestResultsLocation());
8513+ qApp->postLambdaEvent([snapshot, notify, filename] {
8514+ QString snapshotPath = DependencyManager::get<Snapshot>()->saveSnapshot(snapshot, filename, TestScriptingInterface::getInstance()->getTestResultsLocation());
84768515
8477− emit DependencyManager::get<WindowScriptingInterface>()->stillSnapshotTaken(snapshotPath, notify);
8516+ emit DependencyManager::get<WindowScriptingInterface>()->stillSnapshotTaken(snapshotPath, notify);
8517+ });
84788518 }, 0.0f, false));
84798519 }
84808520
@@ -8539,11 +8579,20 @@ void Application::activeChanged(Qt::ApplicationState state) { · 58 unmodified lines
85398579 switch (state) {
85408580 case Qt::ApplicationActive:
85418581 _isForeground = true;
8582+ if (!_aboutToQuit && _startUpFinished) {
8583+ getRefreshRateManager().setRefreshRateRegime(RefreshRateManager::RefreshRateRegime::FOCUS_ACTIVE);
8584+ }
85428585 break;
85438586
85448587 case Qt::ApplicationSuspended:
8588+ break;
85458589 case Qt::ApplicationHidden:
8590+ break;
85468591 case Qt::ApplicationInactive:
8592+ if (!_aboutToQuit && _startUpFinished) {
8593+ getRefreshRateManager().setRefreshRateRegime(RefreshRateManager::RefreshRateRegime::UNFOCUS);
8594+ }
8595+ break;
85478596 default:
85488597 _isForeground = false;
85498598 break;
@@ -8874,7 +8923,7 @@ void Application::setDisplayPlugin(DisplayPluginPointer newDisplayPlugin) { · 324 unmodified lines
88748923 RefreshRateManager& refreshRateManager = getRefreshRateManager();
88758924 refreshRateManager.setRefreshRateOperator(OpenGLDisplayPlugin::getRefreshRateOperator());
88768925 bool isHmd = newDisplayPlugin->isHmd();
8877− RefreshRateManager::UXMode uxMode = isHmd ? RefreshRateManager::UXMode::HMD :
8926+ RefreshRateManager::UXMode uxMode = isHmd ? RefreshRateManager::UXMode::VR :
88788927 RefreshRateManager::UXMode::DESKTOP;
88798928
88808929 refreshRateManager.setUXMode(uxMode);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t