1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-26 20:28:49 -05:00

Implemented hidden cursor on Windows.

This commit is contained in:
Camilla Berglund 2013-03-11 22:57:39 +01:00
parent 26e8fde8fb
commit 200e07027c

View File

@ -50,7 +50,17 @@ static void updateClipRect(_GLFWwindow* window)
// //
static void hideCursor(_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 // Capture mouse cursor
@ -66,11 +76,17 @@ static void captureCursor(_GLFWwindow* window)
// //
static void showCursor(_GLFWwindow* window) static void showCursor(_GLFWwindow* window)
{ {
UNREFERENCED_PARAMETER(window); POINT pos;
ReleaseCapture(); ReleaseCapture();
ClipCursor(NULL); ClipCursor(NULL);
ShowCursor(TRUE); 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 // Translates a Windows key to the corresponding GLFW key
@ -597,6 +613,19 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
break; 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: case WM_DEVICECHANGE:
{ {
if (DBT_DEVNODES_CHANGED == wParam) if (DBT_DEVNODES_CHANGED == wParam)