mirror of
https://github.com/glfw/glfw.git
synced 2024-11-11 13:03:52 +00:00
Added tracking of cursor visibility.
This commit is contained in:
parent
608109c249
commit
6164eb603b
@ -154,6 +154,7 @@ typedef struct _GLFWwindowWin32
|
|||||||
// Various platform specific internal variables
|
// Various platform specific internal variables
|
||||||
GLboolean cursorCentered;
|
GLboolean cursorCentered;
|
||||||
GLboolean cursorInside;
|
GLboolean cursorInside;
|
||||||
|
GLboolean cursorHidden;
|
||||||
int oldCursorX, oldCursorY;
|
int oldCursorX, oldCursorY;
|
||||||
} _GLFWwindowWin32;
|
} _GLFWwindowWin32;
|
||||||
|
|
||||||
|
@ -54,20 +54,30 @@ static void hideCursor(_GLFWwindow* window)
|
|||||||
|
|
||||||
ReleaseCapture();
|
ReleaseCapture();
|
||||||
ClipCursor(NULL);
|
ClipCursor(NULL);
|
||||||
|
|
||||||
|
if (window->win32.cursorHidden)
|
||||||
|
{
|
||||||
ShowCursor(TRUE);
|
ShowCursor(TRUE);
|
||||||
|
window->win32.cursorHidden = GL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (GetCursorPos(&pos))
|
if (GetCursorPos(&pos))
|
||||||
{
|
{
|
||||||
if (WindowFromPoint(pos) == window->win32.handle)
|
if (WindowFromPoint(pos) == window->win32.handle)
|
||||||
SetCursor(NULL);
|
SetCursor(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Capture mouse cursor
|
// Capture mouse cursor
|
||||||
//
|
//
|
||||||
static void captureCursor(_GLFWwindow* window)
|
static void captureCursor(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
|
if (!window->win32.cursorHidden)
|
||||||
|
{
|
||||||
ShowCursor(FALSE);
|
ShowCursor(FALSE);
|
||||||
|
window->win32.cursorHidden = GL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
updateClipRect(window);
|
updateClipRect(window);
|
||||||
SetCapture(window->win32.handle);
|
SetCapture(window->win32.handle);
|
||||||
}
|
}
|
||||||
@ -80,7 +90,12 @@ static void showCursor(_GLFWwindow* window)
|
|||||||
|
|
||||||
ReleaseCapture();
|
ReleaseCapture();
|
||||||
ClipCursor(NULL);
|
ClipCursor(NULL);
|
||||||
|
|
||||||
|
if (window->win32.cursorHidden)
|
||||||
|
{
|
||||||
ShowCursor(TRUE);
|
ShowCursor(TRUE);
|
||||||
|
window->win32.cursorHidden = GL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (GetCursorPos(&pos))
|
if (GetCursorPos(&pos))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user