Fix mouse drag turning

This commit is contained in:
Brad Davis 2016-03-07 17:11:15 -08:00
parent 634f8fbc83
commit 8988dd9771
3 changed files with 14 additions and 9 deletions

View file

@ -2161,17 +2161,16 @@ void Application::mouseMoveEvent(QMouseEvent* event) {
maybeToggleMenuVisible(event);
auto& compositor = getApplicationCompositor();
// if this is a real mouse event, and we're in HMD mode, then we should use it to move the
// compositor reticle
if (event->spontaneous()) {
// handleRealMouseMoveEvent() will return true, if we shouldn't process the event further
if (getApplicationCompositor().handleRealMouseMoveEvent()) {
return; // bail
}
// handleRealMouseMoveEvent() will return true, if we shouldn't process the event further
if (!compositor.fakeEventActive() && compositor.handleRealMouseMoveEvent()) {
return; // bail
}
auto offscreenUi = DependencyManager::get<OffscreenUi>();
auto eventPosition = getApplicationCompositor().getMouseEventPosition(event);
auto eventPosition = compositor.getMouseEventPosition(event);
QPointF transformedPos = offscreenUi->mapToVirtualScreen(eventPosition, _glWidget);
auto button = event->button();
auto buttons = event->buttons();

View file

@ -303,11 +303,14 @@ void CompositorHelper::setReticlePosition(const glm::vec2& position, bool sendFa
auto button = Qt::NoButton;
auto buttons = QApplication::mouseButtons();
auto modifiers = QApplication::keyboardModifiers();
static auto renderingWidget = PluginContainer::getInstance().getPrimaryWidget();
if (qApp->thread() == QThread::currentThread()) {
QMouseEvent event(QEvent::MouseMove, globalPos, button, buttons, modifiers);
qApp->sendEvent(qApp, &event);
_fakeMouseEvent = true;
qApp->sendEvent(renderingWidget, &event);
_fakeMouseEvent = false;
} else {
qApp->postEvent(qApp, new QMouseEvent(QEvent::MouseMove, globalPos, button, buttons, modifiers));
qApp->postEvent(renderingWidget, new QMouseEvent(QEvent::MouseMove, globalPos, button, buttons, modifiers));
}
}
} else {

View file

@ -54,6 +54,7 @@ public:
float getHmdUIAngularSize() const { return _hmdUIAngularSize; }
void setHmdUIAngularSize(float hmdUIAngularSize) { _hmdUIAngularSize = hmdUIAngularSize; }
bool isHMD() const;
bool fakeEventActive() const { return _fakeMouseEvent; }
// Converter from one frame of reference to another.
// Frame of reference:
@ -167,7 +168,9 @@ private:
bool _allowMouseCapture { true };
ReticleInterface* _reticleInterface;
bool _fakeMouseEvent { false };
ReticleInterface* _reticleInterface { nullptr };
};
// Scripting interface available to control the Reticle