Mac: Fix cursor not updating when re-focusing the window.
authorJørgen P. Tjernø <jorgen@valvesoftware.com>
Tue, 23 Apr 2013 18:47:44 -0700
changeset 7100 ffd910de700b
parent 7099 54f187c036e2
child 7101 ea2e8eb622e1
Mac: Fix cursor not updating when re-focusing the window. This fixes a bug where [NSCursor set] doesn't take when called in certain event handlers (like windowDidBecomeKey:). http://bugzilla.libsdl.org/show_bug.cgi?id=1795
src/video/cocoa/SDL_cocoamouse.m
--- a/src/video/cocoa/SDL_cocoamouse.m	Tue Apr 23 18:47:41 2013 -0700
+++ b/src/video/cocoa/SDL_cocoamouse.m	Tue Apr 23 18:47:44 2013 -0700
@@ -162,7 +162,13 @@
     if (cursor) {
         NSCursor *nscursor = (NSCursor *)cursor->driverdata;
 
-        [nscursor set];
+        /* We're possibly executing from an event handler where this operation
+         * is unsupported. This will execute it in the main Cocoa event loop
+         * after this returns.
+         */
+        [nscursor performSelectorOnMainThread:@selector(set)
+                                   withObject:nil
+                                waitUntilDone:NO];
 
 		if (!isShown) {
 			[NSCursor unhide];