mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 21:14:35 +00:00
OS X hidden cursor cleanup.
This commit is contained in:
parent
74d6a5d883
commit
a2745574c8
@ -124,6 +124,9 @@ void _glfwPlatformTerminate(void)
|
|||||||
[_glfw.ns.autoreleasePool release];
|
[_glfw.ns.autoreleasePool release];
|
||||||
_glfw.ns.autoreleasePool = nil;
|
_glfw.ns.autoreleasePool = nil;
|
||||||
|
|
||||||
|
[_glfw.ns.cursor release];
|
||||||
|
_glfw.ns.cursor = nil;
|
||||||
|
|
||||||
_glfwTerminateJoysticks();
|
_glfwTerminateJoysticks();
|
||||||
|
|
||||||
_glfwTerminateContextAPI();
|
_glfwTerminateContextAPI();
|
||||||
|
@ -107,6 +107,7 @@ typedef struct _GLFWlibraryNS
|
|||||||
CGEventSourceRef eventSource;
|
CGEventSourceRef eventSource;
|
||||||
id delegate;
|
id delegate;
|
||||||
id autoreleasePool;
|
id autoreleasePool;
|
||||||
|
id cursor;
|
||||||
|
|
||||||
char* clipboardString;
|
char* clipboardString;
|
||||||
|
|
||||||
|
@ -48,14 +48,11 @@
|
|||||||
|
|
||||||
@implementation GLFWWindowDelegate
|
@implementation GLFWWindowDelegate
|
||||||
|
|
||||||
static void resetMouseCursor(_GLFWwindow *window)
|
static void centerCursor(_GLFWwindow *window)
|
||||||
{
|
{
|
||||||
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
int width, height;
|
||||||
{
|
_glfwPlatformGetWindowSize(window, &width, &height);
|
||||||
int width, height;
|
_glfwPlatformSetCursorPos(window, width / 2.0, height / 2.0);
|
||||||
_glfwPlatformGetWindowSize(window, &width, &height);
|
|
||||||
_glfwPlatformSetCursorPos(window, width / 2.0, height / 2.0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)initWithGlfwWindow:(_GLFWwindow *)initWindow
|
- (id)initWithGlfwWindow:(_GLFWwindow *)initWindow
|
||||||
@ -82,7 +79,8 @@ static void resetMouseCursor(_GLFWwindow *window)
|
|||||||
_glfwInputWindowSize(window, width, height);
|
_glfwInputWindowSize(window, width, height);
|
||||||
_glfwInputWindowDamage(window);
|
_glfwInputWindowDamage(window);
|
||||||
|
|
||||||
resetMouseCursor(window);
|
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
||||||
|
centerCursor(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)windowDidMove:(NSNotification *)notification
|
- (void)windowDidMove:(NSNotification *)notification
|
||||||
@ -93,7 +91,8 @@ static void resetMouseCursor(_GLFWwindow *window)
|
|||||||
_glfwPlatformGetWindowPos(window, &x, &y);
|
_glfwPlatformGetWindowPos(window, &x, &y);
|
||||||
_glfwInputWindowPos(window, x, y);
|
_glfwInputWindowPos(window, x, y);
|
||||||
|
|
||||||
resetMouseCursor(window);
|
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
||||||
|
centerCursor(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)windowDidMiniaturize:(NSNotification *)notification
|
- (void)windowDidMiniaturize:(NSNotification *)notification
|
||||||
@ -110,7 +109,8 @@ static void resetMouseCursor(_GLFWwindow *window)
|
|||||||
{
|
{
|
||||||
_glfwInputWindowFocus(window, GL_TRUE);
|
_glfwInputWindowFocus(window, GL_TRUE);
|
||||||
|
|
||||||
resetMouseCursor(window);
|
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
||||||
|
centerCursor(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)windowDidResignKey:(NSNotification *)notification
|
- (void)windowDidResignKey:(NSNotification *)notification
|
||||||
@ -310,8 +310,6 @@ static int convertMacKeyCode(unsigned int macKeyCode)
|
|||||||
// Content view class for the GLFW window
|
// Content view class for the GLFW window
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
|
|
||||||
static NSCursor *emptyCursor = nil;
|
|
||||||
|
|
||||||
@interface GLFWContentView : NSView
|
@interface GLFWContentView : NSView
|
||||||
{
|
{
|
||||||
_GLFWwindow* window;
|
_GLFWwindow* window;
|
||||||
@ -328,9 +326,13 @@ static NSCursor *emptyCursor = nil;
|
|||||||
{
|
{
|
||||||
if (self == [GLFWContentView class])
|
if (self == [GLFWContentView class])
|
||||||
{
|
{
|
||||||
NSImage *emptyImage = [[NSImage alloc] initWithSize:NSMakeSize(1, 1)];
|
if (_glfw.ns.cursor == nil)
|
||||||
emptyCursor = [[NSCursor alloc] initWithImage:emptyImage hotSpot:NSZeroPoint];
|
{
|
||||||
[emptyImage release];
|
NSImage* data = [[NSImage alloc] initWithSize:NSMakeSize(1, 1)];
|
||||||
|
_glfw.ns.cursor = [[NSCursor alloc] initWithImage:data
|
||||||
|
hotSpot:NSZeroPoint];
|
||||||
|
[data release];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -509,7 +511,7 @@ static NSCursor *emptyCursor = nil;
|
|||||||
|
|
||||||
- (void)resetCursorRects
|
- (void)resetCursorRects
|
||||||
{
|
{
|
||||||
[self addCursorRect:[self bounds] cursor:emptyCursor];
|
[self addCursorRect:[self bounds] cursor:_glfw.ns.cursor];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
Loading…
Reference in New Issue
Block a user