mirror of
https://github.com/glfw/glfw.git
synced 2025-10-03 21:30:57 +00:00
Merge 737e58768d
into 26f86ac50a
This commit is contained in:
commit
c95c934920
@ -39,19 +39,31 @@ static void centerCursor(_GLFWwindow *window)
|
|||||||
_glfwPlatformSetCursorPos(window, width / 2.0, height / 2.0);
|
_glfwPlatformSetCursorPos(window, width / 2.0, height / 2.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the cursor to match the specified cursor mode
|
// Get the cursor object that window uses in the specified cursor mode
|
||||||
//
|
//
|
||||||
static void setModeCursor(_GLFWwindow* window)
|
static NSCursor* getModeCursor(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
if (window->cursorMode == GLFW_CURSOR_NORMAL)
|
if (window->cursorMode == GLFW_CURSOR_NORMAL)
|
||||||
{
|
{
|
||||||
if (window->cursor)
|
if (window->cursor)
|
||||||
[(NSCursor*) window->cursor->ns.object set];
|
return (NSCursor*) window->cursor->ns.object;
|
||||||
else
|
else
|
||||||
[[NSCursor arrowCursor] set];
|
return [NSCursor arrowCursor];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
[(NSCursor*) _glfw.ns.cursor set];
|
return (NSCursor*) _glfw.ns.cursor;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the cursor to match the specified cursor mode
|
||||||
|
//
|
||||||
|
static void updateModeCursor(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
// This is required for the cursor to update if cursor is inside the window
|
||||||
|
NSCursor* cursor = getModeCursor(window);
|
||||||
|
[cursor set];
|
||||||
|
|
||||||
|
// This is required for the cursor to update if cursor is outside the window
|
||||||
|
[window->ns.object invalidateCursorRectsForView:window->ns.view];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enter fullscreen mode
|
// Enter fullscreen mode
|
||||||
@ -197,8 +209,6 @@ static NSRect convertRectToBacking(_GLFWwindow* window, NSRect contentRect)
|
|||||||
- (void)windowDidResignKey:(NSNotification *)notification
|
- (void)windowDidResignKey:(NSNotification *)notification
|
||||||
{
|
{
|
||||||
_glfwInputWindowFocus(window, GL_FALSE);
|
_glfwInputWindowFocus(window, GL_FALSE);
|
||||||
window->cursorMode = GLFW_CURSOR_NORMAL;
|
|
||||||
_glfwPlatformApplyCursorMode(window);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
@ -480,7 +490,7 @@ static int translateKey(unsigned int key)
|
|||||||
|
|
||||||
- (void)cursorUpdate:(NSEvent *)event
|
- (void)cursorUpdate:(NSEvent *)event
|
||||||
{
|
{
|
||||||
setModeCursor(window);
|
updateModeCursor(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)mouseDown:(NSEvent *)event
|
- (void)mouseDown:(NSEvent *)event
|
||||||
@ -677,10 +687,9 @@ static int translateKey(unsigned int key)
|
|||||||
|
|
||||||
- (void)resetCursorRects
|
- (void)resetCursorRects
|
||||||
{
|
{
|
||||||
// This makes the cursor dissapear when the window is
|
NSCursor* cursor = getModeCursor(window);
|
||||||
// resized or received a drag operation
|
|
||||||
[self discardCursorRects];
|
[self addCursorRect:[self bounds] cursor:cursor];
|
||||||
[self addCursorRect:[self bounds] cursor:_glfw.ns.cursor];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
|
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
|
||||||
@ -1201,7 +1210,7 @@ void _glfwPlatformPostEmptyEvent(void)
|
|||||||
|
|
||||||
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
|
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
|
||||||
{
|
{
|
||||||
setModeCursor(window);
|
updateModeCursor(window);
|
||||||
|
|
||||||
if (window->monitor)
|
if (window->monitor)
|
||||||
{
|
{
|
||||||
@ -1221,7 +1230,7 @@ void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
|
|||||||
|
|
||||||
void _glfwPlatformApplyCursorMode(_GLFWwindow* window)
|
void _glfwPlatformApplyCursorMode(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
setModeCursor(window);
|
updateModeCursor(window);
|
||||||
|
|
||||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user