mirror of
https://github.com/glfw/glfw.git
synced 2025-06-14 19:52:14 +00:00
Merge 1f8ef64b30
into 4ff8095dee
This commit is contained in:
commit
7bfc92ad10
@ -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];
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user