diff --git a/src/SFML/Window/OSX/SFApplication.m b/src/SFML/Window/OSX/SFApplication.m index 0cee6045b..cc4840624 100644 --- a/src/SFML/Window/OSX/SFApplication.m +++ b/src/SFML/Window/OSX/SFApplication.m @@ -49,10 +49,10 @@ } // If there are some other event read them. - while (event = [NSApp nextEventMatchingMask:NSAnyEventMask - untilDate:[NSDate distantPast] - inMode:NSDefaultRunLoopMode - dequeue:YES]) // Remove the event from the dequeue + while ((event = [NSApp nextEventMatchingMask:NSAnyEventMask + untilDate:[NSDate distantPast] + inMode:NSDefaultRunLoopMode + dequeue:YES])) // Remove the event from the dequeue { [NSApp sendEvent:event]; } diff --git a/src/SFML/Window/OSX/SFContext.mm b/src/SFML/Window/OSX/SFContext.mm index 3e5b120cf..2479dd97b 100644 --- a/src/SFML/Window/OSX/SFContext.mm +++ b/src/SFML/Window/OSX/SFContext.mm @@ -30,7 +30,6 @@ #include #include - /* * DISCUSSION : * ============ @@ -57,6 +56,9 @@ SFContext::SFContext(SFContext* shared) // Create the context CreateContext(shared, 0, ContextSettings(0, 0, 0)); + + // Activate the context + SetActive(true); } @@ -72,6 +74,9 @@ SFContext::SFContext(SFContext* shared, const WindowImpl* owner, // Apply context. WindowImplCocoa const * ownerCocoa = static_cast(owner); ownerCocoa->ApplyContext(myContext); + + // Activate the context + SetActive(true); } @@ -106,12 +111,12 @@ void SFContext::Display() void SFContext::EnableVerticalSync(bool enabled) { // Make compiler happy -#ifdef USE_OS_X_VERSION_10_4 - long int swapInterval = enabled ? 1 : 0; -#else /* USE_OS_X_VERSION_10_6 */ - GLint swapInterval = enabled ? 1 : 0; +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060 + typedef int GLint; #endif + GLint swapInterval = enabled ? 1 : 0; + [myContext setValues:&swapInterval forParameter:NSOpenGLCPSwapInterval]; } diff --git a/src/SFML/Window/OSX/SFWindowController.mm b/src/SFML/Window/OSX/SFWindowController.mm index 6999b520a..dd6b81834 100644 --- a/src/SFML/Window/OSX/SFWindowController.mm +++ b/src/SFML/Window/OSX/SFWindowController.mm @@ -105,6 +105,19 @@ //////////////////////////////////////////////////////// -(id)initWithMode:(sf::VideoMode const &)mode andStyle:(unsigned long)style { + // If we are not on the main thread we stop here and advice the user. + if ([NSThread currentThread] != [NSThread mainThread]) { + /* + * See http://lists.apple.com/archives/cocoa-dev/2011/Feb/msg00460.html + * for more information. + */ + sf::Err() + << "Cannot create a window from a worker thread. (OS X limitation)" + << std::endl; + + return nil; + } + if ((self = [super init])) { myRequester = 0; @@ -414,6 +427,19 @@ //////////////////////////////////////////////////////// -(void)processEventWithBlockingMode:(BOOL)block { + // If we are not on the main thread we stop here and advice the user. + if ([NSThread currentThread] != [NSThread mainThread]) { + /* + * See http://lists.apple.com/archives/cocoa-dev/2011/Feb/msg00460.html + * for more information. + */ + sf::Err() + << "Cannot fetch event from a worker thread. (OS X limitation)" + << std::endl; + + return; + } + // If we don't have a requester we don't fetch event. if (myRequester != 0) { [SFApplication processEventWithBlockingMode:block];