From 177590614e2a5486c93a13e0ece1cc624c295c93 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Thu, 22 Aug 2019 11:44:09 -0700 Subject: [PATCH] Fix emote bar always visible on MacOS; small logic cleanup --- .../src/scripting/WindowScriptingInterface.cpp | 1 + .../src/scripting/WindowScriptingInterface.h | 11 +++++++++++ .../simplifiedEmote/simplifiedEmote.js | 15 ++++++++++++--- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/interface/src/scripting/WindowScriptingInterface.cpp b/interface/src/scripting/WindowScriptingInterface.cpp index 80c0479bd7..f4aa36e2f4 100644 --- a/interface/src/scripting/WindowScriptingInterface.cpp +++ b/interface/src/scripting/WindowScriptingInterface.cpp @@ -56,6 +56,7 @@ WindowScriptingInterface::WindowScriptingInterface() { }); connect(qApp->getWindow(), &MainWindow::windowGeometryChanged, this, &WindowScriptingInterface::onWindowGeometryChanged); + connect(qApp->getWindow(), &MainWindow::windowMinimizedChanged, this, &WindowScriptingInterface::minimizedChanged); connect(qApp, &Application::interstitialModeChanged, [this] (bool interstitialMode) { emit interstitialModeChanged(interstitialMode); }); diff --git a/interface/src/scripting/WindowScriptingInterface.h b/interface/src/scripting/WindowScriptingInterface.h index 010f3bcca2..6207b22cb8 100644 --- a/interface/src/scripting/WindowScriptingInterface.h +++ b/interface/src/scripting/WindowScriptingInterface.h @@ -814,6 +814,17 @@ signals: */ void geometryChanged(QRect geometry); + + /**jsdoc + * Triggered when "minimized" state of the Interface window changes. + * @function Window.minimizedChanged + * @param {bool} isMinimized - true if the Interface window is now minimized; false otherwise. + * @returns {Signal} + * + * Window.minimizedChanged.connect(onWindowMinimizedChanged); + */ + void minimizedChanged(bool isMinimized); + private: QString getPreviousBrowseLocation() const; void setPreviousBrowseLocation(const QString& location); diff --git a/scripts/simplifiedUI/simplifiedEmote/simplifiedEmote.js b/scripts/simplifiedUI/simplifiedEmote/simplifiedEmote.js index 1b6300a9a9..76944ee4b3 100644 --- a/scripts/simplifiedUI/simplifiedEmote/simplifiedEmote.js +++ b/scripts/simplifiedUI/simplifiedEmote/simplifiedEmote.js @@ -349,6 +349,15 @@ function onGeometryChanged(rect) { } +function onWindowMinimizedChanged(isMinimized) { + if (isMinimized) { + handleEmoteIndicatorVisibleChanged(false); + } else if (!HMD.active && Settings.getValue("simplifiedUI/emoteIndicatorVisible", true)) { + handleEmoteIndicatorVisibleChanged(true); + } +} + + // These keys need to match what's in `SimplifiedEmoteIndicator.qml` in the `buttonsModel` // for the tooltips to match the actual keys. var POSITIVE_KEY = "z"; @@ -450,9 +459,7 @@ function handleEmoteIndicatorVisibleChanged(newValue) { if (newValue && !emoteAppBarWindow) { showEmoteAppBar(); } else if (emoteAppBarWindow) { - if (emoteAppBarWindow) { - emoteAppBarWindow.fromQml.disconnect(onMessageFromEmoteAppBar); - } + emoteAppBarWindow.fromQml.disconnect(onMessageFromEmoteAppBar); emoteAppBarWindow.close(); emoteAppBarWindow = false; } @@ -509,6 +516,7 @@ function init() { } }, {}); + Window.minimizedChanged.connect(onWindowMinimizedChanged); Window.geometryChanged.connect(onGeometryChanged); Settings.valueChanged.connect(onSettingsValueChanged); HMD.displayModeChanged.connect(onDisplayModeChanged); @@ -544,6 +552,7 @@ function shutdown() { maybeClearClapSoundInterval(); maybeClearReticleUpdateLimiterTimeout(); + Window.minimizedChanged.disconnect(onWindowMinimizedChanged); Window.geometryChanged.disconnect(onGeometryChanged); Settings.valueChanged.disconnect(onSettingsValueChanged); HMD.displayModeChanged.disconnect(onDisplayModeChanged);