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 7100ffd910de700b
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
     1.1 --- a/src/video/cocoa/SDL_cocoamouse.m	Tue Apr 23 18:47:41 2013 -0700
     1.2 +++ b/src/video/cocoa/SDL_cocoamouse.m	Tue Apr 23 18:47:44 2013 -0700
     1.3 @@ -162,7 +162,13 @@
     1.4      if (cursor) {
     1.5          NSCursor *nscursor = (NSCursor *)cursor->driverdata;
     1.6  
     1.7 -        [nscursor set];
     1.8 +        /* We're possibly executing from an event handler where this operation
     1.9 +         * is unsupported. This will execute it in the main Cocoa event loop
    1.10 +         * after this returns.
    1.11 +         */
    1.12 +        [nscursor performSelectorOnMainThread:@selector(set)
    1.13 +                                   withObject:nil
    1.14 +                                waitUntilDone:NO];
    1.15  
    1.16  		if (!isShown) {
    1.17  			[NSCursor unhide];