diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 34cdf3cda8..06d1be6997 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -7329,6 +7329,16 @@ bool Application::hasFocus() const { return (QApplication::activeWindow() != nullptr); } +void Application::setFocus() { + // Note: Windows doesn't allow a user focus to be taken away from another application. Instead, it changes the color of and + // 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::setMaxOctreePacketsPerSecond(int maxOctreePPS) { if (maxOctreePPS != _maxOctreePPS) { _maxOctreePPS = maxOctreePPS; diff --git a/interface/src/Application.h b/interface/src/Application.h index ad12a4dc67..c673138369 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -160,6 +160,7 @@ public: QRect getRecommendedHUDRect() const; glm::vec2 getDeviceSize() const; bool hasFocus() const; + void setFocus(); void showCursor(const Cursor::Icon& cursor); diff --git a/interface/src/scripting/WindowScriptingInterface.cpp b/interface/src/scripting/WindowScriptingInterface.cpp index 12b20566ed..1c98f5190d 100644 --- a/interface/src/scripting/WindowScriptingInterface.cpp +++ b/interface/src/scripting/WindowScriptingInterface.cpp @@ -74,9 +74,7 @@ QScriptValue WindowScriptingInterface::hasFocus() { void WindowScriptingInterface::setFocus() { // It's forbidden to call focus() from another thread. qApp->postLambdaEvent([] { - auto window = qApp->getWindow(); - window->activateWindow(); - window->setFocus(); + qApp->setFocus(); }); }