mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-02-10 09:41:09 +00:00
osx port: update SDLMain.m from SDL hg repository/SDL-1.2 branch.
git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@900 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
62d5a02ab4
commit
e1a715de69
1 changed files with 33 additions and 2 deletions
|
@ -62,12 +62,43 @@ BOOL gCalledAppMainline = FALSE;
|
||||||
# undef main
|
# undef main
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
static int IsRootCwd()
|
||||||
|
{
|
||||||
|
char buf[MAXPATHLEN];
|
||||||
|
char *cwd = getcwd(buf, sizeof (buf));
|
||||||
|
return (cwd && (strcmp(cwd, "/") == 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
static int IsTenPointNineOrLater()
|
||||||
|
{
|
||||||
|
/* Gestalt() is deprecated in 10.8, but I don't care. Stop using SDL 1.2. */
|
||||||
|
SInt32 major, minor;
|
||||||
|
Gestalt(gestaltSystemVersionMajor, &major);
|
||||||
|
Gestalt(gestaltSystemVersionMinor, &minor);
|
||||||
|
return ( ((major << 16) | minor) >= ((10 << 16) | 9) );
|
||||||
|
}
|
||||||
|
|
||||||
|
static int IsFinderLaunch(const int argc, char **argv)
|
||||||
|
{
|
||||||
|
const int bIsNewerOS = IsTenPointNineOrLater();
|
||||||
|
/* -psn_XXX is passed if we are launched from Finder in 10.8 and earlier */
|
||||||
|
if ( (!bIsNewerOS) && (argc >= 2) && (strncmp(argv[1], "-psn", 4) == 0) ) {
|
||||||
|
return 1;
|
||||||
|
} else if ((bIsNewerOS) && (argc == 1) && IsRootCwd()) {
|
||||||
|
/* we might still be launched from the Finder; on 10.9+, you might not
|
||||||
|
get the -psn command line anymore. Check version, if there's no
|
||||||
|
command line, and if our current working directory is "/". */
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0; /* not a Finder launch. */
|
||||||
|
}
|
||||||
|
|
||||||
/* Main entry point to executable - should *not* be SDL_main! */
|
/* Main entry point to executable - should *not* be SDL_main! */
|
||||||
int main (int argc, char **argv)
|
int main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
/* Copy the arguments into a global variable */
|
/* Copy the arguments into a global variable */
|
||||||
/* This is passed if we are launched by double-clicking */
|
if (IsFinderLaunch(argc, argv)) {
|
||||||
if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) {
|
|
||||||
gArgv = (char **) SDL_malloc(sizeof (char *) * 2);
|
gArgv = (char **) SDL_malloc(sizeof (char *) * 2);
|
||||||
gArgv[0] = argv[0];
|
gArgv[0] = argv[0];
|
||||||
gArgv[1] = NULL;
|
gArgv[1] = NULL;
|
||||||
|
|
Loading…
Reference in a new issue