This commit is contained in:
Noel Cower 2013-09-18 09:53:12 -07:00
commit 7bfc92ad10
2 changed files with 9 additions and 29 deletions

View File

@ -67,6 +67,7 @@ typedef struct _GLFWwindowNS
id delegate;
id view;
unsigned int modifierFlags;
GLboolean cursorHidden;
} _GLFWwindowNS;
@ -105,8 +106,6 @@ typedef struct _GLFWlibraryNS
id autoreleasePool;
id cursor;
GLboolean cursorHidden;
char* clipboardString;
_GLFWjoy joysticks[GLFW_JOYSTICK_LAST + 1];

View File

@ -628,7 +628,8 @@ static int translateKey(unsigned int key)
- (void)resetCursorRects
{
[self discardCursorRects];
[self addCursorRect:[self bounds] cursor:_glfw.ns.cursor];
if (window->ns.cursorHidden)
[self addCursorRect:[self bounds] cursor:_glfw.ns.cursor];
}
@end
@ -848,7 +849,7 @@ static GLboolean createWindow(_GLFWwindow* window,
[window->ns.object setContentView:window->ns.view];
[window->ns.object setDelegate:window->ns.delegate];
[window->ns.object setAcceptsMouseMovedEvents:YES];
[window->ns.object disableCursorRects];
[window->ns.object enableCursorRects];
[window->ns.object center];
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
@ -1058,37 +1059,17 @@ void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
{
if (mode == GLFW_CURSOR_HIDDEN)
{
[window->ns.object enableCursorRects];
[window->ns.object invalidateCursorRectsForView:window->ns.view];
}
if (mode == GLFW_CURSOR_NORMAL)
window->ns.cursorHidden = GL_FALSE;
else
{
[window->ns.object disableCursorRects];
[window->ns.object invalidateCursorRectsForView:window->ns.view];
}
window->ns.cursorHidden = GL_TRUE;
[window->ns.object invalidateCursorRectsForView:window->ns.view];
if (mode == GLFW_CURSOR_DISABLED)
{
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;
}
}
}