From 966d711e56f7f7585290fef3a11ef4dca67eb9b1 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 14 Mar 2018 13:38:48 +1300 Subject: [PATCH] Fix Window.raiseMainWindow() --- interface/src/Application.cpp | 17 ++++++++++++++--- interface/src/Application.h | 1 + .../src/scripting/WindowScriptingInterface.cpp | 2 +- .../src/scripting/WindowScriptingInterface.h | 2 +- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index cffb390644..e3168f228a 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -7362,9 +7362,20 @@ void Application::setFocus() { // flashes the taskbar icon. auto window = qApp->getWindow(); window->activateWindow(); - - // Do NOT do the following because it takes focus away from the _displayPlugin. - //window->setFocus(); +} + +void Application::raise() { + auto windowState = qApp->getWindow()->windowState(); + if (windowState & Qt::WindowMinimized) { + if (windowState & Qt::WindowMaximized) { + qApp->getWindow()->showMaximized(); + } else if (windowState & Qt::WindowFullScreen) { + qApp->getWindow()->showFullScreen(); + } else { + qApp->getWindow()->showNormal(); + } + } + qApp->getWindow()->raise(); } void Application::setMaxOctreePacketsPerSecond(int maxOctreePPS) { diff --git a/interface/src/Application.h b/interface/src/Application.h index 7339257bba..1420d5b056 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -162,6 +162,7 @@ public: glm::vec2 getDeviceSize() const; bool hasFocus() const; void setFocus(); + void raise(); void showCursor(const Cursor::Icon& cursor); diff --git a/interface/src/scripting/WindowScriptingInterface.cpp b/interface/src/scripting/WindowScriptingInterface.cpp index ffd2a76318..4cedfb5a34 100644 --- a/interface/src/scripting/WindowScriptingInterface.cpp +++ b/interface/src/scripting/WindowScriptingInterface.cpp @@ -81,7 +81,7 @@ void WindowScriptingInterface::setFocus() { void WindowScriptingInterface::raiseMainWindow() { // It's forbidden to call raise() from another thread. qApp->postLambdaEvent([] { - qApp->getWindow()->raise(); + qApp->raise(); }); } diff --git a/interface/src/scripting/WindowScriptingInterface.h b/interface/src/scripting/WindowScriptingInterface.h index dfe117b239..2a9806a302 100644 --- a/interface/src/scripting/WindowScriptingInterface.h +++ b/interface/src/scripting/WindowScriptingInterface.h @@ -69,7 +69,7 @@ public slots: void setFocus(); /**jsdoc - * Raise the Interface window if it is minimized, and give it focus. + * Raise the Interface window if it is minimized. If raised, the window gains focus. * @function Window.raiseMainWindow */ void raiseMainWindow();