#import <AppKit/NSApplication.h>
+#import <Foundation/NSAutoReleasePool.h>
#import <Foundation/NSRunLoop.h>
#include "cocoadisplay.h"
struct _CocoaDisplay
{
NSApplication *app;
+ NSAutoreleasePool *arp;
CFMutableArrayRef event_queue;
};
CocoaDisplay *create_display()
{
CocoaDisplay *display = (CocoaDisplay *)malloc(sizeof(CocoaDisplay));
+ display->arp = [[NSAutoreleasePool alloc] init];
display->app = [NSApplication sharedApplication];
// This makes windows appear when run from terminal
if([display->app respondsToSelector:@selector(setActivationPolicy:)])
void destroy_display(CocoaDisplay *display)
{
CFRelease(display->event_queue);
+ [display->arp release];
free(display);
}
NSEvent *event = [display->app nextEventMatchingMask:NSAnyEventMask untilDate:nil inMode:NSDefaultRunLoopMode dequeue:YES];
if(event)
{
+ [event retain];
[display->app sendEvent:event];
convert_event(event, buf);
+ [event release];
return true;
}
{
CocoaDisplay *display;
__strong NSWindow *window;
+ __strong WindowDelegate *delegate;
NSUInteger style;
};
wrapper->window = window;
wrapper->style = style;
- [window setDelegate:[[WindowDelegate alloc] init]];
+ wrapper->delegate = [[WindowDelegate alloc] init];
+ [window setDelegate:wrapper->delegate];
if(!windows)
windows = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
}
[window->window release];
+ [window->delegate release];
free(window);
}