From 07ff687bfec0c8ff742ea6619f5b35dad2c3c306 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Tue, 5 Apr 2016 18:12:02 -0700 Subject: [PATCH] Application: change keyboard input focus when using ui overlay. call focusOutEvent on keyboard input plugin when an offscreen ui has activeFocus. --- interface/src/Application.cpp | 9 +++++++++ interface/src/Application.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 311583acb7..66039cf41c 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2564,6 +2564,15 @@ void Application::idle(uint64_t now) { _overlayConductor.setEnabled(Menu::getInstance()->isOptionChecked(MenuOption::Overlays)); } + // If the offscreen Ui has something active that is NOT the root, then assume it has keyboard focus. + auto offscreenUi = DependencyManager::get(); + if (_keyboardDeviceHasFocus && offscreenUi && offscreenUi->getWindow()->activeFocusItem() != offscreenUi->getRootItem()) { + _keyboardMouseDevice->pluginFocusOutEvent(); + _keyboardDeviceHasFocus = false; + } else if (offscreenUi && offscreenUi->getWindow()->activeFocusItem() == offscreenUi->getRootItem()) { + _keyboardDeviceHasFocus = true; + } + auto displayPlugin = getActiveDisplayPlugin(); // depending on whether we're throttling or not. // Once rendering is off on another thread we should be able to have Application::idle run at start(0) in diff --git a/interface/src/Application.h b/interface/src/Application.h index e3196febd5..f2b6edeea4 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -518,6 +518,8 @@ private: std::mutex _preRenderLambdasLock; std::atomic _processOctreeStatsCounter { 0 }; + + bool _keyboardDeviceHasFocus { true }; }; #endif // hifi_Application_h