mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-13 01:24:28 +02:00
don't capture the mouse if you're not the active window or if a menu is popped up
This commit is contained in:
parent
adcadedc65
commit
0de5c1cf71
4 changed files with 20 additions and 2 deletions
|
@ -968,6 +968,7 @@ int Menu::positionBeforeSeparatorIfNeeded(MenuWrapper* menu, int requestedPositi
|
|||
return requestedPosition;
|
||||
}
|
||||
|
||||
bool Menu::_isSomeSubmenuShown = false;
|
||||
|
||||
MenuWrapper* Menu::addMenu(const QString& menuName, const QString& grouping) {
|
||||
QStringList menuTree = menuName.split(">");
|
||||
|
@ -994,6 +995,12 @@ MenuWrapper* Menu::addMenu(const QString& menuName, const QString& grouping) {
|
|||
}
|
||||
|
||||
QMenuBar::repaint();
|
||||
|
||||
// hook our show/hide for popup menus, so we can keep track of whether or not one
|
||||
// of our submenus is currently showing.
|
||||
connect(menu->_realMenu, &QMenu::aboutToShow, []() { _isSomeSubmenuShown = true; });
|
||||
connect(menu->_realMenu, &QMenu::aboutToHide, []() { _isSomeSubmenuShown = false; });
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ public:
|
|||
QAction* newAction() {
|
||||
return new QAction(_realMenu);
|
||||
}
|
||||
|
||||
private:
|
||||
MenuWrapper(QMenu* menu);
|
||||
|
||||
|
@ -117,6 +118,8 @@ public slots:
|
|||
void toggleDeveloperMenus();
|
||||
void toggleAdvancedMenus();
|
||||
|
||||
static bool isSomeSubmenuShown() { return _isSomeSubmenuShown; }
|
||||
|
||||
private:
|
||||
typedef void(*settingsAction)(Settings&, QAction&);
|
||||
static void loadAction(Settings& settings, QAction& action);
|
||||
|
@ -142,6 +145,8 @@ private:
|
|||
bool isValidGrouping(const QString& grouping) const { return grouping == "Advanced" || grouping == "Developer"; }
|
||||
QHash<QString, bool> _groupingVisible;
|
||||
QHash<QString, QSet<QAction*>> _groupingActions;
|
||||
|
||||
static bool _isSomeSubmenuShown;
|
||||
};
|
||||
|
||||
namespace MenuOption {
|
||||
|
|
|
@ -308,9 +308,13 @@ QPointF ApplicationCompositor::getMouseEventPosition(QMouseEvent* event) {
|
|||
return event->localPos();
|
||||
}
|
||||
|
||||
bool ApplicationCompositor::shouldCaptureMouse() const {
|
||||
// if we're in HMD mode, and some window of ours is active, but we're not currently showing a popup menu
|
||||
return qApp->isHMDMode() && QApplication::activeWindow() && !Menu::isSomeSubmenuShown();
|
||||
}
|
||||
|
||||
void ApplicationCompositor::handleLeaveEvent() {
|
||||
if (qApp->isHMDMode()) {
|
||||
if (shouldCaptureMouse()) {
|
||||
auto applicationGeometry = qApp->getApplicationGeometry();
|
||||
_ignoreMouseMove = true;
|
||||
auto sendToPos = applicationGeometry.center();
|
||||
|
@ -328,7 +332,7 @@ bool ApplicationCompositor::handleRealMouseMoveEvent(bool sendFakeEvent) {
|
|||
}
|
||||
|
||||
// If we're in HMD mode
|
||||
if (qApp->isHMDMode()) {
|
||||
if (shouldCaptureMouse()) {
|
||||
auto newPosition = QCursor::pos();
|
||||
auto changeInRealMouse = newPosition - _lastKnownRealMouse;
|
||||
auto newReticlePosition = _reticlePositionInHMD + toGlm(changeInRealMouse);
|
||||
|
|
|
@ -105,6 +105,8 @@ public:
|
|||
|
||||
|
||||
private:
|
||||
bool shouldCaptureMouse() const;
|
||||
|
||||
void displayOverlayTextureStereo(RenderArgs* renderArgs, float aspectRatio, float fov);
|
||||
void bindCursorTexture(gpu::Batch& batch, uint8_t cursorId = 0);
|
||||
void buildHemiVertices(const float fov, const float aspectRatio, const int slices, const int stacks);
|
||||
|
|
Loading…
Reference in a new issue