From 6228ff19bf2c9315b6edc01747a985301421e436 Mon Sep 17 00:00:00 2001 From: NeetBhagat Date: Fri, 2 Jun 2017 14:37:17 +0530 Subject: [PATCH] Resolve the reviewed comments of @ZappoMan --- interface/src/Application.cpp | 26 +++++++++---------- interface/src/Application.h | 2 +- .../display-plugins/OpenGLDisplayPlugin.cpp | 3 ++- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 8384204fb9..a3787847db 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1349,16 +1349,12 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo _autoSwitchDisplayModeSupportedHMDPlugin->getName(); _previousHMDWornStatus = _autoSwitchDisplayModeSupportedHMDPlugin->isDisplayVisible(); - qCDebug(interfaceapp) << "_autoSwitchModeSupportedPluginName::" - << _autoSwitchDisplayModeSupportedHMDPluginName; break; } } - if (_autoSwitchDisplayModeSupportedHMDPlugin != nullptr) { - // If HMD Plugin is available and current display plugin is not HMD plugin - // then startHMDStandBySession to poll HMD Worn status. - if (getActiveDisplayPlugin()->getName() != _autoSwitchDisplayModeSupportedHMDPluginName && + if (_autoSwitchDisplayModeSupportedHMDPlugin) { + if (getActiveDisplayPlugin() != _autoSwitchDisplayModeSupportedHMDPlugin && !_autoSwitchDisplayModeSupportedHMDPlugin->isStandBySessionActive()) { startHMDStandBySession(); } @@ -1600,7 +1596,7 @@ void Application::aboutToQuit() { } getActiveDisplayPlugin()->deactivate(); - if (_autoSwitchDisplayModeSupportedHMDPlugin != nullptr + if (_autoSwitchDisplayModeSupportedHMDPlugin && _autoSwitchDisplayModeSupportedHMDPlugin->isStandBySessionActive()) { _autoSwitchDisplayModeSupportedHMDPlugin->endStandBySession(); } @@ -6769,18 +6765,20 @@ void Application::updateDisplayMode() { } void Application::switchDisplayMode() { + if (!_autoSwitchDisplayModeSupportedHMDPlugin) { + return; + } bool currentHMDWornStatus = _autoSwitchDisplayModeSupportedHMDPlugin->isDisplayVisible(); if (currentHMDWornStatus != _previousHMDWornStatus) { - // Switch to respective mode as soon as currentHMDWornStatus changes - if (currentHMDWornStatus == false && _previousHMDWornStatus == true) { - qCDebug(interfaceapp) << "Switching from HMD to desktop mode"; - setActiveDisplayPlugin(DESKTOP_DISPLAY_PLUGIN_NAME); - startHMDStandBySession(); - } - if (currentHMDWornStatus == true && _previousHMDWornStatus == false) { + // Switch to respective mode as soon as currentHMDWornStatus changes + if (currentHMDWornStatus) { qCDebug(interfaceapp) << "Switching from Desktop to HMD mode"; endHMDStandBySession(); setActiveDisplayPlugin(_autoSwitchDisplayModeSupportedHMDPluginName); + } else { + qCDebug(interfaceapp) << "Switching from HMD to desktop mode"; + setActiveDisplayPlugin(DESKTOP_DISPLAY_PLUGIN_NAME); + startHMDStandBySession(); } } _previousHMDWornStatus = currentHMDWornStatus; diff --git a/interface/src/Application.h b/interface/src/Application.h index e1fb37ef3a..4cd47ada58 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -681,7 +681,7 @@ private: AudioInjector* _snapshotSoundInjector { nullptr }; SharedSoundPointer _snapshotSound; - DisplayPluginPointer _autoSwitchDisplayModeSupportedHMDPlugin = nullptr; + DisplayPluginPointer _autoSwitchDisplayModeSupportedHMDPlugin; QString _autoSwitchDisplayModeSupportedHMDPluginName; bool _previousHMDWornStatus; void startHMDStandBySession(); diff --git a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp index 3bdf9a672c..fbdc1ad71e 100644 --- a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp +++ b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp @@ -315,6 +315,7 @@ bool OpenGLDisplayPlugin::activate() { if (isHmd() && (getHmdScreen() >= 0)) { _container->showDisplayPluginsTools(); } + return Parent::activate(); } @@ -347,7 +348,7 @@ bool OpenGLDisplayPlugin::startStandBySession() { void OpenGLDisplayPlugin::endStandBySession() { deactivateStandBySession(); - return Parent::endStandBySession(); + Parent::endStandBySession(); } void OpenGLDisplayPlugin::customizeContext() {