Mercurial > sdl-ios-xcode
annotate src/main/macosx/SDLMain.m @ 4167:a6f635e5eaa6 SDL-1.2
Fixed bug #611
From Tim Angus 2008-08-12 11:18:06
I'm one of the maintainers of ioquake3.org, an updated version of the
Quake 3 engine. Relatively recently, we moved ioq3 to use SDL as a
replacement for 95% of the platform specific code that was there. On the
whole it's doing a great job but unfortunately since the move we've been
getting complaints about the quality of the mouse input on the Windows
platform to the point where for many the game is unplayable. Put in
other terms, the current stable SDL 1.2 is basically not fit for purpose
if you need high quality mouse input as you do in a first person shooter.
Over the weekend I decided to pull my finger out and actually figure out
what's going on. There are basically two major problems. Firstly, when
using the "windib" driver, mouse input is gathered via the WM_MOUSEMOVE
message. Googling for this indicates that often this is known to result
in "spurious" and/or "missing" mouse movement events; this is the
primary cause of the poor mouse input. The second problem is that the
"directx" driver does not work at all in combination with OpenGL meaning
that you can't use DirectInput if your application also uses OpenGL. In
other words you're locked into using the "windib" driver and its poor
mouse input.
In order to address these problems I've done the following:
* Remove WM_MOUSEMOVE based motion event generation and replace with
calls to GetCursorPos which seems much more reliable. In order to
achieve this I've moved mouse motion out into a separate function that
is called once per DIB_PumpEvents.
* Remove the restriction on the "directx" driver being inoperable in
combination with OpenGL. There is a bug for this issues that I've
hijacked to a certain extent
(http://bugzilla.libsdl.org/show_bug.cgi?id=265). I'm the first to admit
I don't really understand why this restriction is there in the first
place. The commit message for the bug fix that introduced this
restriction (r581) isn't very elaborate and I couldn't see any other bug
tracking the issue. If anyone has more information on the bug that was
avoided by r581 it would be helpful as I/someone could then look into
addressing the problem without disabling the "directx" driver.
* I've also removed the restriction on not being allowed to use
DirectInput in windowed mode. I couldn't see any reason for this, at
least not from our perspective. I have my suspicions that it'll be
something like matching up the cursor with the mouse coordinates...
* I bumped up the DirectInput API used to version 7 in order to get
access to mouse buttons 4-7. I've had to inject a little bit of the DX7
headers into SDL there as the MinGW ones aren't up to date in this respect.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 02 Apr 2009 04:43:36 +0000 (2009-04-02) |
parents | f00b6b19d57e |
children | 1496aa09e41e |
rev | line source |
---|---|
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* SDLMain.m - main entry point for our Cocoa-ized SDL app |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
2 Initial Version: Darrell Walisser <dwaliss1@purdue.edu> |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
3 Non-NIB-Code & other changes: Max Horn <max@quendi.de> |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 Feel free to customize this file to suit your needs |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 */ |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 |
4145
f00b6b19d57e
Date: Sat, 5 Apr 2008 19:54:28 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
1809
diff
changeset
|
8 #include "SDL.h" |
f00b6b19d57e
Date: Sat, 5 Apr 2008 19:54:28 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
1809
diff
changeset
|
9 #include "SDLMain.h" |
f00b6b19d57e
Date: Sat, 5 Apr 2008 19:54:28 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
1809
diff
changeset
|
10 #include <sys/param.h> /* for MAXPATHLEN */ |
f00b6b19d57e
Date: Sat, 5 Apr 2008 19:54:28 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
1809
diff
changeset
|
11 #include <unistd.h> |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 |
1591
24247fe40188
Close off warning about setAppleMenu on Mac OS X 10.4 SDK.
Ryan C. Gordon <icculus@icculus.org>
parents:
1572
diff
changeset
|
13 /* For some reaon, Apple removed setAppleMenu from the headers in 10.4, |
24247fe40188
Close off warning about setAppleMenu on Mac OS X 10.4 SDK.
Ryan C. Gordon <icculus@icculus.org>
parents:
1572
diff
changeset
|
14 but the method still is there and works. To avoid warnings, we declare |
24247fe40188
Close off warning about setAppleMenu on Mac OS X 10.4 SDK.
Ryan C. Gordon <icculus@icculus.org>
parents:
1572
diff
changeset
|
15 it ourselves here. */ |
24247fe40188
Close off warning about setAppleMenu on Mac OS X 10.4 SDK.
Ryan C. Gordon <icculus@icculus.org>
parents:
1572
diff
changeset
|
16 @interface NSApplication(SDL_Missing_Methods) |
24247fe40188
Close off warning about setAppleMenu on Mac OS X 10.4 SDK.
Ryan C. Gordon <icculus@icculus.org>
parents:
1572
diff
changeset
|
17 - (void)setAppleMenu:(NSMenu *)menu; |
24247fe40188
Close off warning about setAppleMenu on Mac OS X 10.4 SDK.
Ryan C. Gordon <icculus@icculus.org>
parents:
1572
diff
changeset
|
18 @end |
24247fe40188
Close off warning about setAppleMenu on Mac OS X 10.4 SDK.
Ryan C. Gordon <icculus@icculus.org>
parents:
1572
diff
changeset
|
19 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
20 /* Use this flag to determine whether we use SDLMain.nib or not */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
21 #define SDL_USE_NIB_FILE 0 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
22 |
476
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
23 /* Use this flag to determine whether we use CPS (docking) or not */ |
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
24 #define SDL_USE_CPS 1 |
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
25 #ifdef SDL_USE_CPS |
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
26 /* Portions of CPS.h */ |
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
27 typedef struct CPSProcessSerNum |
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
28 { |
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
29 UInt32 lo; |
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
30 UInt32 hi; |
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
31 } CPSProcessSerNum; |
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
32 |
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
33 extern OSErr CPSGetCurrentProcess( CPSProcessSerNum *psn); |
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
34 extern OSErr CPSEnableForegroundOperation( CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5); |
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
35 extern OSErr CPSSetFrontProcess( CPSProcessSerNum *psn); |
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
36 |
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
37 #endif /* SDL_USE_CPS */ |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
38 |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 static int gArgc; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 static char **gArgv; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 static BOOL gFinderLaunch; |
1113
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
42 static BOOL gCalledAppMainline = FALSE; |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 |
957
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
44 static NSString *getApplicationName(void) |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
45 { |
4145
f00b6b19d57e
Date: Sat, 5 Apr 2008 19:54:28 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
1809
diff
changeset
|
46 const NSDictionary *dict; |
957
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
47 NSString *appName = 0; |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
48 |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
49 /* Determine the application name */ |
4145
f00b6b19d57e
Date: Sat, 5 Apr 2008 19:54:28 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
1809
diff
changeset
|
50 dict = (const NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle()); |
957
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
51 if (dict) |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
52 appName = [dict objectForKey: @"CFBundleName"]; |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
53 |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
54 if (![appName length]) |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
55 appName = [[NSProcessInfo processInfo] processName]; |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
56 |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
57 return appName; |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
58 } |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
59 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
60 #if SDL_USE_NIB_FILE |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
61 /* A helper category for NSString */ |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
62 @interface NSString (ReplaceSubString) |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 - (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
64 @end |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
65 #endif |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
66 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
67 @interface SDLApplication : NSApplication |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
68 @end |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
69 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
70 @implementation SDLApplication |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
71 /* Invoked from the Quit menu item */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
72 - (void)terminate:(id)sender |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
73 { |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
74 /* Post a SDL_QUIT event */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
75 SDL_Event event; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
76 event.type = SDL_QUIT; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
77 SDL_PushEvent(&event); |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
78 } |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
79 @end |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 /* The main class of the application, the application's delegate */ |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 @implementation SDLMain |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 /* Set the working directory to the .app's parent directory */ |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 - (void) setupWorkingDirectory:(BOOL)shouldChdir |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 { |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 if (shouldChdir) |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 { |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
89 char parentdir[MAXPATHLEN]; |
4145
f00b6b19d57e
Date: Sat, 5 Apr 2008 19:54:28 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
1809
diff
changeset
|
90 CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle()); |
f00b6b19d57e
Date: Sat, 5 Apr 2008 19:54:28 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
1809
diff
changeset
|
91 CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url); |
f00b6b19d57e
Date: Sat, 5 Apr 2008 19:54:28 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
1809
diff
changeset
|
92 if (CFURLGetFileSystemRepresentation(url2, 1, (UInt8 *)parentdir, MAXPATHLEN)) { |
f00b6b19d57e
Date: Sat, 5 Apr 2008 19:54:28 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
1809
diff
changeset
|
93 chdir(parentdir); /* chdir to the binary app's parent */ |
f00b6b19d57e
Date: Sat, 5 Apr 2008 19:54:28 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
1809
diff
changeset
|
94 } |
f00b6b19d57e
Date: Sat, 5 Apr 2008 19:54:28 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
1809
diff
changeset
|
95 CFRelease(url); |
f00b6b19d57e
Date: Sat, 5 Apr 2008 19:54:28 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
1809
diff
changeset
|
96 CFRelease(url2); |
f00b6b19d57e
Date: Sat, 5 Apr 2008 19:54:28 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
1809
diff
changeset
|
97 } |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 } |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
100 #if SDL_USE_NIB_FILE |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
101 |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
102 /* Fix menu to contain the real app name instead of "SDL App" */ |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
103 - (void)fixMenu:(NSMenu *)aMenu withAppName:(NSString *)appName |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 { |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 NSRange aRange; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 NSEnumerator *enumerator; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 NSMenuItem *menuItem; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 aRange = [[aMenu title] rangeOfString:@"SDL App"]; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 if (aRange.length != 0) |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
111 [aMenu setTitle: [[aMenu title] stringByReplacingRange:aRange with:appName]]; |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 enumerator = [[aMenu itemArray] objectEnumerator]; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 while ((menuItem = [enumerator nextObject])) |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 { |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 aRange = [[menuItem title] rangeOfString:@"SDL App"]; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 if (aRange.length != 0) |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
118 [menuItem setTitle: [[menuItem title] stringByReplacingRange:aRange with:appName]]; |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 if ([menuItem hasSubmenu]) |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
120 [self fixMenu:[menuItem submenu] withAppName:appName]; |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 } |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 [ aMenu sizeToFit ]; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
123 } |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
125 #else |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
126 |
957
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
127 static void setApplicationMenu(void) |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
128 { |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
129 /* warning: this code is very odd */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
130 NSMenu *appleMenu; |
957
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
131 NSMenuItem *menuItem; |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
132 NSString *title; |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
133 NSString *appName; |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
134 |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
135 appName = getApplicationName(); |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
136 appleMenu = [[NSMenu alloc] initWithTitle:@""]; |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
137 |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
138 /* Add menu items */ |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
139 title = [@"About " stringByAppendingString:appName]; |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
140 [appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""]; |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
141 |
957
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
142 [appleMenu addItem:[NSMenuItem separatorItem]]; |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
143 |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
144 title = [@"Hide " stringByAppendingString:appName]; |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
145 [appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"]; |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
146 |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
147 menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"]; |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
148 [menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)]; |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
149 |
957
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
150 [appleMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""]; |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
151 |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
152 [appleMenu addItem:[NSMenuItem separatorItem]]; |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
153 |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
154 title = [@"Quit " stringByAppendingString:appName]; |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
155 [appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"]; |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
156 |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
157 |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
158 /* Put menu into the menubar */ |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
159 menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""]; |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
160 [menuItem setSubmenu:appleMenu]; |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
161 [[NSApp mainMenu] addItem:menuItem]; |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
162 |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
163 /* Tell the application object that this is now the application menu */ |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
164 [NSApp setAppleMenu:appleMenu]; |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
165 |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
166 /* Finally give up our references to the objects */ |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
167 [appleMenu release]; |
957
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
168 [menuItem release]; |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
169 } |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
170 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
171 /* Create a window menu */ |
957
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
172 static void setupWindowMenu(void) |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
173 { |
957
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
174 NSMenu *windowMenu; |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
175 NSMenuItem *windowMenuItem; |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
176 NSMenuItem *menuItem; |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
177 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
178 windowMenu = [[NSMenu alloc] initWithTitle:@"Window"]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
179 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
180 /* "Minimize" item */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
181 menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
182 [windowMenu addItem:menuItem]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
183 [menuItem release]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
184 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
185 /* Put menu into the menubar */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
186 windowMenuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
187 [windowMenuItem setSubmenu:windowMenu]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
188 [[NSApp mainMenu] addItem:windowMenuItem]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
189 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
190 /* Tell the application object that this is now the window menu */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
191 [NSApp setWindowsMenu:windowMenu]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
192 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
193 /* Finally give up our references to the objects */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
194 [windowMenu release]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
195 [windowMenuItem release]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
196 } |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
197 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
198 /* Replacement for NSApplicationMain */ |
1211 | 199 static void CustomApplicationMain (int argc, char **argv) |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
200 { |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
201 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
202 SDLMain *sdlMain; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
203 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
204 /* Ensure the application object is initialised */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
205 [SDLApplication sharedApplication]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
206 |
476
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
207 #ifdef SDL_USE_CPS |
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
208 { |
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
209 CPSProcessSerNum PSN; |
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
210 /* Tell the dock about us */ |
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
211 if (!CPSGetCurrentProcess(&PSN)) |
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
212 if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103)) |
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
213 if (!CPSSetFrontProcess(&PSN)) |
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
214 [SDLApplication sharedApplication]; |
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
215 } |
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
216 #endif /* SDL_USE_CPS */ |
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
217 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
218 /* Set up the menubar */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
219 [NSApp setMainMenu:[[NSMenu alloc] init]]; |
957
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
220 setApplicationMenu(); |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
221 setupWindowMenu(); |
957
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
222 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
223 /* Create SDLMain and make it the app delegate */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
224 sdlMain = [[SDLMain alloc] init]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
225 [NSApp setDelegate:sdlMain]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
226 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
227 /* Start the main event loop */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
228 [NSApp run]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
229 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
230 [sdlMain release]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
231 [pool release]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
232 } |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
233 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
234 #endif |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
235 |
1113
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
236 |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
237 /* |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
238 * Catch document open requests...this lets us notice files when the app |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
239 * was launched by double-clicking a document, or when a document was |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
240 * dragged/dropped on the app's icon. You need to have a |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
241 * CFBundleDocumentsType section in your Info.plist to get this message, |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
242 * apparently. |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
243 * |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
244 * Files are added to gArgv, so to the app, they'll look like command line |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
245 * arguments. Previously, apps launched from the finder had nothing but |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
246 * an argv[0]. |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
247 * |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
248 * This message may be received multiple times to open several docs on launch. |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
249 * |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
250 * This message is ignored once the app's mainline has been called. |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
251 */ |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
252 - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
253 { |
1809
41ab83bec62f
Date: Wed, 10 May 2006 17:43:21 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
1591
diff
changeset
|
254 const char *temparg; |
41ab83bec62f
Date: Wed, 10 May 2006 17:43:21 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
1591
diff
changeset
|
255 size_t arglen; |
41ab83bec62f
Date: Wed, 10 May 2006 17:43:21 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
1591
diff
changeset
|
256 char *arg; |
41ab83bec62f
Date: Wed, 10 May 2006 17:43:21 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
1591
diff
changeset
|
257 char **newargv; |
41ab83bec62f
Date: Wed, 10 May 2006 17:43:21 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
1591
diff
changeset
|
258 |
1125
a6011e1394d9
Apparently MacOS X will sometimes pass command line arguments to a Cocoa
Ryan C. Gordon <icculus@icculus.org>
parents:
1113
diff
changeset
|
259 if (!gFinderLaunch) /* MacOS is passing command line args. */ |
a6011e1394d9
Apparently MacOS X will sometimes pass command line arguments to a Cocoa
Ryan C. Gordon <icculus@icculus.org>
parents:
1113
diff
changeset
|
260 return FALSE; |
a6011e1394d9
Apparently MacOS X will sometimes pass command line arguments to a Cocoa
Ryan C. Gordon <icculus@icculus.org>
parents:
1113
diff
changeset
|
261 |
1113
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
262 if (gCalledAppMainline) /* app has started, ignore this document. */ |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
263 return FALSE; |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
264 |
1809
41ab83bec62f
Date: Wed, 10 May 2006 17:43:21 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
1591
diff
changeset
|
265 temparg = [filename UTF8String]; |
41ab83bec62f
Date: Wed, 10 May 2006 17:43:21 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
1591
diff
changeset
|
266 arglen = SDL_strlen(temparg) + 1; |
41ab83bec62f
Date: Wed, 10 May 2006 17:43:21 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
1591
diff
changeset
|
267 arg = (char *) SDL_malloc(arglen); |
1113
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
268 if (arg == NULL) |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
269 return FALSE; |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
270 |
1809
41ab83bec62f
Date: Wed, 10 May 2006 17:43:21 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
1591
diff
changeset
|
271 newargv = (char **) realloc(gArgv, sizeof (char *) * (gArgc + 2)); |
1113
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
272 if (newargv == NULL) |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
273 { |
1572
3a8920cc822b
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
1211
diff
changeset
|
274 SDL_free(arg); |
1113
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
275 return FALSE; |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
276 } |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
277 gArgv = newargv; |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
278 |
1572
3a8920cc822b
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
1211
diff
changeset
|
279 SDL_strlcpy(arg, temparg, arglen); |
1211 | 280 gArgv[gArgc++] = arg; |
281 gArgv[gArgc] = NULL; | |
282 return TRUE; | |
1113
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
283 } |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
284 |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
285 |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
286 /* Called when the internal event loop has just started running */ |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
287 - (void) applicationDidFinishLaunching: (NSNotification *) note |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
288 { |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
289 int status; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
290 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
291 /* Set the working directory to the .app's parent directory */ |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
292 [self setupWorkingDirectory:gFinderLaunch]; |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
293 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
294 #if SDL_USE_NIB_FILE |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
295 /* Set the main menu to contain the real app name instead of "SDL App" */ |
957
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
296 [self fixMenu:[NSApp mainMenu] withAppName:getApplicationName()]; |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
297 #endif |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
298 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
299 /* Hand off to main application code */ |
1113
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
300 gCalledAppMainline = TRUE; |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
301 status = SDL_main (gArgc, gArgv); |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
302 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
303 /* We're done, thank you for playing */ |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
304 exit(status); |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
305 } |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
306 @end |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
307 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
308 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
309 @implementation NSString (ReplaceSubString) |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
310 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
311 - (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
312 { |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
313 unsigned int bufferSize; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
314 unsigned int selfLen = [self length]; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
315 unsigned int aStringLen = [aString length]; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
316 unichar *buffer; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
317 NSRange localRange; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
318 NSString *result; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
319 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
320 bufferSize = selfLen + aStringLen - aRange.length; |
4145
f00b6b19d57e
Date: Sat, 5 Apr 2008 19:54:28 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
1809
diff
changeset
|
321 buffer = (unichar *)NSAllocateMemoryPages(bufferSize*sizeof(unichar)); |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
322 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
323 /* Get first part into buffer */ |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
324 localRange.location = 0; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
325 localRange.length = aRange.location; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
326 [self getCharacters:buffer range:localRange]; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
327 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
328 /* Get middle part into buffer */ |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
329 localRange.location = 0; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
330 localRange.length = aStringLen; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
331 [aString getCharacters:(buffer+aRange.location) range:localRange]; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
332 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
333 /* Get last part into buffer */ |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
334 localRange.location = aRange.location + aRange.length; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
335 localRange.length = selfLen - localRange.location; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
336 [self getCharacters:(buffer+aRange.location+aStringLen) range:localRange]; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
337 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
338 /* Build output string */ |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
339 result = [NSString stringWithCharacters:buffer length:bufferSize]; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
340 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
341 NSDeallocateMemoryPages(buffer, bufferSize); |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
342 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
343 return result; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
344 } |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
345 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
346 @end |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
347 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
348 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
349 |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
350 #ifdef main |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
351 # undef main |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
352 #endif |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
353 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
354 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
355 /* Main entry point to executable - should *not* be SDL_main! */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
356 int main (int argc, char **argv) |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
357 { |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
358 /* Copy the arguments into a global variable */ |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
359 /* This is passed if we are launched by double-clicking */ |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
360 if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) { |
1572
3a8920cc822b
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
1211
diff
changeset
|
361 gArgv = (char **) SDL_malloc(sizeof (char *) * 2); |
1113
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
362 gArgv[0] = argv[0]; |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
363 gArgv[1] = NULL; |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
364 gArgc = 1; |
957
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
365 gFinderLaunch = YES; |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
366 } else { |
1113
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
367 int i; |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
368 gArgc = argc; |
1572
3a8920cc822b
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
1211
diff
changeset
|
369 gArgv = (char **) SDL_malloc(sizeof (char *) * (argc+1)); |
1113
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
370 for (i = 0; i <= argc; i++) |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
371 gArgv[i] = argv[i]; |
957
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
372 gFinderLaunch = NO; |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
373 } |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
374 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
375 #if SDL_USE_NIB_FILE |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
376 [SDLApplication poseAsClass:[NSApplication class]]; |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
377 NSApplicationMain (argc, argv); |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
378 #else |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
379 CustomApplicationMain (argc, argv); |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
380 #endif |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
381 return 0; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
382 } |
1809
41ab83bec62f
Date: Wed, 10 May 2006 17:43:21 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
1591
diff
changeset
|
383 |