From 6164eb603b49f84840341284f103c3c23d80756b Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 14 Apr 2013 15:36:10 +0200 Subject: [PATCH] Added tracking of cursor visibility. --- src/win32_platform.h | 1 + src/win32_window.c | 23 +++++++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/win32_platform.h b/src/win32_platform.h index 857289e6..0fa37170 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -154,6 +154,7 @@ typedef struct _GLFWwindowWin32 // Various platform specific internal variables GLboolean cursorCentered; GLboolean cursorInside; + GLboolean cursorHidden; int oldCursorX, oldCursorY; } _GLFWwindowWin32; diff --git a/src/win32_window.c b/src/win32_window.c index cfaced67..0379c4d6 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -54,20 +54,30 @@ static void hideCursor(_GLFWwindow* window) ReleaseCapture(); ClipCursor(NULL); - ShowCursor(TRUE); + + if (window->win32.cursorHidden) + { + ShowCursor(TRUE); + window->win32.cursorHidden = GL_FALSE; + } if (GetCursorPos(&pos)) { if (WindowFromPoint(pos) == window->win32.handle) SetCursor(NULL); -} + } } // Capture mouse cursor // static void captureCursor(_GLFWwindow* window) { - ShowCursor(FALSE); + if (!window->win32.cursorHidden) + { + ShowCursor(FALSE); + window->win32.cursorHidden = GL_TRUE; + } + updateClipRect(window); SetCapture(window->win32.handle); } @@ -80,7 +90,12 @@ static void showCursor(_GLFWwindow* window) ReleaseCapture(); ClipCursor(NULL); - ShowCursor(TRUE); + + if (window->win32.cursorHidden) + { + ShowCursor(TRUE); + window->win32.cursorHidden = GL_FALSE; + } if (GetCursorPos(&pos)) {