History

make mouse cursor hiding more aware of focused window and bounds

ZappoMan committed 13 years ago

Commit 6f9fdfb1 parent 78b2f262 files · +19 −6Browse files

Showing the changes to interface/src/Application.cpp (1 of 2 files). Show all

Unified · Split

interface/src/Application.cpp+18−6
@@ -107,6 +107,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 106 unmodified lines
107107 _mouseY(0),
108108 _lastMouseMove(usecTimestampNow()),
109109 _mouseHidden(false),
110+ _seenMouseMove(false),
110111 _touchAvgX(0.0f),
111112 _touchAvgY(0.0f),
112113 _isTouchPressed(false),
@@ -988,6 +989,7 @@ void Application::mouseMoveEvent(QMouseEvent* event) { · 875 unmodified lines
988989 if (_mouseHidden) {
989990 getGLWidget()->setCursor(Qt::ArrowCursor);
990991 _mouseHidden = false;
992+ _seenMouseMove = true;
991993 }
992994
993995 if (activeWindow() == _window) {
@@ -2133,12 +2135,22 @@ void Application::update(float deltaTime) { · 1139 unmodified lines
21332135 #endif
21342136
21352137 // 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+ }
21422154 }
21432155 }
21442156

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t