1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-23 02:38:52 -05:00

Fixed captured cursor mode on OS X.

This commit is contained in:
Camilla Berglund 2013-04-22 00:38:51 +02:00
parent 7423cfa5bf
commit 3ec843a1da
2 changed files with 29 additions and 17 deletions

View File

@ -109,6 +109,8 @@ typedef struct _GLFWlibraryNS
id autoreleasePool;
id cursor;
GLboolean cursorHidden;
char* clipboardString;
_GLFWjoy joysticks[GLFW_JOYSTICK_LAST + 1];

View File

@ -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;
}
}
}