src/main/macosx/SDLMain.m
changeset 168 e92aa316c517
parent 158 4382c38dfbee
     1.1 --- a/src/main/macosx/SDLMain.m	Tue Sep 04 22:53:46 2001 +0000
     1.2 +++ b/src/main/macosx/SDLMain.m	Tue Sep 04 23:18:45 2001 +0000
     1.3 @@ -12,6 +12,7 @@
     1.4  static int    gArgc;
     1.5  static char  **gArgv;
     1.6  static NSString *gAppName = 0;
     1.7 +static BOOL   gFinderLaunch;
     1.8  
     1.9  @interface NSString (ReplaceSubString)
    1.10  - (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString;
    1.11 @@ -29,15 +30,21 @@
    1.12      SDL_PushEvent(&event);
    1.13  }
    1.14  
    1.15 +/* Invoked from the Make Full-Screen menu item */
    1.16 +- (void) makeFullscreen:(id)sender
    1.17 +{
    1.18 +    /* TODO */
    1.19 +}
    1.20 +
    1.21  /* Set the working directory to the .app's parent directory */
    1.22 -- (void) setupWorkingDirectory
    1.23 +- (void) setupWorkingDirectory:(BOOL)shouldChdir
    1.24  {
    1.25      char parentdir[MAXPATHLEN];
    1.26      char *c;
    1.27      
    1.28      strncpy ( parentdir, gArgv[0], sizeof(parentdir) );
    1.29      c = (char*) parentdir;
    1.30 -    
    1.31 +
    1.32      while (*c != '\0')     /* go to end */
    1.33          c++;
    1.34      
    1.35 @@ -45,11 +52,13 @@
    1.36          c--;
    1.37      
    1.38      *c++ = '\0';             /* cut off last part (binary name) */
    1.39 -    
    1.40 -    assert ( chdir (parentdir) == 0 );   /* chdir to the binary app's parent */
    1.41 -    assert ( chdir ("../../../") == 0 ); /* chdir to the .app's parent */
    1.42 -    
    1.43 -    gAppName = [ NSString stringWithCString: c ];
    1.44 +  
    1.45 +    if (shouldChdir)
    1.46 +    {
    1.47 +      assert ( chdir (parentdir) == 0 );   /* chdir to the binary app's parent */
    1.48 +      assert ( chdir ("../../../") == 0 ); /* chdir to the .app's parent */
    1.49 +    }
    1.50 +    /* gAppName = [ NSString stringWithCString: c ]; */
    1.51  }
    1.52  
    1.53  /* Fix menu to contain the real app name instead of "SDL App" */
    1.54 @@ -81,9 +90,10 @@
    1.55      int status;
    1.56  
    1.57      /* Set the working directory to the .app's parent directory */
    1.58 -    [ self setupWorkingDirectory ];
    1.59 +    [ self setupWorkingDirectory: gFinderLaunch ];
    1.60  
    1.61      /* Set the main menu to contain the real app name instead of "SDL App" */
    1.62 +    gAppName = [ [ NSBundle mainBundle ] bundleIdentifier ];
    1.63      [ self fixMenu: [ NSApp mainMenu ] ];
    1.64  
    1.65      /* Hand off to main application code */
    1.66 @@ -148,8 +158,10 @@
    1.67      /* This is passed if we are launched by double-clicking */
    1.68      if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) {
    1.69          gArgc = 1;
    1.70 +	gFinderLaunch = YES;
    1.71      } else {
    1.72          gArgc = argc;
    1.73 +	gFinderLaunch = NO;
    1.74      }
    1.75      gArgv = (char**) malloc (sizeof(*gArgv) * (gArgc+1));
    1.76      assert (gArgv != NULL);