From 200e07027c819d0effe833ee6debba59cb8c395b Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Mon, 11 Mar 2013 22:57:39 +0100 Subject: [PATCH] Implemented hidden cursor on Windows. --- src/win32_window.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/win32_window.c b/src/win32_window.c index ad98bde2..c8b4eda6 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -50,7 +50,17 @@ static void updateClipRect(_GLFWwindow* window) // static void hideCursor(_GLFWwindow* window) { - UNREFERENCED_PARAMETER(window); + POINT pos; + + ReleaseCapture(); + ClipCursor(NULL); + ShowCursor(TRUE); + + if (GetCursorPos(&pos)) + { + if (WindowFromPoint(pos) == window->win32.handle) + SetCursor(NULL); + } } // Capture mouse cursor @@ -66,11 +76,17 @@ static void captureCursor(_GLFWwindow* window) // static void showCursor(_GLFWwindow* window) { - UNREFERENCED_PARAMETER(window); + POINT pos; ReleaseCapture(); ClipCursor(NULL); ShowCursor(TRUE); + + if (GetCursorPos(&pos)) + { + if (WindowFromPoint(pos) == window->win32.handle) + SetCursor(LoadCursor(NULL, IDC_ARROW)); + } } // Translates a Windows key to the corresponding GLFW key @@ -597,6 +613,19 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, break; } + case WM_SETCURSOR: + { + if (window->cursorMode == GLFW_CURSOR_HIDDEN && + window->win32.handle == GetForegroundWindow() && + LOWORD(lParam) == HTCLIENT) + { + SetCursor(NULL); + return TRUE; + } + + break; + } + case WM_DEVICECHANGE: { if (DBT_DEVNODES_CHANGED == wParam)