Implemented hidden cursor on Windows.

master
Camilla Berglund ago%!(EXTRA string=12 years)
parent 26e8fde8fb
commit 200e07027c
  1. 33
      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)

Loading…
Cancel
Save