mirror of
https://github.com/kanjitalk755/macemu.git
synced 2025-01-11 10:30:09 +00:00
pull latest SDLMain from SDL-1.2.15
This commit is contained in:
parent
bc315e9942
commit
e4234d7cff
@ -5,7 +5,12 @@
|
|||||||
Feel free to customize this file to suit your needs
|
Feel free to customize this file to suit your needs
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef _SDLMain_h_
|
||||||
|
#define _SDLMain_h_
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
@interface SDLMain : NSObject
|
@interface SDLMain : NSObject
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
#endif /* _SDLMain_h_ */
|
||||||
|
@ -5,10 +5,10 @@
|
|||||||
Feel free to customize this file to suit your needs
|
Feel free to customize this file to suit your needs
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "SDL.h"
|
#include "SDL.h"
|
||||||
#import "SDLMain.h"
|
#include "SDLMain.h"
|
||||||
#import <sys/param.h> /* for MAXPATHLEN */
|
#include <sys/param.h> /* for MAXPATHLEN */
|
||||||
#import <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
/* For some reaon, Apple removed setAppleMenu from the headers in 10.4,
|
/* For some reaon, Apple removed setAppleMenu from the headers in 10.4,
|
||||||
but the method still is there and works. To avoid warnings, we declare
|
but the method still is there and works. To avoid warnings, we declare
|
||||||
@ -43,11 +43,11 @@ static BOOL gCalledAppMainline = FALSE;
|
|||||||
|
|
||||||
static NSString *getApplicationName(void)
|
static NSString *getApplicationName(void)
|
||||||
{
|
{
|
||||||
NSDictionary *dict;
|
const NSDictionary *dict;
|
||||||
NSString *appName = 0;
|
NSString *appName = 0;
|
||||||
|
|
||||||
/* Determine the application name */
|
/* Determine the application name */
|
||||||
dict = (NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle());
|
dict = (const NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle());
|
||||||
if (dict)
|
if (dict)
|
||||||
appName = [dict objectForKey: @"CFBundleName"];
|
appName = [dict objectForKey: @"CFBundleName"];
|
||||||
|
|
||||||
@ -64,10 +64,10 @@ static NSString *getApplicationName(void)
|
|||||||
@end
|
@end
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@interface SDLApplication : NSApplication
|
@interface NSApplication (SDLApplication)
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation SDLApplication
|
@implementation NSApplication (SDLApplication)
|
||||||
/* Invoked from the Quit menu item */
|
/* Invoked from the Quit menu item */
|
||||||
- (void)terminate:(id)sender
|
- (void)terminate:(id)sender
|
||||||
{
|
{
|
||||||
@ -87,15 +87,14 @@ static NSString *getApplicationName(void)
|
|||||||
if (shouldChdir)
|
if (shouldChdir)
|
||||||
{
|
{
|
||||||
char parentdir[MAXPATHLEN];
|
char parentdir[MAXPATHLEN];
|
||||||
CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
|
CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
|
||||||
CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url);
|
CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url);
|
||||||
if (CFURLGetFileSystemRepresentation(url2, true, (UInt8 *)parentdir, MAXPATHLEN)) {
|
if (CFURLGetFileSystemRepresentation(url2, 1, (UInt8 *)parentdir, MAXPATHLEN)) {
|
||||||
assert ( chdir (parentdir) == 0 ); /* chdir to the binary app's parent */
|
chdir(parentdir); /* chdir to the binary app's parent */
|
||||||
}
|
}
|
||||||
CFRelease(url);
|
CFRelease(url);
|
||||||
CFRelease(url2);
|
CFRelease(url2);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SDL_USE_NIB_FILE
|
#if SDL_USE_NIB_FILE
|
||||||
@ -120,7 +119,6 @@ static NSString *getApplicationName(void)
|
|||||||
if ([menuItem hasSubmenu])
|
if ([menuItem hasSubmenu])
|
||||||
[self fixMenu:[menuItem submenu] withAppName:appName];
|
[self fixMenu:[menuItem submenu] withAppName:appName];
|
||||||
}
|
}
|
||||||
[ aMenu sizeToFit ];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@ -203,7 +201,7 @@ static void CustomApplicationMain (int argc, char **argv)
|
|||||||
SDLMain *sdlMain;
|
SDLMain *sdlMain;
|
||||||
|
|
||||||
/* Ensure the application object is initialised */
|
/* Ensure the application object is initialised */
|
||||||
[SDLApplication sharedApplication];
|
[NSApplication sharedApplication];
|
||||||
|
|
||||||
#ifdef SDL_USE_CPS
|
#ifdef SDL_USE_CPS
|
||||||
{
|
{
|
||||||
@ -212,7 +210,7 @@ static void CustomApplicationMain (int argc, char **argv)
|
|||||||
if (!CPSGetCurrentProcess(&PSN))
|
if (!CPSGetCurrentProcess(&PSN))
|
||||||
if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103))
|
if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103))
|
||||||
if (!CPSSetFrontProcess(&PSN))
|
if (!CPSSetFrontProcess(&PSN))
|
||||||
[SDLApplication sharedApplication];
|
[NSApplication sharedApplication];
|
||||||
}
|
}
|
||||||
#endif /* SDL_USE_CPS */
|
#endif /* SDL_USE_CPS */
|
||||||
|
|
||||||
@ -319,7 +317,7 @@ static void CustomApplicationMain (int argc, char **argv)
|
|||||||
NSString *result;
|
NSString *result;
|
||||||
|
|
||||||
bufferSize = selfLen + aStringLen - aRange.length;
|
bufferSize = selfLen + aStringLen - aRange.length;
|
||||||
buffer = NSAllocateMemoryPages(bufferSize*sizeof(unichar));
|
buffer = (unichar *)NSAllocateMemoryPages(bufferSize*sizeof(unichar));
|
||||||
|
|
||||||
/* Get first part into buffer */
|
/* Get first part into buffer */
|
||||||
localRange.location = 0;
|
localRange.location = 0;
|
||||||
@ -347,6 +345,7 @@ static void CustomApplicationMain (int argc, char **argv)
|
|||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef main
|
#ifdef main
|
||||||
# undef main
|
# undef main
|
||||||
#endif
|
#endif
|
||||||
@ -373,7 +372,6 @@ int main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if SDL_USE_NIB_FILE
|
#if SDL_USE_NIB_FILE
|
||||||
[SDLApplication poseAsClass:[NSApplication class]];
|
|
||||||
NSApplicationMain (argc, argv);
|
NSApplicationMain (argc, argv);
|
||||||
#else
|
#else
|
||||||
CustomApplicationMain (argc, argv);
|
CustomApplicationMain (argc, argv);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user