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 | _mouseY(0), | 107 | _mouseY(0), |
| 108 | _lastMouseMove(usecTimestampNow()), | 108 | _lastMouseMove(usecTimestampNow()), |
| 109 | _mouseHidden(false), | 109 | _mouseHidden(false), |
| 110 | _seenMouseMove(false), | ||
| 110 | _touchAvgX(0.0f), | 111 | _touchAvgX(0.0f), |
| 111 | _touchAvgY(0.0f), | 112 | _touchAvgY(0.0f), |
| 112 | _isTouchPressed(false), | 113 | _isTouchPressed(false), |
| @@ -988,6 +989,7 @@ void Application::mouseMoveEvent(QMouseEvent* event) { · 875 unmodified lines | |||
| 988 | if (_mouseHidden) { | 989 | if (_mouseHidden) { |
| 989 | getGLWidget()->setCursor(Qt::ArrowCursor); | 990 | getGLWidget()->setCursor(Qt::ArrowCursor); |
| 990 | _mouseHidden = false; | 991 | _mouseHidden = false; |
| 992 | _seenMouseMove = true; | ||
| 991 | } | 993 | } |
| 992 | 994 | ||
| 993 | if (activeWindow() == _window) { | 995 | if (activeWindow() == _window) { |
| @@ -2133,12 +2135,22 @@ void Application::update(float deltaTime) { · 1139 unmodified lines | |||
| 2133 | #endif | 2135 | #endif |
| 2134 | 2136 | ||
| 2135 | // watch mouse position, if it hasn't moved, hide the cursor | 2137 | // watch mouse position, if it hasn't moved, hide the cursor |
| 2136 | uint64_t now = usecTimestampNow(); | 2138 | bool underMouse = _glWidget->underMouse(); |
| 2137 | int elapsed = now - _lastMouseMove; | 2139 | if (!_mouseHidden) { |
| 2138 | const int HIDE_CURSOR_TIMEOUT = 1 * 1000 * 1000; // 1 second | 2140 | uint64_t now = usecTimestampNow(); |
| 2139 | if (elapsed > HIDE_CURSOR_TIMEOUT) { | 2141 | int elapsed = now - _lastMouseMove; |
| 2140 | getGLWidget()->setCursor(Qt::BlankCursor); | 2142 | const int HIDE_CURSOR_TIMEOUT = 1 * 1000 * 1000; // 1 second |
| 2141 | _mouseHidden = true; | 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 | ||