mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 20:08:56 +02:00
Don't trigger keyboard on revealing the overlay layer
This commit is contained in:
parent
7e88772e85
commit
f3bad3a63b
5 changed files with 34 additions and 6 deletions
|
@ -297,6 +297,9 @@ FocusScope {
|
||||||
|
|
||||||
onPinnedChanged: {
|
onPinnedChanged: {
|
||||||
if (pinned) {
|
if (pinned) {
|
||||||
|
nullFocus.focus = true;
|
||||||
|
nullFocus.forceActiveFocus();
|
||||||
|
|
||||||
// recalculate our non-pinned children
|
// recalculate our non-pinned children
|
||||||
hiddenChildren = d.findMatchingChildren(desktop, function(child){
|
hiddenChildren = d.findMatchingChildren(desktop, function(child){
|
||||||
return !d.isTopLevelWindow(child) && child.visible && !child.pinned;
|
return !d.isTopLevelWindow(child) && child.visible && !child.pinned;
|
||||||
|
@ -478,6 +481,8 @@ FocusScope {
|
||||||
|
|
||||||
FocusHack { id: focusHack; }
|
FocusHack { id: focusHack; }
|
||||||
|
|
||||||
|
FocusScope { id: nullFocus; }
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: focusDebugger;
|
id: focusDebugger;
|
||||||
objectName: "focusDebugger"
|
objectName: "focusDebugger"
|
||||||
|
|
|
@ -267,7 +267,7 @@ void OpenVrDisplayPlugin::unsuppressKeyboard() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (1 == _keyboardSupressionCount.fetch_sub(1)) {
|
if (1 == _keyboardSupressionCount.fetch_sub(1)) {
|
||||||
enableOpenVrKeyboard();
|
enableOpenVrKeyboard(_container);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,9 @@
|
||||||
#include <OffscreenUi.h>
|
#include <OffscreenUi.h>
|
||||||
#include <controllers/Pose.h>
|
#include <controllers/Pose.h>
|
||||||
#include <NumericalConstants.h>
|
#include <NumericalConstants.h>
|
||||||
|
#include <plugins/PluginContainer.h>
|
||||||
|
#include <ui/Menu.h>
|
||||||
|
#include "../../interface/src/Menu.h"
|
||||||
|
|
||||||
Q_DECLARE_LOGGING_CATEGORY(displayplugins)
|
Q_DECLARE_LOGGING_CATEGORY(displayplugins)
|
||||||
Q_LOGGING_CATEGORY(displayplugins, "hifi.plugins.display")
|
Q_LOGGING_CATEGORY(displayplugins, "hifi.plugins.display")
|
||||||
|
@ -91,7 +94,7 @@ void releaseOpenVrSystem() {
|
||||||
|
|
||||||
static char textArray[8192];
|
static char textArray[8192];
|
||||||
|
|
||||||
static QMetaObject::Connection _focusConnection, _focusTextConnection;
|
static QMetaObject::Connection _focusConnection, _focusTextConnection, _overlayMenuConnection;
|
||||||
extern bool _openVrDisplayActive;
|
extern bool _openVrDisplayActive;
|
||||||
static vr::IVROverlay* _overlay { nullptr };
|
static vr::IVROverlay* _overlay { nullptr };
|
||||||
static QObject* _keyboardFocusObject { nullptr };
|
static QObject* _keyboardFocusObject { nullptr };
|
||||||
|
@ -99,7 +102,8 @@ static QString _existingText;
|
||||||
static Qt::InputMethodHints _currentHints;
|
static Qt::InputMethodHints _currentHints;
|
||||||
extern vr::TrackedDevicePose_t _trackedDevicePose[vr::k_unMaxTrackedDeviceCount];
|
extern vr::TrackedDevicePose_t _trackedDevicePose[vr::k_unMaxTrackedDeviceCount];
|
||||||
static bool _keyboardShown { false };
|
static bool _keyboardShown { false };
|
||||||
static const uint32_t SHOW_KEYBOARD_DELAY_MS = 100;
|
static bool _overlayRevealed { false };
|
||||||
|
static const uint32_t SHOW_KEYBOARD_DELAY_MS = 400;
|
||||||
|
|
||||||
void showOpenVrKeyboard(bool show = true) {
|
void showOpenVrKeyboard(bool show = true) {
|
||||||
if (!_overlay) {
|
if (!_overlay) {
|
||||||
|
@ -175,13 +179,25 @@ void finishOpenVrKeyboardInput() {
|
||||||
static const QString DEBUG_FLAG("HIFI_DISABLE_STEAM_VR_KEYBOARD");
|
static const QString DEBUG_FLAG("HIFI_DISABLE_STEAM_VR_KEYBOARD");
|
||||||
bool disableSteamVrKeyboard = QProcessEnvironment::systemEnvironment().contains(DEBUG_FLAG);
|
bool disableSteamVrKeyboard = QProcessEnvironment::systemEnvironment().contains(DEBUG_FLAG);
|
||||||
|
|
||||||
void enableOpenVrKeyboard() {
|
void enableOpenVrKeyboard(PluginContainer* container) {
|
||||||
if (disableSteamVrKeyboard) {
|
if (disableSteamVrKeyboard) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
_overlay = vr::VROverlay();
|
_overlay = vr::VROverlay();
|
||||||
|
|
||||||
|
|
||||||
|
auto menu = container->getPrimaryMenu();
|
||||||
|
auto action = menu->getActionForOption(MenuOption::Overlays);
|
||||||
|
|
||||||
|
// When the overlays are revealed, suppress the keyboard from appearing on text focus for a tenth of a second.
|
||||||
|
_overlayMenuConnection = QObject::connect(action, &QAction::triggered, [action] {
|
||||||
|
if (action->isChecked()) {
|
||||||
|
_overlayRevealed = true;
|
||||||
|
QTimer::singleShot(100, [&] { _overlayRevealed = false; });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
_focusConnection = QObject::connect(offscreenUi->getWindow(), &QQuickWindow::focusObjectChanged, [](QObject* object) {
|
_focusConnection = QObject::connect(offscreenUi->getWindow(), &QQuickWindow::focusObjectChanged, [](QObject* object) {
|
||||||
if (object != _keyboardFocusObject) {
|
if (object != _keyboardFocusObject) {
|
||||||
showOpenVrKeyboard(false);
|
showOpenVrKeyboard(false);
|
||||||
|
@ -190,6 +206,11 @@ void enableOpenVrKeyboard() {
|
||||||
|
|
||||||
_focusTextConnection = QObject::connect(offscreenUi.data(), &OffscreenUi::focusTextChanged, [](bool focusText) {
|
_focusTextConnection = QObject::connect(offscreenUi.data(), &OffscreenUi::focusTextChanged, [](bool focusText) {
|
||||||
if (_openVrDisplayActive) {
|
if (_openVrDisplayActive) {
|
||||||
|
if (_overlayRevealed) {
|
||||||
|
// suppress at most one text focus event
|
||||||
|
_overlayRevealed = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
showOpenVrKeyboard(focusText);
|
showOpenVrKeyboard(focusText);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -200,6 +221,7 @@ void disableOpenVrKeyboard() {
|
||||||
if (disableSteamVrKeyboard) {
|
if (disableSteamVrKeyboard) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
QObject::disconnect(_overlayMenuConnection);
|
||||||
QObject::disconnect(_focusTextConnection);
|
QObject::disconnect(_focusTextConnection);
|
||||||
QObject::disconnect(_focusConnection);
|
QObject::disconnect(_focusConnection);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include <glm/gtc/matrix_transform.hpp>
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
|
|
||||||
#include <controllers/Forward.h>
|
#include <controllers/Forward.h>
|
||||||
|
#include <plugins/Forward.h>
|
||||||
|
|
||||||
bool openVrSupported();
|
bool openVrSupported();
|
||||||
|
|
||||||
|
@ -20,7 +21,7 @@ vr::IVRSystem* acquireOpenVrSystem();
|
||||||
void releaseOpenVrSystem();
|
void releaseOpenVrSystem();
|
||||||
void handleOpenVrEvents();
|
void handleOpenVrEvents();
|
||||||
bool openVrQuitRequested();
|
bool openVrQuitRequested();
|
||||||
void enableOpenVrKeyboard();
|
void enableOpenVrKeyboard(PluginContainer* container);
|
||||||
void disableOpenVrKeyboard();
|
void disableOpenVrKeyboard();
|
||||||
bool isOpenVrKeyboardShown();
|
bool isOpenVrKeyboardShown();
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ bool ViveControllerManager::activate() {
|
||||||
}
|
}
|
||||||
Q_ASSERT(_system);
|
Q_ASSERT(_system);
|
||||||
|
|
||||||
enableOpenVrKeyboard();
|
enableOpenVrKeyboard(_container);
|
||||||
|
|
||||||
// OpenVR provides 3d mesh representations of the controllers
|
// OpenVR provides 3d mesh representations of the controllers
|
||||||
// Disabled controller rendering code
|
// Disabled controller rendering code
|
||||||
|
|
Loading…
Reference in a new issue