Showing the changes to interface/src/Application.cpp (1 of 2 files). Show all
Unified · Split
| @@ -107,6 +107,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 106 unmodified lines | ||
| 107 | 107 | _mouseY(0), |
| 108 | 108 | _lastMouseMove(usecTimestampNow()), |
| 109 | 109 | _mouseHidden(false), |
| 110 | + _seenMouseMove(false), | |
| 110 | 111 | _touchAvgX(0.0f), |
| 111 | 112 | _touchAvgY(0.0f), |
| 112 | 113 | _isTouchPressed(false), |
| @@ -988,6 +989,7 @@ void Application::mouseMoveEvent(QMouseEvent* event) { · 875 unmodified lines | ||
| 988 | 989 | if (_mouseHidden) { |
| 989 | 990 | getGLWidget()->setCursor(Qt::ArrowCursor); |
| 990 | 991 | _mouseHidden = false; |
| 992 | + _seenMouseMove = true; | |
| 991 | 993 | } |
| 992 | 994 | |
| 993 | 995 | if (activeWindow() == _window) { |
| @@ -2133,12 +2135,22 @@ void Application::update(float deltaTime) { · 1139 unmodified lines | ||
| 2133 | 2135 | #endif |
| 2134 | 2136 | |
| 2135 | 2137 | // watch mouse position, if it hasn't moved, hide the cursor |
| 2136 | − uint64_t now = usecTimestampNow(); | |
| 2137 | − int elapsed = now - _lastMouseMove; | |
| 2138 | − const int HIDE_CURSOR_TIMEOUT = 1 * 1000 * 1000; // 1 second | |
| 2139 | − if (elapsed > HIDE_CURSOR_TIMEOUT) { | |
| 2140 | − getGLWidget()->setCursor(Qt::BlankCursor); | |
| 2141 | − _mouseHidden = true; | |
| 2138 | + bool underMouse = _glWidget->underMouse(); | |
| 2139 | + if (!_mouseHidden) { | |
| 2140 | + uint64_t now = usecTimestampNow(); | |
| 2141 | + int elapsed = now - _lastMouseMove; | |
| 2142 | + const int HIDE_CURSOR_TIMEOUT = 1 * 1000 * 1000; // 1 second | |
| 2143 | + if (elapsed > HIDE_CURSOR_TIMEOUT && (underMouse || !_seenMouseMove)) { | |
| 2144 | + getGLWidget()->setCursor(Qt::BlankCursor); | |
| 2145 | + _mouseHidden = true; | |
| 2146 | + } | |
| 2147 | + } else { | |
| 2148 | + // if the mouse is hidden, but we're not inside our window, then consider ourselves to be moving | |
| 2149 | + if (!underMouse && _seenMouseMove) { | |
| 2150 | + _lastMouseMove = usecTimestampNow(); | |
| 2151 | + getGLWidget()->setCursor(Qt::ArrowCursor); | |
| 2152 | + _mouseHidden = false; | |
| 2153 | + } | |
| 2142 | 2154 | } |
| 2143 | 2155 | } |
| 2144 | 2156 | |