Backed out use of @autorelease keyword for now, since it's not supported by older Xcode versions.
This commit is contained in:
parent
e2aa9f0afb
commit
d36265107b
11 changed files with 773 additions and 702 deletions
|
@ -20,7 +20,9 @@ FILE* SDL_OpenFPFromBundleOrFallback(const char *file, const char *mode)
|
|||
return fopen(file, mode);
|
||||
}
|
||||
|
||||
@autoreleasepool {
|
||||
NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
|
||||
NSFileManager* file_manager = [NSFileManager defaultManager];
|
||||
NSString* resource_path = [[NSBundle mainBundle] resourcePath];
|
||||
|
||||
|
@ -35,7 +37,8 @@ FILE* SDL_OpenFPFromBundleOrFallback(const char *file, const char *mode)
|
|||
{
|
||||
fp = fopen(file, mode);
|
||||
}
|
||||
}
|
||||
|
||||
[autorelease_pool drain];
|
||||
|
||||
return fp;
|
||||
}
|
||||
|
|
|
@ -45,15 +45,17 @@ int
|
|||
Cocoa_SetClipboardText(_THIS, const char *text)
|
||||
{
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
|
||||
NSAutoreleasePool *pool;
|
||||
NSPasteboard *pasteboard;
|
||||
NSString *format = GetTextFormat(_this);
|
||||
|
||||
@autoreleasepool {
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
pasteboard = [NSPasteboard generalPasteboard];
|
||||
data->clipboard_count = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil];
|
||||
[pasteboard setString:[NSString stringWithUTF8String:text] forType:format];
|
||||
}
|
||||
|
||||
[pool release];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -61,12 +63,14 @@ Cocoa_SetClipboardText(_THIS, const char *text)
|
|||
char *
|
||||
Cocoa_GetClipboardText(_THIS)
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
NSPasteboard *pasteboard;
|
||||
NSString *format = GetTextFormat(_this);
|
||||
NSString *available;
|
||||
char *text;
|
||||
|
||||
@autoreleasepool {
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
pasteboard = [NSPasteboard generalPasteboard];
|
||||
available = [pasteboard availableTypeFromArray: [NSArray arrayWithObject:format]];
|
||||
if ([available isEqualToString:format]) {
|
||||
|
@ -83,7 +87,8 @@ Cocoa_GetClipboardText(_THIS)
|
|||
} else {
|
||||
text = SDL_strdup("");
|
||||
}
|
||||
}
|
||||
|
||||
[pool release];
|
||||
|
||||
return text;
|
||||
}
|
||||
|
@ -103,10 +108,12 @@ Cocoa_HasClipboardText(_THIS)
|
|||
void
|
||||
Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data)
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
NSPasteboard *pasteboard;
|
||||
NSInteger count;
|
||||
|
||||
@autoreleasepool {
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
pasteboard = [NSPasteboard generalPasteboard];
|
||||
count = [pasteboard changeCount];
|
||||
if (count != data->clipboard_count) {
|
||||
|
@ -115,7 +122,8 @@ Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data)
|
|||
}
|
||||
data->clipboard_count = count;
|
||||
}
|
||||
}
|
||||
|
||||
[pool release];
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_COCOA */
|
||||
|
|
|
@ -159,13 +159,14 @@ Cocoa_RegisterApp(void)
|
|||
{
|
||||
/* This can get called more than once! Be careful what you initialize! */
|
||||
ProcessSerialNumber psn;
|
||||
NSAutoreleasePool *pool;
|
||||
|
||||
if (!GetCurrentProcess(&psn)) {
|
||||
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
||||
SetFrontProcess(&psn);
|
||||
}
|
||||
|
||||
@autoreleasepool {
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
if (NSApp == nil) {
|
||||
[NSApplication sharedApplication];
|
||||
|
||||
|
@ -177,12 +178,14 @@ Cocoa_RegisterApp(void)
|
|||
if ([NSApp delegate] == nil) {
|
||||
[NSApp setDelegate:[[SDLAppDelegate alloc] init]];
|
||||
}
|
||||
}
|
||||
[pool release];
|
||||
}
|
||||
|
||||
void
|
||||
Cocoa_PumpEvents(_THIS)
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
|
||||
/* Update activity every 30 seconds to prevent screensaver */
|
||||
if (_this->suspend_screensaver) {
|
||||
SDL_VideoData *data = (SDL_VideoData *)_this->driverdata;
|
||||
|
@ -194,7 +197,7 @@ Cocoa_PumpEvents(_THIS)
|
|||
}
|
||||
}
|
||||
|
||||
@autoreleasepool {
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
for ( ; ; ) {
|
||||
NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES ];
|
||||
if ( event == nil ) {
|
||||
|
@ -226,7 +229,7 @@ Cocoa_PumpEvents(_THIS)
|
|||
/* Pass through to NSApp to make sure everything stays in sync */
|
||||
[NSApp sendEvent:event];
|
||||
}
|
||||
}
|
||||
[pool release];
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_COCOA */
|
||||
|
|
|
@ -625,7 +625,7 @@ void
|
|||
Cocoa_StartTextInput(_THIS)
|
||||
{
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
@autoreleasepool {
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSView *parentView = [[NSApp keyWindow] contentView];
|
||||
|
||||
/* We only keep one field editor per process, since only the front most
|
||||
|
@ -645,7 +645,8 @@ Cocoa_StartTextInput(_THIS)
|
|||
[parentView addSubview: data->fieldEdit];
|
||||
[[NSApp keyWindow] makeFirstResponder: data->fieldEdit];
|
||||
}
|
||||
}
|
||||
|
||||
[pool release];
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -654,11 +655,11 @@ Cocoa_StopTextInput(_THIS)
|
|||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
|
||||
if (data && data->fieldEdit) {
|
||||
@autoreleasepool {
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
[data->fieldEdit removeFromSuperview];
|
||||
[data->fieldEdit release];
|
||||
data->fieldEdit = nil;
|
||||
}
|
||||
[pool release];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,8 @@ Cocoa_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
|||
{
|
||||
Cocoa_RegisterApp();
|
||||
|
||||
@autoreleasepool {
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
NSAlert* alert = [[NSAlert alloc] init];
|
||||
|
||||
if (messageboxdata->flags & SDL_MESSAGEBOX_ERROR) {
|
||||
|
@ -70,7 +71,8 @@ Cocoa_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
|||
clicked -= NSAlertFirstButtonReturn;
|
||||
*buttonid = buttons[clicked].buttonid;
|
||||
[alert release];
|
||||
}
|
||||
|
||||
[pool release];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
static SDL_Cursor *
|
||||
Cocoa_CreateDefaultCursor()
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSCursor *nscursor;
|
||||
SDL_Cursor *cursor = NULL;
|
||||
|
||||
|
@ -46,14 +46,15 @@ Cocoa_CreateDefaultCursor()
|
|||
}
|
||||
}
|
||||
|
||||
[pool release];
|
||||
|
||||
return cursor;
|
||||
}
|
||||
}
|
||||
|
||||
static SDL_Cursor *
|
||||
Cocoa_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSImage *nsimage;
|
||||
NSCursor *nscursor = NULL;
|
||||
SDL_Cursor *cursor = NULL;
|
||||
|
@ -70,14 +71,15 @@ Cocoa_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
|
|||
}
|
||||
}
|
||||
|
||||
[pool release];
|
||||
|
||||
return cursor;
|
||||
}
|
||||
}
|
||||
|
||||
static SDL_Cursor *
|
||||
Cocoa_CreateSystemCursor(SDL_SystemCursor id)
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSCursor *nscursor = NULL;
|
||||
SDL_Cursor *cursor = NULL;
|
||||
|
||||
|
@ -131,25 +133,28 @@ Cocoa_CreateSystemCursor(SDL_SystemCursor id)
|
|||
}
|
||||
}
|
||||
|
||||
[pool release];
|
||||
|
||||
return cursor;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Cocoa_FreeCursor(SDL_Cursor * cursor)
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSCursor *nscursor = (NSCursor *)cursor->driverdata;
|
||||
|
||||
[nscursor release];
|
||||
SDL_free(cursor);
|
||||
}
|
||||
|
||||
[pool release];
|
||||
}
|
||||
|
||||
static int
|
||||
Cocoa_ShowCursor(SDL_Cursor * cursor)
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
if (cursor) {
|
||||
NSCursor *nscursor = (NSCursor *)cursor->driverdata;
|
||||
|
||||
|
@ -158,7 +163,8 @@ Cocoa_ShowCursor(SDL_Cursor * cursor)
|
|||
} else {
|
||||
[NSCursor hide];
|
||||
}
|
||||
}
|
||||
|
||||
[pool release];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -80,6 +80,7 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
|
|||
const int wantver = (_this->gl_config.major_version << 8) |
|
||||
(_this->gl_config.minor_version);
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
NSAutoreleasePool *pool;
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||
SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata;
|
||||
NSOpenGLPixelFormatAttribute attr[32];
|
||||
|
@ -99,7 +100,8 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
@autoreleasepool {
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
/* specify a profile if we're on Lion (10.7) or later. */
|
||||
if (data->osversion >= 0x1070) {
|
||||
NSOpenGLPixelFormatAttribute profile = kCGLOGLPVersion_Legacy;
|
||||
|
@ -172,6 +174,7 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
|
|||
fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr];
|
||||
if (fmt == nil) {
|
||||
SDL_SetError ("Failed creating OpenGL pixel format");
|
||||
[pool release];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -181,6 +184,7 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
|
|||
|
||||
if (context == nil) {
|
||||
SDL_SetError ("Failed creating OpenGL context");
|
||||
[pool release];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -206,9 +210,11 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
|
|||
CGLSetParameter (ctx, GLI_SUBMIT_FUNC_CACHE_MAX, &cache_max);
|
||||
CGLSetParameter (ctx, GLI_ARRAY_FUNC_CACHE_MAX, &cache_max);
|
||||
}
|
||||
}
|
||||
|
||||
/* End Wisdom from Apple Engineer section. --ryan. */
|
||||
|
||||
[pool release];
|
||||
|
||||
if ( Cocoa_GL_MakeCurrent(_this, window, context) < 0 ) {
|
||||
Cocoa_GL_DeleteContext(_this, context);
|
||||
return NULL;
|
||||
|
@ -220,7 +226,10 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
|
|||
int
|
||||
Cocoa_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSAutoreleasePool *pool;
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
if (context) {
|
||||
SDL_WindowData *windowdata = (SDL_WindowData *)window->driverdata;
|
||||
NSOpenGLContext *nscontext = (NSOpenGLContext *)context;
|
||||
|
@ -240,19 +249,21 @@ Cocoa_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
|
|||
} else {
|
||||
[NSOpenGLContext clearCurrentContext];
|
||||
}
|
||||
}
|
||||
|
||||
[pool release];
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
Cocoa_GL_SetSwapInterval(_THIS, int interval)
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
NSOpenGLContext *nscontext;
|
||||
GLint value;
|
||||
int status;
|
||||
|
||||
@autoreleasepool {
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
nscontext = [NSOpenGLContext currentContext];
|
||||
if (nscontext != nil) {
|
||||
value = interval;
|
||||
|
@ -262,52 +273,60 @@ Cocoa_GL_SetSwapInterval(_THIS, int interval)
|
|||
SDL_SetError("No current OpenGL context");
|
||||
status = -1;
|
||||
}
|
||||
}
|
||||
|
||||
[pool release];
|
||||
return status;
|
||||
}
|
||||
|
||||
int
|
||||
Cocoa_GL_GetSwapInterval(_THIS)
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
NSOpenGLContext *nscontext;
|
||||
GLint value;
|
||||
int status = 0;
|
||||
|
||||
@autoreleasepool {
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
nscontext = [NSOpenGLContext currentContext];
|
||||
if (nscontext != nil) {
|
||||
[nscontext getValues:&value forParameter:NSOpenGLCPSwapInterval];
|
||||
status = (int)value;
|
||||
}
|
||||
}
|
||||
|
||||
[pool release];
|
||||
return status;
|
||||
}
|
||||
|
||||
void
|
||||
Cocoa_GL_SwapWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
NSOpenGLContext *nscontext;
|
||||
|
||||
@autoreleasepool {
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
/* FIXME: Do we need to get the context for the window? */
|
||||
nscontext = [NSOpenGLContext currentContext];
|
||||
if (nscontext != nil) {
|
||||
[nscontext flushBuffer];
|
||||
}
|
||||
}
|
||||
|
||||
[pool release];
|
||||
}
|
||||
|
||||
void
|
||||
Cocoa_GL_DeleteContext(_THIS, SDL_GLContext context)
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
NSOpenGLContext *nscontext = (NSOpenGLContext *)context;
|
||||
|
||||
@autoreleasepool {
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
[nscontext clearDrawable];
|
||||
[nscontext release];
|
||||
}
|
||||
|
||||
[pool release];
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_OPENGL_CGL */
|
||||
|
|
|
@ -74,7 +74,7 @@ Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShape
|
|||
SDL_ShapeData* data = (SDL_ShapeData*)shaper->driverdata;
|
||||
SDL_WindowData* windata = (SDL_WindowData*)shaper->window->driverdata;
|
||||
SDL_CocoaClosure closure;
|
||||
|
||||
NSAutoreleasePool *pool = NULL;
|
||||
if(data->saved == SDL_TRUE) {
|
||||
[data->context restoreGraphicsState];
|
||||
data->saved = SDL_FALSE;
|
||||
|
@ -88,13 +88,12 @@ Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShape
|
|||
NSRectFill([[windata->nswindow contentView] frame]);
|
||||
data->shape = SDL_CalculateShapeTree(*shape_mode,shape);
|
||||
|
||||
@autoreleasepool {
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
closure.view = [windata->nswindow contentView];
|
||||
closure.path = [[NSBezierPath bezierPath] autorelease];
|
||||
closure.window = shaper->window;
|
||||
SDL_TraverseShapeTree(data->shape,&ConvertRects,&closure);
|
||||
[closure.path addClip];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -250,7 +250,8 @@ SDL_PromptAssertion_cocoa(const SDL_assert_data *data)
|
|||
}
|
||||
}
|
||||
|
||||
@autoreleasepool {
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
NSString *msg = [NSString stringWithFormat:
|
||||
@"Assertion failure at %s (%s:%d), triggered %u time%s:\n '%s'",
|
||||
data->function, data->filename, data->linenum,
|
||||
|
@ -275,13 +276,14 @@ SDL_PromptAssertion_cocoa(const SDL_assert_data *data)
|
|||
const NSInteger clicked = [alert runModal];
|
||||
[alert release];
|
||||
|
||||
[pool release];
|
||||
|
||||
if (!initialized) {
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
}
|
||||
|
||||
return (SDL_assert_state) (clicked - NSAlertFirstButtonReturn);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_COCOA */
|
||||
|
||||
|
|
|
@ -507,6 +507,7 @@ GetWindowStyle(SDL_Window * window)
|
|||
static int
|
||||
SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created)
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
|
||||
SDL_WindowData *data;
|
||||
|
||||
|
@ -521,7 +522,8 @@ SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created
|
|||
data->created = created;
|
||||
data->videodata = videodata;
|
||||
|
||||
@autoreleasepool {
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
/* Create an event listener for the window */
|
||||
data->listener = [[Cocoa_WindowListener alloc] init];
|
||||
|
||||
|
@ -574,15 +576,15 @@ SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created
|
|||
}
|
||||
|
||||
/* All done! */
|
||||
[pool release];
|
||||
window->driverdata = data;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
Cocoa_CreateWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSWindow *nswindow;
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||
NSRect rect;
|
||||
|
@ -623,27 +625,31 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window)
|
|||
[nswindow setContentView: contentView];
|
||||
[contentView release];
|
||||
|
||||
[pool release];
|
||||
|
||||
if (SetupWindowData(_this, window, nswindow, SDL_TRUE) < 0) {
|
||||
[nswindow release];
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
Cocoa_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
NSWindow *nswindow = (NSWindow *) data;
|
||||
NSString *title;
|
||||
|
||||
@autoreleasepool {
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
/* Query the title from the existing window */
|
||||
title = [nswindow title];
|
||||
if (title) {
|
||||
window->title = SDL_strdup([title UTF8String]);
|
||||
}
|
||||
}
|
||||
|
||||
[pool release];
|
||||
|
||||
return SetupWindowData(_this, window, nswindow, SDL_FALSE);
|
||||
}
|
||||
|
@ -651,7 +657,7 @@ Cocoa_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
|
|||
void
|
||||
Cocoa_SetWindowTitle(_THIS, SDL_Window * window)
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
||||
NSString *string;
|
||||
|
||||
|
@ -662,25 +668,27 @@ Cocoa_SetWindowTitle(_THIS, SDL_Window * window)
|
|||
}
|
||||
[nswindow setTitle:string];
|
||||
[string release];
|
||||
}
|
||||
|
||||
[pool release];
|
||||
}
|
||||
|
||||
void
|
||||
Cocoa_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSImage *nsimage = Cocoa_CreateImage(icon);
|
||||
|
||||
if (nsimage) {
|
||||
[NSApp setApplicationIconImage:nsimage];
|
||||
}
|
||||
}
|
||||
|
||||
[pool release];
|
||||
}
|
||||
|
||||
void
|
||||
Cocoa_SetWindowPosition(_THIS, SDL_Window * window)
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
||||
NSRect rect;
|
||||
Uint32 moveHack;
|
||||
|
@ -699,13 +707,14 @@ Cocoa_SetWindowPosition(_THIS, SDL_Window * window)
|
|||
if (window == _this->current_glwin) {
|
||||
[((NSOpenGLContext *) _this->current_glctx) update];
|
||||
}
|
||||
}
|
||||
|
||||
[pool release];
|
||||
}
|
||||
|
||||
void
|
||||
Cocoa_SetWindowSize(_THIS, SDL_Window * window)
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
|
||||
NSWindow *nswindow = windata->nswindow;
|
||||
NSSize size;
|
||||
|
@ -717,13 +726,14 @@ Cocoa_SetWindowSize(_THIS, SDL_Window * window)
|
|||
if (window == _this->current_glwin) {
|
||||
[((NSOpenGLContext *) _this->current_glctx) update];
|
||||
}
|
||||
}
|
||||
|
||||
[pool release];
|
||||
}
|
||||
|
||||
void
|
||||
Cocoa_SetWindowMinimumSize(_THIS, SDL_Window * window)
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
|
||||
|
||||
NSSize minSize;
|
||||
|
@ -731,13 +741,14 @@ Cocoa_SetWindowMinimumSize(_THIS, SDL_Window * window)
|
|||
minSize.height = window->min_h;
|
||||
|
||||
[windata->nswindow setContentMinSize:minSize];
|
||||
}
|
||||
|
||||
[pool release];
|
||||
}
|
||||
|
||||
void
|
||||
Cocoa_SetWindowMaximumSize(_THIS, SDL_Window * window)
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
|
||||
|
||||
NSSize maxSize;
|
||||
|
@ -745,65 +756,71 @@ Cocoa_SetWindowMaximumSize(_THIS, SDL_Window * window)
|
|||
maxSize.height = window->max_h;
|
||||
|
||||
[windata->nswindow setContentMaxSize:maxSize];
|
||||
}
|
||||
|
||||
[pool release];
|
||||
}
|
||||
|
||||
void
|
||||
Cocoa_ShowWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
||||
|
||||
if (![nswindow isMiniaturized]) {
|
||||
[nswindow makeKeyAndOrderFront:nil];
|
||||
}
|
||||
}
|
||||
[pool release];
|
||||
}
|
||||
|
||||
void
|
||||
Cocoa_HideWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
||||
|
||||
[nswindow orderOut:nil];
|
||||
}
|
||||
[pool release];
|
||||
}
|
||||
|
||||
void
|
||||
Cocoa_RaiseWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
||||
|
||||
[nswindow makeKeyAndOrderFront:nil];
|
||||
}
|
||||
[pool release];
|
||||
}
|
||||
|
||||
void
|
||||
Cocoa_MaximizeWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
||||
|
||||
[nswindow zoom:nil];
|
||||
|
||||
if (window == _this->current_glwin) {
|
||||
[((NSOpenGLContext *) _this->current_glctx) update];
|
||||
}
|
||||
}
|
||||
|
||||
[pool release];
|
||||
}
|
||||
|
||||
void
|
||||
Cocoa_MinimizeWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
||||
|
||||
[nswindow miniaturize:nil];
|
||||
}
|
||||
[pool release];
|
||||
}
|
||||
|
||||
void
|
||||
Cocoa_RestoreWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
||||
|
||||
if ([nswindow isMiniaturized]) {
|
||||
|
@ -811,7 +828,7 @@ Cocoa_RestoreWindow(_THIS, SDL_Window * window)
|
|||
} else if ((window->flags & SDL_WINDOW_RESIZABLE) && [nswindow isZoomed]) {
|
||||
[nswindow zoom:nil];
|
||||
}
|
||||
}
|
||||
[pool release];
|
||||
}
|
||||
|
||||
static NSWindow *
|
||||
|
@ -837,7 +854,7 @@ Cocoa_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
|
|||
{
|
||||
/* this message arrived in 10.6. You're out of luck on older OSes. */
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
||||
@autoreleasepool {
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
||||
if ([nswindow respondsToSelector:@selector(setStyleMask:)]) {
|
||||
[nswindow setStyleMask:GetWindowStyle(window)];
|
||||
|
@ -845,14 +862,14 @@ Cocoa_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
|
|||
Cocoa_SetWindowTitle(_this, window); // this got blanked out.
|
||||
}
|
||||
}
|
||||
}
|
||||
[pool release];
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen)
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
NSWindow *nswindow = data->nswindow;
|
||||
NSRect rect;
|
||||
|
@ -925,7 +942,8 @@ Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display
|
|||
if (window == _this->current_glwin) {
|
||||
[((NSOpenGLContext *) _this->current_glctx) update];
|
||||
}
|
||||
}
|
||||
|
||||
[pool release];
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -1009,7 +1027,7 @@ Cocoa_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
|
|||
void
|
||||
Cocoa_DestroyWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
|
||||
if (data) {
|
||||
|
@ -1020,7 +1038,7 @@ Cocoa_DestroyWindow(_THIS, SDL_Window * window)
|
|||
}
|
||||
SDL_free(data);
|
||||
}
|
||||
}
|
||||
[pool release];
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
|
|
|
@ -21,23 +21,30 @@ FILE* TestSupportRWops_OpenFPFromReadDir(const char *file, const char *mode)
|
|||
FILE* fp = NULL;
|
||||
|
||||
// If the file mode is writable, skip all the bundle stuff because generally the bundle is read-only.
|
||||
if (strcmp("r", mode) && strcmp("rb", mode)) {
|
||||
if(strcmp("r", mode) && strcmp("rb", mode))
|
||||
{
|
||||
return fopen(file, mode);
|
||||
}
|
||||
|
||||
@autoreleasepool {
|
||||
NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
|
||||
NSFileManager* file_manager = [NSFileManager defaultManager];
|
||||
NSString* resource_path = [[NSBundle mainBundle] resourcePath];
|
||||
|
||||
NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
|
||||
|
||||
NSString* full_path_with_file_to_try = [resource_path stringByAppendingPathComponent:ns_string_file_component];
|
||||
if ([file_manager fileExistsAtPath:full_path_with_file_to_try]) {
|
||||
if([file_manager fileExistsAtPath:full_path_with_file_to_try])
|
||||
{
|
||||
fp = fopen([full_path_with_file_to_try fileSystemRepresentation], mode);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
fp = fopen(file, mode);
|
||||
}
|
||||
}
|
||||
|
||||
[autorelease_pool drain];
|
||||
|
||||
return fp;
|
||||
}
|
||||
|
@ -46,13 +53,15 @@ FILE* TestSupportRWops_OpenFPFromWriteDir(const char *file, const char *mode)
|
|||
{
|
||||
FILE* fp = NULL;
|
||||
|
||||
@autoreleasepool {
|
||||
NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
NSFileManager* file_manager = [NSFileManager defaultManager];
|
||||
NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
|
||||
NSString* full_path_with_file_to_try = [NSTemporaryDirectory() stringByAppendingPathComponent:ns_string_file_component];
|
||||
|
||||
fp = fopen([full_path_with_file_to_try fileSystemRepresentation], mode);
|
||||
}
|
||||
|
||||
[autorelease_pool drain];
|
||||
|
||||
return fp;
|
||||
}
|
||||
|
@ -66,14 +75,15 @@ SDL_RWops* TestSupportRWops_OpenRWopsFromWriteDir(const char *file, const char *
|
|||
{
|
||||
SDL_RWops* rw = NULL;
|
||||
|
||||
@autoreleasepool {
|
||||
NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
NSFileManager* file_manager = [NSFileManager defaultManager];
|
||||
NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
|
||||
NSString* full_path_with_file_to_try = [NSTemporaryDirectory() stringByAppendingPathComponent:ns_string_file_component];
|
||||
|
||||
rw = SDL_RWFromFile( [full_path_with_file_to_try fileSystemRepresentation], mode );
|
||||
}
|
||||
|
||||
[autorelease_pool drain];
|
||||
return rw;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue