Fix setReticlePosition and getReticlePosition to match.

This commit is contained in:
howard-stearns 2016-05-09 11:34:52 -07:00
parent 3f3233da66
commit af8d0dc280
2 changed files with 3 additions and 17 deletions

View file

@ -258,7 +258,7 @@ glm::vec2 CompositorHelper::getReticlePosition() const {
QMutexLocker locker(&_reticleLock); QMutexLocker locker(&_reticleLock);
return _reticlePositionInHMD; return _reticlePositionInHMD;
} }
return toGlm(QCursor::pos()); return toGlm(_renderingWidget->mapFromGlobal(QCursor::pos()));
} }
bool CompositorHelper::getReticleOverDesktop() const { bool CompositorHelper::getReticleOverDesktop() const {
@ -324,20 +324,8 @@ void CompositorHelper::setReticlePosition(const glm::vec2& position, bool sendFa
sendFakeMouseEvent(); sendFakeMouseEvent();
} }
} else { } else {
if (!_mainWindow) { const QPoint point(position.x, position.y);
auto windows = qApp->topLevelWindows(); QCursor::setPos(_renderingWidget->mapToGlobal(point));
QWindow* result = nullptr;
for (auto window : windows) {
QVariant isMainWindow = window->property("MainWindow");
if (!qobject_cast<QQuickWindow*>(window)) {
result = window;
break;
}
}
_mainWindow = result;;
}
const int MENU_BAR_HEIGHT = 20;
QCursor::setPos(position.x + _mainWindow->x(), position.y + _mainWindow->y() + MENU_BAR_HEIGHT);
} }
} }

View file

@ -17,7 +17,6 @@
#include <QtCore/QPropertyAnimation> #include <QtCore/QPropertyAnimation>
#include <QtGui/QCursor> #include <QtGui/QCursor>
#include <QtGui/QMouseEvent> #include <QtGui/QMouseEvent>
#include <QtGui/QWindow>
#include <GLMHelpers.h> #include <GLMHelpers.h>
#include <Transform.h> #include <Transform.h>
@ -183,7 +182,6 @@ private:
bool _fakeMouseEvent { false }; bool _fakeMouseEvent { false };
ReticleInterface* _reticleInterface { nullptr }; ReticleInterface* _reticleInterface { nullptr };
QWindow* _mainWindow { nullptr };
}; };
// Scripting interface available to control the Reticle // Scripting interface available to control the Reticle