Mac: Fix unmatched hide/show cursor calls.
authorJørgen P. Tjernø <jorgen@valvesoftware.com>
Tue, 23 Apr 2013 18:47:41 -0700
changeset 7099 54f187c036e2
parent 7098 f4b2c6fb0258
child 7100 ffd910de700b
Mac: Fix unmatched hide/show cursor calls. This tracks the previous hide/unhide state of the cursor, so we don't re-hide a hidden cursor.
src/video/cocoa/SDL_cocoamouse.m
--- a/src/video/cocoa/SDL_cocoamouse.m	Tue Apr 23 18:47:38 2013 -0700
+++ b/src/video/cocoa/SDL_cocoamouse.m	Tue Apr 23 18:47:41 2013 -0700
@@ -153,15 +153,24 @@
 static int
 Cocoa_ShowCursor(SDL_Cursor * cursor)
 {
+	/* We need to track the previous state because hide and unhide calls need to
+	 * be matched, but ShowCursor calls don't.
+	 */
+	static SDL_bool isShown = SDL_TRUE;
     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
 
     if (cursor) {
         NSCursor *nscursor = (NSCursor *)cursor->driverdata;
 
         [nscursor set];
-        [NSCursor unhide];
-    } else {
-        [NSCursor hide];
+
+		if (!isShown) {
+			[NSCursor unhide];
+			isShown = SDL_TRUE;
+		}
+	} else if (isShown) {
+		[NSCursor hide];
+		isShown = SDL_FALSE;
     }
 
     [pool release];