mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 13:04:35 +00:00
Fixed captured cursor mode on OS X.
This commit is contained in:
parent
7423cfa5bf
commit
3ec843a1da
@ -109,6 +109,8 @@ typedef struct _GLFWlibraryNS
|
||||
id autoreleasePool;
|
||||
id cursor;
|
||||
|
||||
GLboolean cursorHidden;
|
||||
|
||||
char* clipboardString;
|
||||
|
||||
_GLFWjoy joysticks[GLFW_JOYSTICK_LAST + 1];
|
||||
|
@ -942,26 +942,36 @@ void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
|
||||
|
||||
void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
|
||||
{
|
||||
// Unhide the cursor if the last mode was CAPTURED.
|
||||
if (window->cursorMode == GLFW_CURSOR_CAPTURED) {
|
||||
CGAssociateMouseAndMouseCursorPosition(true);
|
||||
if (mode == GLFW_CURSOR_HIDDEN)
|
||||
{
|
||||
[window->ns.object enableCursorRects];
|
||||
[window->ns.object invalidateCursorRectsForView:window->ns.view];
|
||||
}
|
||||
else
|
||||
{
|
||||
[window->ns.object disableCursorRects];
|
||||
[window->ns.object invalidateCursorRectsForView:window->ns.view];
|
||||
}
|
||||
|
||||
switch (mode)
|
||||
if (mode == GLFW_CURSOR_CAPTURED)
|
||||
{
|
||||
case GLFW_CURSOR_NORMAL:
|
||||
[window->ns.object disableCursorRects];
|
||||
[window->ns.object invalidateCursorRectsForView:window->ns.view];
|
||||
break;
|
||||
case GLFW_CURSOR_HIDDEN:
|
||||
[window->ns.object enableCursorRects];
|
||||
[window->ns.object invalidateCursorRectsForView:window->ns.view];
|
||||
break;
|
||||
case GLFW_CURSOR_CAPTURED:
|
||||
[window->ns.object enableCursorRects];
|
||||
[window->ns.object invalidateCursorRectsForView:window->ns.view];
|
||||
CGAssociateMouseAndMouseCursorPosition(false);
|
||||
break;
|
||||
CGAssociateMouseAndMouseCursorPosition(false);
|
||||
|
||||
if (!_glfw.ns.cursorHidden)
|
||||
{
|
||||
[NSCursor hide];
|
||||
_glfw.ns.cursorHidden = GL_TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CGAssociateMouseAndMouseCursorPosition(true);
|
||||
|
||||
if (_glfw.ns.cursorHidden)
|
||||
{
|
||||
[NSCursor unhide];
|
||||
_glfw.ns.cursorHidden = GL_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user