Fix offset so that non-full-size window can be located anywhere on screen.

This commit is contained in:
howard-stearns 2016-05-03 16:26:45 -07:00
parent eb0517f3cd
commit fdf9c0a217
3 changed files with 20 additions and 6 deletions

View file

@ -305,6 +305,10 @@ void CompositorHelper::sendFakeMouseEvent() {
}
}
//FIXME remove static Setting::Handle<QRect> windowGeometry("WindowGeometry");
#include "QWindow.h"
#include "QQuickWindow.h"
void CompositorHelper::setReticlePosition(const glm::vec2& position, bool sendFakeEvent) {
if (isHMD()) {
glm::vec2 maxOverlayPosition = _currentDisplayPlugin->getRecommendedUiSize();
@ -322,7 +326,20 @@ void CompositorHelper::setReticlePosition(const glm::vec2& position, bool sendFa
sendFakeMouseEvent();
}
} else {
QCursor::setPos(position.x, position.y);
if (!_mainWindow) {
auto windows = qApp->topLevelWindows();
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,6 +17,7 @@
#include <QtCore/QPropertyAnimation>
#include <QtGui/QCursor>
#include <QtGui/QMouseEvent>
#include <QtGui/QWindow>
#include <GLMHelpers.h>
#include <Transform.h>
@ -182,6 +183,7 @@ private:
bool _fakeMouseEvent { false };
ReticleInterface* _reticleInterface { nullptr };
QWindow* _mainWindow { nullptr };
};
// Scripting interface available to control the Reticle

View file

@ -84,11 +84,6 @@ function ignoreMouseActivity() {
return true;
}
var setReticlePosition = function (point2d) {
if (!HMD.active) {
// FIX SYSTEM BUG: setPosition is setting relative to screen origin, not the content area of the window.
// https://app.asana.com/0/26225263936266/118427643788550
point2d = {x: point2d.x, y: point2d.y + 50};
}
weMovedReticle = true;
Reticle.setPosition(point2d);
};