mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 09:25:12 +02:00
Fix for making cursor invisible over the glwidget and js-interface to cursorVisible boolean
This commit is contained in:
parent
8b1a226d8e
commit
9dbcefed2a
5 changed files with 16 additions and 25 deletions
|
@ -1940,32 +1940,14 @@ void Application::updateCursor(float deltaTime) {
|
|||
|
||||
static QPoint lastMousePos = QPoint();
|
||||
_lastMouseMove = (lastMousePos == QCursor::pos()) ? _lastMouseMove : usecTimestampNow();
|
||||
bool hideMouse = false;
|
||||
bool underMouse = QGuiApplication::topLevelAt(QCursor::pos()) ==
|
||||
Application::getInstance()->getWindow()->windowHandle();
|
||||
|
||||
static const int HIDE_CURSOR_TIMEOUT = 3 * USECS_PER_SECOND; // 3 second
|
||||
int elapsed = usecTimestampNow() - _lastMouseMove;
|
||||
if ((elapsed > HIDE_CURSOR_TIMEOUT) ||
|
||||
(OculusManager::isConnected() && Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode))) {
|
||||
hideMouse = underMouse;
|
||||
}
|
||||
|
||||
setCursorVisible(!hideMouse);
|
||||
lastMousePos = QCursor::pos();
|
||||
}
|
||||
|
||||
void Application::setCursorVisible(bool visible) {
|
||||
if (visible) {
|
||||
if (overrideCursor() != NULL) {
|
||||
restoreOverrideCursor();
|
||||
}
|
||||
DependencyManager::get<GLCanvas>()->unsetCursor();
|
||||
} else {
|
||||
if (overrideCursor() != NULL) {
|
||||
changeOverrideCursor(Qt::BlankCursor);
|
||||
} else {
|
||||
setOverrideCursor(Qt::BlankCursor);
|
||||
}
|
||||
DependencyManager::get<GLCanvas>()->setCursor(Qt::BlankCursor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -187,7 +187,6 @@ public:
|
|||
|
||||
bool isMousePressed() const { return _mousePressed; }
|
||||
bool isMouseHidden() const { return DependencyManager::get<GLCanvas>()->cursor().shape() == Qt::BlankCursor; }
|
||||
void setCursorVisible(bool visible);
|
||||
const glm::vec3& getMouseRayOrigin() const { return _mouseRayOrigin; }
|
||||
const glm::vec3& getMouseRayDirection() const { return _mouseRayDirection; }
|
||||
bool mouseOnScreen() const;
|
||||
|
@ -398,6 +397,8 @@ private slots:
|
|||
|
||||
void audioMuteToggled();
|
||||
|
||||
void setCursorVisible(bool visible);
|
||||
|
||||
private:
|
||||
void resetCamerasOnResizeGL(Camera& camera, int width, int height);
|
||||
void updateProjectionMatrix();
|
||||
|
|
|
@ -50,7 +50,12 @@ void WindowScriptingInterface::setFocus() {
|
|||
}
|
||||
|
||||
void WindowScriptingInterface::setCursorVisible(bool visible) {
|
||||
Application::getInstance()->setCursorVisible(visible);
|
||||
QMetaObject::invokeMethod(Application::getInstance(), "setCursorVisible", Qt::BlockingQueuedConnection,
|
||||
Q_ARG(bool, visible));
|
||||
}
|
||||
|
||||
bool WindowScriptingInterface::isCursorVisible() const {
|
||||
return !Application::getInstance()->isMouseHidden();
|
||||
}
|
||||
|
||||
void WindowScriptingInterface::setCursorPosition(int x, int y) {
|
||||
|
|
|
@ -27,12 +27,14 @@ class WindowScriptingInterface : public QObject {
|
|||
Q_PROPERTY(int innerHeight READ getInnerHeight)
|
||||
Q_PROPERTY(int x READ getX)
|
||||
Q_PROPERTY(int y READ getY)
|
||||
Q_PROPERTY(bool cursorVisible READ isCursorVisible)
|
||||
public:
|
||||
static WindowScriptingInterface* getInstance();
|
||||
int getInnerWidth();
|
||||
int getInnerHeight();
|
||||
int getX();
|
||||
int getY();
|
||||
bool isCursorVisible() const;
|
||||
|
||||
public slots:
|
||||
QScriptValue getCursorPositionX();
|
||||
|
|
|
@ -330,8 +330,9 @@ void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) {
|
|||
_overlays.buildVBO(_textureFov, _textureAspectRatio, 80, 80);
|
||||
}
|
||||
_overlays.render();
|
||||
renderPointersOculus(myAvatar->getDefaultEyePosition());
|
||||
|
||||
if (!Application::getInstance()->isMouseHidden()) {
|
||||
renderPointersOculus(myAvatar->getDefaultEyePosition());
|
||||
}
|
||||
glDepthMask(GL_TRUE);
|
||||
_overlays.releaseTexture();
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
@ -542,7 +543,7 @@ void ApplicationOverlay::renderPointers() {
|
|||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, _crosshairTexture);
|
||||
|
||||
if (OculusManager::isConnected() && !application->getLastMouseMoveWasSimulated()) {
|
||||
if (OculusManager::isConnected() && !application->getLastMouseMoveWasSimulated() && !application->isMouseHidden()) {
|
||||
//If we are in oculus, render reticle later
|
||||
if (_lastMouseMove == 0) {
|
||||
_lastMouseMove = usecTimestampNow();
|
||||
|
|
Loading…
Reference in a new issue