don't capture mouse when other windows or menus are active

This commit is contained in:
HifiExperiments 2020-09-02 11:58:22 -07:00
parent 5281f89d0d
commit 1403f8908f
2 changed files with 18 additions and 1 deletions

View file

@ -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;

View file

@ -603,6 +603,7 @@ private:
void maybeToggleMenuVisible(QMouseEvent* event) const;
void toggleTabletUI(bool shouldOpen = false) const;
bool shouldCaptureMouse() const;
void userKickConfirmation(const QUuid& nodeID);