From 39fd16fc9e9a2f7f212b7843aead634803f31164 Mon Sep 17 00:00:00 2001 From: amer cerkic Date: Wed, 3 Jul 2019 11:05:38 -0700 Subject: [PATCH 1/3] adding a null check escape to the activeItem. On right click back to root window active item becomes null instead of root item --- interface/src/Application.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 8ecb16b65f..0f499adf7d 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5109,7 +5109,7 @@ void Application::idle() { // If the offscreen Ui has something active that is NOT the root, then assume it has keyboard focus. if (offscreenUi && offscreenUi->getWindow()) { auto activeFocusItem = offscreenUi->getWindow()->activeFocusItem(); - if (_keyboardDeviceHasFocus && activeFocusItem != offscreenUi->getRootItem()) { + if (_keyboardDeviceHasFocus && (activeFocusItem != NULL && activeFocusItem != offscreenUi->getRootItem())) { _keyboardMouseDevice->pluginFocusOutEvent(); _keyboardDeviceHasFocus = false; synthesizeKeyReleasEvents(); From 9384c5b3a35b016bd3e4d09bae9b0cacf1d19a1f Mon Sep 17 00:00:00 2001 From: amer cerkic Date: Wed, 3 Jul 2019 16:02:56 -0700 Subject: [PATCH 2/3] testing what happens (for mac specifically) when we specify the focus item to be the root, not NULL as sometimes happens when toggling between modal popups and the main window --- interface/src/Application.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index d014f19770..6dc093954c 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -4161,6 +4161,19 @@ bool Application::event(QEvent* event) { case QEvent::FocusOut: focusOutEvent(static_cast(event)); return true; + case QEvent::FocusIn: + { //testing to see if we can set focus when focus is not set to root window. + auto offscreenUi = getOffscreenUI(); + auto activeFocusItem = offscreenUi->getWindow()->activeFocusItem(); + + if (activeFocusItem == NULL) { + offscreenUi->getRootItem()->setEnabled(true); + offscreenUi->getRootItem()->setFocus(true, Qt::FocusReason::ActiveWindowFocusReason); + } + + return true; + } + case QEvent::TouchBegin: touchBeginEvent(static_cast(event)); event->accept(); From 84055a6f0d99740d40ce01876ad6b7e68e85d95f Mon Sep 17 00:00:00 2001 From: amerhifi Date: Mon, 8 Jul 2019 11:12:50 -0700 Subject: [PATCH 3/3] adding focus back on _glWidget --- interface/src/Application.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 6dc093954c..c550c91f87 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -4162,15 +4162,9 @@ bool Application::event(QEvent* event) { focusOutEvent(static_cast(event)); return true; case QEvent::FocusIn: - { //testing to see if we can set focus when focus is not set to root window. - auto offscreenUi = getOffscreenUI(); - auto activeFocusItem = offscreenUi->getWindow()->activeFocusItem(); - - if (activeFocusItem == NULL) { - offscreenUi->getRootItem()->setEnabled(true); - offscreenUi->getRootItem()->setFocus(true, Qt::FocusReason::ActiveWindowFocusReason); - } - + { //testing to see if we can set focus when focus is not set to root window. + _glWidget->activateWindow(); + _glWidget->setFocus(); return true; } @@ -8782,6 +8776,8 @@ bool Application::isThrottleRendering() const { bool Application::hasFocus() const { bool result = (QApplication::activeWindow() != nullptr); + + #if defined(Q_OS_WIN) // On Windows, QWidget::activateWindow() - as called in setFocus() - makes the application's taskbar icon flash but doesn't // take user focus away from their current window. So also check whether the application is the user's current foreground