|
@@ -1000,8 +1000,8 @@ SetWindowStyle(SDL_Window * window, unsigned int style)
|
|
|
|
|
|
static int
|
|
|
SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created)
|
|
|
+{ @autoreleasepool
|
|
|
{
|
|
|
- NSAutoreleasePool *pool;
|
|
|
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
|
|
|
SDL_WindowData *data;
|
|
|
|
|
@@ -1016,8 +1016,6 @@ SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created
|
|
|
data->videodata = videodata;
|
|
|
data->nscontexts = [[NSMutableArray alloc] init];
|
|
|
|
|
|
- pool = [[NSAutoreleasePool alloc] init];
|
|
|
-
|
|
|
/* Create an event listener for the window */
|
|
|
data->listener = [[Cocoa_WindowListener alloc] init];
|
|
|
|
|
@@ -1079,16 +1077,15 @@ SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created
|
|
|
[nswindow setOneShot:NO];
|
|
|
|
|
|
/* All done! */
|
|
|
- [pool release];
|
|
|
window->driverdata = data;
|
|
|
return 0;
|
|
|
-}
|
|
|
+}}
|
|
|
|
|
|
int
|
|
|
Cocoa_CreateWindow(_THIS, SDL_Window * window)
|
|
|
+{ @autoreleasepool
|
|
|
{
|
|
|
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
|
|
|
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
|
|
NSWindow *nswindow;
|
|
|
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
|
|
NSRect rect;
|
|
@@ -1123,9 +1120,7 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window)
|
|
|
nswindow = [[SDLWindow alloc] initWithContentRect:rect styleMask:style backing:NSBackingStoreBuffered defer:NO screen:screen];
|
|
|
}
|
|
|
@catch (NSException *e) {
|
|
|
- SDL_SetError("%s", [[e reason] UTF8String]);
|
|
|
- [pool release];
|
|
|
- return -1;
|
|
|
+ return SDL_SetError("%s", [[e reason] UTF8String]);
|
|
|
}
|
|
|
[nswindow setBackgroundColor:[NSColor blackColor]];
|
|
|
|
|
@@ -1155,63 +1150,54 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window)
|
|
|
/* Allow files and folders to be dragged onto the window by users */
|
|
|
[nswindow registerForDraggedTypes:[NSArray arrayWithObject:(NSString *)kUTTypeFileURL]];
|
|
|
|
|
|
- [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)
|
|
|
+{ @autoreleasepool
|
|
|
{
|
|
|
- NSAutoreleasePool *pool;
|
|
|
NSWindow *nswindow = (NSWindow *) data;
|
|
|
NSString *title;
|
|
|
|
|
|
- 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);
|
|
|
-}
|
|
|
+}}
|
|
|
|
|
|
void
|
|
|
Cocoa_SetWindowTitle(_THIS, SDL_Window * window)
|
|
|
+{ @autoreleasepool
|
|
|
{
|
|
|
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
|
|
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
|
|
NSString *string = [[NSString alloc] initWithUTF8String:window->title];
|
|
|
[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];
|
|
|
SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
|
|
|
NSWindow *nswindow = windata->nswindow;
|
|
|
NSRect rect;
|
|
@@ -1229,14 +1215,12 @@ Cocoa_SetWindowPosition(_THIS, SDL_Window * window)
|
|
|
s_moveHack = moveHack;
|
|
|
|
|
|
ScheduleContextUpdates(windata);
|
|
|
-
|
|
|
- [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;
|
|
@@ -1246,14 +1230,12 @@ Cocoa_SetWindowSize(_THIS, SDL_Window * window)
|
|
|
[nswindow setContentSize:size];
|
|
|
|
|
|
ScheduleContextUpdates(windata);
|
|
|
-
|
|
|
- [pool release];
|
|
|
-}
|
|
|
+}}
|
|
|
|
|
|
void
|
|
|
Cocoa_SetWindowMinimumSize(_THIS, SDL_Window * window)
|
|
|
+{ @autoreleasepool
|
|
|
{
|
|
|
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
|
|
SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
|
|
|
|
|
|
NSSize minSize;
|
|
@@ -1261,14 +1243,12 @@ 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;
|
|
@@ -1276,14 +1256,12 @@ 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];
|
|
|
SDL_WindowData *windowData = ((SDL_WindowData *) window->driverdata);
|
|
|
NSWindow *nswindow = windowData->nswindow;
|
|
|
|
|
@@ -1292,23 +1270,21 @@ Cocoa_ShowWindow(_THIS, SDL_Window * window)
|
|
|
[nswindow makeKeyAndOrderFront:nil];
|
|
|
[windowData->listener resumeVisibleObservation];
|
|
|
}
|
|
|
- [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];
|
|
|
SDL_WindowData *windowData = ((SDL_WindowData *) window->driverdata);
|
|
|
NSWindow *nswindow = windowData->nswindow;
|
|
|
|
|
@@ -1321,28 +1297,24 @@ Cocoa_RaiseWindow(_THIS, SDL_Window * window)
|
|
|
[nswindow makeKeyAndOrderFront:nil];
|
|
|
}
|
|
|
[windowData->listener resumeVisibleObservation];
|
|
|
-
|
|
|
- [pool release];
|
|
|
-}
|
|
|
+}}
|
|
|
|
|
|
void
|
|
|
Cocoa_MaximizeWindow(_THIS, SDL_Window * window)
|
|
|
+{ @autoreleasepool
|
|
|
{
|
|
|
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
|
|
SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
|
|
|
NSWindow *nswindow = windata->nswindow;
|
|
|
|
|
|
[nswindow zoom:nil];
|
|
|
|
|
|
ScheduleContextUpdates(windata);
|
|
|
-
|
|
|
- [pool release];
|
|
|
-}
|
|
|
+}}
|
|
|
|
|
|
void
|
|
|
Cocoa_MinimizeWindow(_THIS, SDL_Window * window)
|
|
|
+{ @autoreleasepool
|
|
|
{
|
|
|
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
|
|
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
|
|
NSWindow *nswindow = data->nswindow;
|
|
|
|
|
@@ -1351,13 +1323,12 @@ Cocoa_MinimizeWindow(_THIS, SDL_Window * window)
|
|
|
} else {
|
|
|
[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]) {
|
|
@@ -1365,8 +1336,7 @@ Cocoa_RestoreWindow(_THIS, SDL_Window * window)
|
|
|
} else if ((window->flags & SDL_WINDOW_RESIZABLE) && [nswindow isZoomed]) {
|
|
|
[nswindow zoom:nil];
|
|
|
}
|
|
|
- [pool release];
|
|
|
-}
|
|
|
+}}
|
|
|
|
|
|
static NSWindow *
|
|
|
Cocoa_RebuildWindow(SDL_WindowData * data, NSWindow * nswindow, unsigned style)
|
|
@@ -1391,21 +1361,20 @@ Cocoa_RebuildWindow(SDL_WindowData * data, NSWindow * nswindow, unsigned style)
|
|
|
|
|
|
void
|
|
|
Cocoa_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
|
|
|
+{ @autoreleasepool
|
|
|
{
|
|
|
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
|
|
if (SetWindowStyle(window, GetWindowStyle(window))) {
|
|
|
if (bordered) {
|
|
|
Cocoa_SetWindowTitle(_this, window); /* this got blanked out. */
|
|
|
}
|
|
|
}
|
|
|
- [pool release];
|
|
|
-}
|
|
|
+}}
|
|
|
|
|
|
|
|
|
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;
|
|
@@ -1479,9 +1448,7 @@ Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display
|
|
|
}
|
|
|
|
|
|
ScheduleContextUpdates(data);
|
|
|
-
|
|
|
- [pool release];
|
|
|
-}
|
|
|
+}}
|
|
|
|
|
|
int
|
|
|
Cocoa_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp)
|
|
@@ -1564,8 +1531,8 @@ 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) {
|
|
@@ -1585,9 +1552,7 @@ Cocoa_DestroyWindow(_THIS, SDL_Window * window)
|
|
|
SDL_free(data);
|
|
|
}
|
|
|
window->driverdata = NULL;
|
|
|
-
|
|
|
- [pool release];
|
|
|
-}
|
|
|
+}}
|
|
|
|
|
|
SDL_bool
|
|
|
Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
|
|
@@ -1619,9 +1584,9 @@ Cocoa_IsWindowInFullscreenSpace(SDL_Window * window)
|
|
|
|
|
|
SDL_bool
|
|
|
Cocoa_SetWindowFullscreenSpace(SDL_Window * window, SDL_bool state)
|
|
|
+{ @autoreleasepool
|
|
|
{
|
|
|
SDL_bool succeeded = SDL_FALSE;
|
|
|
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
|
|
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
|
|
|
|
|
if ([data->listener setFullscreenSpace:(state ? YES : NO)]) {
|
|
@@ -1642,10 +1607,8 @@ Cocoa_SetWindowFullscreenSpace(SDL_Window * window, SDL_bool state)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- [pool release];
|
|
|
-
|
|
|
return succeeded;
|
|
|
-}
|
|
|
+}}
|
|
|
|
|
|
int
|
|
|
Cocoa_SetWindowHitTest(SDL_Window * window, SDL_bool enabled)
|