| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -72,6 +72,18 @@ NSString* GLFWNameKeys[] = | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}; | 
					 | 
					 | 
					 | 
					}; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					//======================================================================== | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					// Change to our application bundle's resources directory, if present | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					//======================================================================== | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					static void changeToResourcesDirectory(void) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					{ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    char* resourcePath = [[[NSBundle mainBundle] resourcePath] UTF8String]; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    if (access(resourcePath, R_OK) == 0) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        chdir(resourcePath); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					//======================================================================== | 
					 | 
					 | 
					 | 
					//======================================================================== | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					// Try to figure out what the calling application is called | 
					 | 
					 | 
					 | 
					// Try to figure out what the calling application is called | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					//======================================================================== | 
					 | 
					 | 
					 | 
					//======================================================================== | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -87,24 +99,18 @@ static NSString* findAppName(void) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            [name isKindOfClass:[NSString class]] && | 
					 | 
					 | 
					 | 
					            [name isKindOfClass:[NSString class]] && | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            ![@"" isEqualToString:name]) | 
					 | 
					 | 
					 | 
					            ![@"" isEqualToString:name]) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        { | 
					 | 
					 | 
					 | 
					        { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            _glfwLibrary.NS.bundled = GL_TRUE; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            return name; | 
					 | 
					 | 
					 | 
					            return name; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    // If we get here, we're unbundled | 
					 | 
					 | 
					 | 
					    // If we get here, we're unbundled | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if (!_glfwLibrary.NS.unbundled) | 
					 | 
					 | 
					 | 
					    ProcessSerialNumber psn = { 0, kCurrentProcess }; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    { | 
					 | 
					 | 
					 | 
					    TransformProcessType(&psn, kProcessTransformToForegroundApplication); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        // Could do this only if we discover we're unbundled, but it should | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        // do no harm... | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        ProcessSerialNumber psn = { 0, kCurrentProcess }; | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        TransformProcessType(&psn, kProcessTransformToForegroundApplication); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        // Having the app in front of the terminal window is also generally | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        // handy.  There is an NSApplication API to do this, but... | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        SetFrontProcess(&psn); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        _glfwLibrary.NS.unbundled = GL_TRUE; | 
					 | 
					 | 
					 | 
					    // Having the app in front of the terminal window is also generally | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    // handy.  There is an NSApplication API to do this, but... | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    SetFrontProcess(&psn); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    char** progname = _NSGetProgname(); | 
					 | 
					 | 
					 | 
					    char** progname = _NSGetProgname(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if (progname && *progname) | 
					 | 
					 | 
					 | 
					    if (progname && *progname) | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -210,16 +216,16 @@ int _glfwPlatformInit(void) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return GL_FALSE; | 
					 | 
					 | 
					 | 
					        return GL_FALSE; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    NSString* resourcePath = [[NSBundle mainBundle] resourcePath]; | 
					 | 
					 | 
					 | 
					    // Setting up the menu bar must go between sharedApplication | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					    // above and finishLaunching below, in order to properly emulate the | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if (access([resourcePath cStringUsingEncoding:NSUTF8StringEncoding], R_OK) == 0) | 
					 | 
					 | 
					 | 
					    // behavior of NSApplicationMain | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        chdir([resourcePath cStringUsingEncoding:NSUTF8StringEncoding]); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    // Setting up menu bar must go exactly here else weirdness ensues | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    setUpMenuBar(); | 
					 | 
					 | 
					 | 
					    setUpMenuBar(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    [NSApp finishLaunching]; | 
					 | 
					 | 
					 | 
					    [NSApp finishLaunching]; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    if (_glfwLibrary.NS.bundled) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        changeToResourcesDirectory(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    _glfwPlatformSetTime(0.0); | 
					 | 
					 | 
					 | 
					    _glfwPlatformSetTime(0.0); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    _glfwLibrary.NS.desktopMode = | 
					 | 
					 | 
					 | 
					    _glfwLibrary.NS.desktopMode = | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |