1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-23 10:48:51 -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 autoreleasePool;
id cursor; id cursor;
GLboolean cursorHidden;
char* clipboardString; char* clipboardString;
_GLFWjoy joysticks[GLFW_JOYSTICK_LAST + 1]; _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) void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
{ {
// Unhide the cursor if the last mode was CAPTURED. if (mode == GLFW_CURSOR_HIDDEN)
if (window->cursorMode == GLFW_CURSOR_CAPTURED) { {
CGAssociateMouseAndMouseCursorPosition(true); [window->ns.object enableCursorRects];
} [window->ns.object invalidateCursorRectsForView:window->ns.view];
}
switch (mode) else
{ {
case GLFW_CURSOR_NORMAL:
[window->ns.object disableCursorRects]; [window->ns.object disableCursorRects];
[window->ns.object invalidateCursorRectsForView:window->ns.view]; [window->ns.object invalidateCursorRectsForView:window->ns.view];
break; }
case GLFW_CURSOR_HIDDEN:
[window->ns.object enableCursorRects]; if (mode == GLFW_CURSOR_CAPTURED)
[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); CGAssociateMouseAndMouseCursorPosition(false);
break;
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;
}
} }
} }