From 1403f8908f59417de53ccfad4005c217b4106936 Mon Sep 17 00:00:00 2001 From: HifiExperiments Date: Wed, 2 Sep 2020 11:58:22 -0700 Subject: [PATCH] don't capture mouse when other windows or menus are active --- interface/src/Application.cpp | 18 +++++++++++++++++- interface/src/Application.h | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index e46182ed83..270013a80d 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5921,6 +5921,22 @@ void Application::cameraModeChanged() { cameraMenuChanged(); } +bool Application::shouldCaptureMouse() const { + if (!_captureMouse) { + return false; + } + + if (!_glWidget->isActiveWindow()) { + return false; + } + + if (ui::Menu::isSomeSubmenuShown()) { + return false; + } + + return true; +} + void Application::captureMouseChanged(bool captureMouse) { _captureMouse = captureMouse; if (_captureMouse) { @@ -6281,7 +6297,7 @@ void Application::update(float deltaTime) { PROFILE_ASYNC_END(app, "Scene Loading", ""); } - if (_captureMouse) { + if (shouldCaptureMouse()) { QPoint point = _glWidget->mapToGlobal(_glWidget->geometry().center()); if (QCursor::pos() != point) { _mouseCaptureTarget = point; diff --git a/interface/src/Application.h b/interface/src/Application.h index d66d9c32b3..7ab62016c8 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -603,6 +603,7 @@ private: void maybeToggleMenuVisible(QMouseEvent* event) const; void toggleTabletUI(bool shouldOpen = false) const; + bool shouldCaptureMouse() const; void userKickConfirmation(const QUuid& nodeID);