playmus/playwave XCode: update SDLMain.m from SDL-1.2. fix SDL_mixer framework name. SDL-1.2
authorOzkan Sezer <sezeroz@gmail.com>
Sun, 06 Oct 2019 17:15:40 +0300
branchSDL-1.2
changeset 953bb7d11f913cd
parent 948 3546f037f9da
playmus/playwave XCode: update SDLMain.m from SDL-1.2. fix SDL_mixer framework name.
Xcode/playmus/SDLMain.m
Xcode/playmus/playmus.xcodeproj/project.pbxproj
Xcode/playwave/playwave.xcodeproj/project.pbxproj
     1.1 --- a/Xcode/playmus/SDLMain.m	Wed Sep 11 20:20:02 2019 +0300
     1.2 +++ b/Xcode/playmus/SDLMain.m	Sun Oct 06 17:15:40 2019 +0300
     1.3 @@ -5,7 +5,7 @@
     1.4      Feel free to customize this file to suit your needs
     1.5  */
     1.6  
     1.7 -#include <SDL/SDL.h>
     1.8 +#include "SDL.h"
     1.9  #include "SDLMain.h"
    1.10  #include <sys/param.h> /* for MAXPATHLEN */
    1.11  #include <unistd.h>
    1.12 @@ -20,22 +20,6 @@
    1.13  /* Use this flag to determine whether we use SDLMain.nib or not */
    1.14  #define		SDL_USE_NIB_FILE	0
    1.15  
    1.16 -/* Use this flag to determine whether we use CPS (docking) or not */
    1.17 -#define		SDL_USE_CPS		1
    1.18 -#ifdef SDL_USE_CPS
    1.19 -/* Portions of CPS.h */
    1.20 -typedef struct CPSProcessSerNum
    1.21 -{
    1.22 -	UInt32		lo;
    1.23 -	UInt32		hi;
    1.24 -} CPSProcessSerNum;
    1.25 -
    1.26 -extern OSErr	CPSGetCurrentProcess( CPSProcessSerNum *psn);
    1.27 -extern OSErr 	CPSEnableForegroundOperation( CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5);
    1.28 -extern OSErr	CPSSetFrontProcess( CPSProcessSerNum *psn);
    1.29 -
    1.30 -#endif /* SDL_USE_CPS */
    1.31 -
    1.32  static int    gArgc;
    1.33  static char  **gArgv;
    1.34  static BOOL   gFinderLaunch;
    1.35 @@ -64,10 +48,10 @@
    1.36  @end
    1.37  #endif
    1.38  
    1.39 -@interface SDLApplication : NSApplication
    1.40 +@interface NSApplication (SDLApplication)
    1.41  @end
    1.42  
    1.43 -@implementation SDLApplication
    1.44 +@implementation NSApplication (SDLApplication)
    1.45  /* Invoked from the Quit menu item */
    1.46  - (void)terminate:(id)sender
    1.47  {
    1.48 @@ -119,7 +103,6 @@
    1.49          if ([menuItem hasSubmenu])
    1.50              [self fixMenu:[menuItem submenu] withAppName:appName];
    1.51      }
    1.52 -    [ aMenu sizeToFit ];
    1.53  }
    1.54  
    1.55  #else
    1.56 @@ -202,18 +185,7 @@
    1.57      SDLMain				*sdlMain;
    1.58  
    1.59      /* Ensure the application object is initialised */
    1.60 -    [SDLApplication sharedApplication];
    1.61 -    
    1.62 -#ifdef SDL_USE_CPS
    1.63 -    {
    1.64 -        CPSProcessSerNum PSN;
    1.65 -        /* Tell the dock about us */
    1.66 -        if (!CPSGetCurrentProcess(&PSN))
    1.67 -            if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103))
    1.68 -                if (!CPSSetFrontProcess(&PSN))
    1.69 -                    [SDLApplication sharedApplication];
    1.70 -    }
    1.71 -#endif /* SDL_USE_CPS */
    1.72 +    [[NSApplication sharedApplication] activateIgnoringOtherApps: YES];
    1.73  
    1.74      /* Set up the menubar */
    1.75      [NSApp setMainMenu:[[NSMenu alloc] init]];
    1.76 @@ -346,18 +318,38 @@
    1.77  @end
    1.78  
    1.79  
    1.80 -
    1.81  #ifdef main
    1.82  #  undef main
    1.83  #endif
    1.84  
    1.85  
    1.86 +static int IsRootCwd()
    1.87 +{
    1.88 +    char buf[MAXPATHLEN];
    1.89 +    char *cwd = getcwd(buf, sizeof (buf));
    1.90 +    return (cwd && (strcmp(cwd, "/") == 0));
    1.91 +}
    1.92 +
    1.93 +static int IsFinderLaunch(const int argc, char **argv)
    1.94 +{
    1.95 +    /* -psn_XXX is passed if we are launched from Finder, SOMETIMES */
    1.96 +    if ( (argc >= 2) && (strncmp(argv[1], "-psn", 4) == 0) ) {
    1.97 +        return 1;
    1.98 +    } else if ((argc == 1) && IsRootCwd()) {
    1.99 +        /* we might still be launched from the Finder; on 10.9+, you might not
   1.100 +        get the -psn command line anymore. If there's no
   1.101 +        command line, and if our current working directory is "/", it
   1.102 +        might as well be a Finder launch. */
   1.103 +        return 1;
   1.104 +    }
   1.105 +    return 0;  /* not a Finder launch. */
   1.106 +}
   1.107 +
   1.108  /* Main entry point to executable - should *not* be SDL_main! */
   1.109  int main (int argc, char **argv)
   1.110  {
   1.111      /* Copy the arguments into a global variable */
   1.112 -    /* This is passed if we are launched by double-clicking */
   1.113 -    if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) {
   1.114 +    if (IsFinderLaunch(argc, argv)) {
   1.115          gArgv = (char **) SDL_malloc(sizeof (char *) * 2);
   1.116          gArgv[0] = argv[0];
   1.117          gArgv[1] = NULL;
   1.118 @@ -373,7 +365,6 @@
   1.119      }
   1.120  
   1.121  #if SDL_USE_NIB_FILE
   1.122 -    [SDLApplication poseAsClass:[NSApplication class]];
   1.123      NSApplicationMain (argc, argv);
   1.124  #else
   1.125      CustomApplicationMain (argc, argv);
     2.1 --- a/Xcode/playmus/playmus.xcodeproj/project.pbxproj	Wed Sep 11 20:20:02 2019 +0300
     2.2 +++ b/Xcode/playmus/playmus.xcodeproj/project.pbxproj	Sun Oct 06 17:15:40 2019 +0300
     2.3 @@ -221,8 +221,8 @@
     2.4  				HEADER_SEARCH_PATHS = (
     2.5  					"$(HOME)/Library/Frameworks/SDL.framework/Headers",
     2.6  					/Library/Frameworks/SDL.framework/Headers,
     2.7 -					"$(HOME)/Library/Frameworks/SDLmixer.framework/Headers",
     2.8 -					/Library/Frameworks/SDLmixer.framework/Headers,
     2.9 +					"$(HOME)/Library/Frameworks/SDL_mixer.framework/Headers",
    2.10 +					/Library/Frameworks/SDL_mixer.framework/Headers,
    2.11  				);
    2.12  				INFOPLIST_FILE = "Info-playmus__Upgraded_.plist";
    2.13  				INSTALL_PATH = "$(HOME)/Applications";
    2.14 @@ -253,8 +253,8 @@
    2.15  				HEADER_SEARCH_PATHS = (
    2.16  					"$(HOME)/Library/Frameworks/SDL.framework/Headers",
    2.17  					/Library/Frameworks/SDL.framework/Headers,
    2.18 -					"$(HOME)/Library/Frameworks/SDLmixer.framework/Headers",
    2.19 -					/Library/Frameworks/SDLmixer.framework/Headers,
    2.20 +					"$(HOME)/Library/Frameworks/SDL_mixer.framework/Headers",
    2.21 +					/Library/Frameworks/SDL_mixer.framework/Headers,
    2.22  				);
    2.23  				INFOPLIST_FILE = "Info-playmus__Upgraded_.plist";
    2.24  				INSTALL_PATH = "$(HOME)/Applications";
    2.25 @@ -282,8 +282,8 @@
    2.26  				HEADER_SEARCH_PATHS = (
    2.27  					"$(HOME)/Library/Frameworks/SDL.framework/Headers",
    2.28  					/Library/Frameworks/SDL.framework/Headers,
    2.29 -					"$(HOME)/Library/Frameworks/SDLmixer.framework/Headers",
    2.30 -					/Library/Frameworks/SDLmixer.framework/Headers,
    2.31 +					"$(HOME)/Library/Frameworks/SDL_mixer.framework/Headers",
    2.32 +					/Library/Frameworks/SDL_mixer.framework/Headers,
    2.33  				);
    2.34  				INFOPLIST_FILE = "Info-playmus__Upgraded_.plist";
    2.35  				INSTALL_PATH = "$(HOME)/Applications";
     3.1 --- a/Xcode/playwave/playwave.xcodeproj/project.pbxproj	Wed Sep 11 20:20:02 2019 +0300
     3.2 +++ b/Xcode/playwave/playwave.xcodeproj/project.pbxproj	Sun Oct 06 17:15:40 2019 +0300
     3.3 @@ -224,8 +224,8 @@
     3.4  				HEADER_SEARCH_PATHS = (
     3.5  					"$(HOME)/Library/Frameworks/SDL.framework/Headers",
     3.6  					/Library/Frameworks/SDL.framework/Headers,
     3.7 -					"$(HOME)/Library/Frameworks/SDLmixer.framework/Headers",
     3.8 -					/Library/Frameworks/SDLmixer.framework/Headers,
     3.9 +					"$(HOME)/Library/Frameworks/SDL_mixer.framework/Headers",
    3.10 +					/Library/Frameworks/SDL_mixer.framework/Headers,
    3.11  				);
    3.12  				INFOPLIST_FILE = "Info-playwave__Upgraded_.plist";
    3.13  				INSTALL_PATH = "$(HOME)/Applications";
    3.14 @@ -254,8 +254,8 @@
    3.15  				HEADER_SEARCH_PATHS = (
    3.16  					"$(HOME)/Library/Frameworks/SDL.framework/Headers",
    3.17  					/Library/Frameworks/SDL.framework/Headers,
    3.18 -					"$(HOME)/Library/Frameworks/SDLmixer.framework/Headers",
    3.19 -					/Library/Frameworks/SDLmixer.framework/Headers,
    3.20 +					"$(HOME)/Library/Frameworks/SDL_mixer.framework/Headers",
    3.21 +					/Library/Frameworks/SDL_mixer.framework/Headers,
    3.22  				);
    3.23  				INFOPLIST_FILE = "Info-playwave__Upgraded_.plist";
    3.24  				INSTALL_PATH = "$(HOME)/Applications";
    3.25 @@ -283,8 +283,8 @@
    3.26  				HEADER_SEARCH_PATHS = (
    3.27  					"$(HOME)/Library/Frameworks/SDL.framework/Headers",
    3.28  					/Library/Frameworks/SDL.framework/Headers,
    3.29 -					"$(HOME)/Library/Frameworks/SDLmixer.framework/Headers",
    3.30 -					/Library/Frameworks/SDLmixer.framework/Headers,
    3.31 +					"$(HOME)/Library/Frameworks/SDL_mixer.framework/Headers",
    3.32 +					/Library/Frameworks/SDL_mixer.framework/Headers,
    3.33  				);
    3.34  				INFOPLIST_FILE = "Info-playwave__Upgraded_.plist";
    3.35  				INSTALL_PATH = "$(HOME)/Applications";