mirror of
https://github.com/lubosz/overte.git
synced 2025-04-25 14:33:06 +02:00
Away improvements
This commit is contained in:
parent
0268ca0888
commit
2c3fdc995f
5 changed files with 78 additions and 12 deletions
|
@ -106,6 +106,12 @@ function goAway() {
|
||||||
MyAvatar.setEnableMeshVisible(false); // just for our own display, without changing point of view
|
MyAvatar.setEnableMeshVisible(false); // just for our own display, without changing point of view
|
||||||
playAwayAnimation(); // animation is still seen by others
|
playAwayAnimation(); // animation is still seen by others
|
||||||
showOverlay();
|
showOverlay();
|
||||||
|
|
||||||
|
// tell the Reticle, we want to stop capturing the mouse until we come back
|
||||||
|
Reticle.allowMouseCapture = false;
|
||||||
|
if (HMD.active) {
|
||||||
|
Reticle.visible = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function goActive() {
|
function goActive() {
|
||||||
if (!isAway) {
|
if (!isAway) {
|
||||||
|
@ -119,13 +125,20 @@ function goActive() {
|
||||||
MyAvatar.setEnableMeshVisible(true); // IWBNI we respected Developer->Avatar->Draw Mesh setting.
|
MyAvatar.setEnableMeshVisible(true); // IWBNI we respected Developer->Avatar->Draw Mesh setting.
|
||||||
stopAwayAnimation();
|
stopAwayAnimation();
|
||||||
hideOverlay();
|
hideOverlay();
|
||||||
|
|
||||||
|
// tell the Reticle, we are ready to capture the mouse again and it should be visible
|
||||||
|
Reticle.allowMouseCapture = true;
|
||||||
|
Reticle.visible = true;
|
||||||
|
if (HMD.active) {
|
||||||
|
Reticle.position = HMD.getHUDLookAtPosition2D();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function maybeGoActive(event) {
|
function maybeGoActive(event) {
|
||||||
if (event.isAutoRepeat) { // isAutoRepeat is true when held down (or when Windows feels like it)
|
if (event.isAutoRepeat) { // isAutoRepeat is true when held down (or when Windows feels like it)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!isAway && (event.text === '.')) {
|
if (!isAway && (event.text == 'ESC')) {
|
||||||
goAway();
|
goAway();
|
||||||
} else {
|
} else {
|
||||||
goActive();
|
goActive();
|
||||||
|
@ -141,10 +154,8 @@ function maybeGoAway() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the mouse has gone from captured, to non-captured state,
|
// If the mouse has gone from captured, to non-captured state, then it likely means the person is still in the HMD, but
|
||||||
// then it likely means the person is still in the HMD, but has
|
// tabbed away from the application (meaning they don't have mouse control) and they likely want to go into an away state
|
||||||
// tabbed away from the application (meaning they don't have mouse
|
|
||||||
// control) and they likely want to go into an away state
|
|
||||||
if (Reticle.mouseCaptured !== wasMouseCaptured) {
|
if (Reticle.mouseCaptured !== wasMouseCaptured) {
|
||||||
wasMouseCaptured = !wasMouseCaptured;
|
wasMouseCaptured = !wasMouseCaptured;
|
||||||
if (!wasMouseCaptured) {
|
if (!wasMouseCaptured) {
|
||||||
|
|
|
@ -661,15 +661,15 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) :
|
||||||
|
|
||||||
_glWidget->setFocusPolicy(Qt::StrongFocus);
|
_glWidget->setFocusPolicy(Qt::StrongFocus);
|
||||||
_glWidget->setFocus();
|
_glWidget->setFocus();
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
// OSX doesn't seem to provide for hiding the cursor only on the GL widget
|
auto cursorTarget = _window; // OSX doesn't seem to provide for hiding the cursor only on the GL widget
|
||||||
_window->setCursor(Qt::BlankCursor);
|
|
||||||
#else
|
#else
|
||||||
// On windows and linux, hiding the top level cursor also means it's invisible
|
// On windows and linux, hiding the top level cursor also means it's invisible when hovering over the
|
||||||
// when hovering over the window menu, which is a pain, so only hide it for
|
// window menu, which is a pain, so only hide it for the GL surface
|
||||||
// the GL surface
|
auto cursorTarget = _glWidget;
|
||||||
_glWidget->setCursor(Qt::BlankCursor);
|
|
||||||
#endif
|
#endif
|
||||||
|
cursorTarget->setCursor(Qt::BlankCursor);
|
||||||
|
|
||||||
// enable mouse tracking; otherwise, we only get drag events
|
// enable mouse tracking; otherwise, we only get drag events
|
||||||
_glWidget->setMouseTracking(true);
|
_glWidget->setMouseTracking(true);
|
||||||
|
@ -981,6 +981,29 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) :
|
||||||
_idleTimer->start(0);
|
_idleTimer->start(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Application::checkChangeCursor() {
|
||||||
|
QMutexLocker locker(&_changeCursorLock);
|
||||||
|
if (_cursorNeedsChanging) {
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
auto cursorTarget = _window; // OSX doesn't seem to provide for hiding the cursor only on the GL widget
|
||||||
|
#else
|
||||||
|
// On windows and linux, hiding the top level cursor also means it's invisible when hovering over the
|
||||||
|
// window menu, which is a pain, so only hide it for the GL surface
|
||||||
|
auto cursorTarget = _glWidget;
|
||||||
|
#endif
|
||||||
|
cursorTarget->setCursor(_desiredCursor);
|
||||||
|
|
||||||
|
_cursorNeedsChanging = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Application::showCursor(const QCursor& cursor) {
|
||||||
|
QMutexLocker locker(&_changeCursorLock);
|
||||||
|
_desiredCursor = cursor;
|
||||||
|
_cursorNeedsChanging = true;
|
||||||
|
}
|
||||||
|
|
||||||
void Application::aboutToQuit() {
|
void Application::aboutToQuit() {
|
||||||
emit beforeAboutToQuit();
|
emit beforeAboutToQuit();
|
||||||
|
|
||||||
|
@ -2431,6 +2454,9 @@ void Application::idle(uint64_t now) {
|
||||||
return; // bail early, nothing to do here.
|
return; // bail early, nothing to do here.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
checkChangeCursor();
|
||||||
|
|
||||||
Stats::getInstance()->updateStats();
|
Stats::getInstance()->updateStats();
|
||||||
AvatarInputs::getInstance()->update();
|
AvatarInputs::getInstance()->update();
|
||||||
|
|
||||||
|
|
|
@ -120,6 +120,8 @@ public:
|
||||||
QSize getDeviceSize() const;
|
QSize getDeviceSize() const;
|
||||||
bool hasFocus() const;
|
bool hasFocus() const;
|
||||||
|
|
||||||
|
void showCursor(const QCursor& cursor);
|
||||||
|
|
||||||
bool isThrottleRendering() const;
|
bool isThrottleRendering() const;
|
||||||
|
|
||||||
Camera* getCamera() { return &_myCamera; }
|
Camera* getCamera() { return &_myCamera; }
|
||||||
|
@ -515,6 +517,11 @@ private:
|
||||||
QTimer* _idleTimer { nullptr };
|
QTimer* _idleTimer { nullptr };
|
||||||
|
|
||||||
bool _fakedMouseEvent { false };
|
bool _fakedMouseEvent { false };
|
||||||
|
|
||||||
|
void checkChangeCursor();
|
||||||
|
mutable QMutex _changeCursorLock { QMutex::Recursive };
|
||||||
|
QCursor _desiredCursor{ Qt::BlankCursor };
|
||||||
|
bool _cursorNeedsChanging { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_Application_h
|
#endif // hifi_Application_h
|
||||||
|
|
|
@ -335,9 +335,21 @@ QPointF ApplicationCompositor::getMouseEventPosition(QMouseEvent* event) {
|
||||||
|
|
||||||
bool ApplicationCompositor::shouldCaptureMouse() const {
|
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
|
// 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();
|
return _allowMouseCapture && qApp->isHMDMode() && QApplication::activeWindow() && !Menu::isSomeSubmenuShown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ApplicationCompositor::setAllowMouseCapture(bool capture) {
|
||||||
|
if (qApp->isHMDMode()) {
|
||||||
|
if (capture) {
|
||||||
|
qApp->showCursor(Qt::BlankCursor);
|
||||||
|
} else {
|
||||||
|
qApp->showCursor(Qt::ArrowCursor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_allowMouseCapture = capture;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ApplicationCompositor::handleLeaveEvent() {
|
void ApplicationCompositor::handleLeaveEvent() {
|
||||||
|
|
||||||
if (shouldCaptureMouse()) {
|
if (shouldCaptureMouse()) {
|
||||||
|
|
|
@ -106,6 +106,9 @@ public:
|
||||||
|
|
||||||
bool shouldCaptureMouse() const;
|
bool shouldCaptureMouse() const;
|
||||||
|
|
||||||
|
bool getAllowMouseCapture() const { return _allowMouseCapture; }
|
||||||
|
void setAllowMouseCapture(bool capture);
|
||||||
|
|
||||||
/// if the reticle is pointing to a system overlay (a dialog box for example) then the function returns true otherwise false
|
/// if the reticle is pointing to a system overlay (a dialog box for example) then the function returns true otherwise false
|
||||||
bool getReticleOverDesktop() const;
|
bool getReticleOverDesktop() const;
|
||||||
void setReticleOverDesktop(bool value) { _isOverDesktop = value; }
|
void setReticleOverDesktop(bool value) { _isOverDesktop = value; }
|
||||||
|
@ -162,6 +165,8 @@ private:
|
||||||
|
|
||||||
bool _reticleOverQml { false };
|
bool _reticleOverQml { false };
|
||||||
|
|
||||||
|
bool _allowMouseCapture { true };
|
||||||
|
|
||||||
ReticleInterface* _reticleInterface;
|
ReticleInterface* _reticleInterface;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -173,12 +178,17 @@ class ReticleInterface : public QObject {
|
||||||
Q_PROPERTY(float depth READ getDepth WRITE setDepth)
|
Q_PROPERTY(float depth READ getDepth WRITE setDepth)
|
||||||
Q_PROPERTY(glm::vec2 maximumPosition READ getMaximumPosition)
|
Q_PROPERTY(glm::vec2 maximumPosition READ getMaximumPosition)
|
||||||
Q_PROPERTY(bool mouseCaptured READ isMouseCaptured)
|
Q_PROPERTY(bool mouseCaptured READ isMouseCaptured)
|
||||||
|
Q_PROPERTY(bool allowMouseCapture READ getAllowMouseCapture WRITE setAllowMouseCapture)
|
||||||
Q_PROPERTY(bool pointingAtSystemOverlay READ isPointingAtSystemOverlay)
|
Q_PROPERTY(bool pointingAtSystemOverlay READ isPointingAtSystemOverlay)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ReticleInterface(ApplicationCompositor* outer) : QObject(outer), _compositor(outer) {}
|
ReticleInterface(ApplicationCompositor* outer) : QObject(outer), _compositor(outer) {}
|
||||||
|
|
||||||
Q_INVOKABLE bool isMouseCaptured() { return _compositor->shouldCaptureMouse(); }
|
Q_INVOKABLE bool isMouseCaptured() { return _compositor->shouldCaptureMouse(); }
|
||||||
|
|
||||||
|
Q_INVOKABLE bool getAllowMouseCapture() { return _compositor->getAllowMouseCapture(); }
|
||||||
|
Q_INVOKABLE void setAllowMouseCapture(bool value) { return _compositor->setAllowMouseCapture(value); }
|
||||||
|
|
||||||
Q_INVOKABLE bool isPointingAtSystemOverlay() { return !_compositor->getReticleOverDesktop(); }
|
Q_INVOKABLE bool isPointingAtSystemOverlay() { return !_compositor->getReticleOverDesktop(); }
|
||||||
|
|
||||||
Q_INVOKABLE bool getVisible() { return _compositor->getReticleVisible(); }
|
Q_INVOKABLE bool getVisible() { return _compositor->getReticleVisible(); }
|
||||||
|
|
Loading…
Reference in a new issue