00001 #include "util-osx-cocoa.h"
00002 #import <Cocoa/Cocoa.h>
00003
00004
00005 @implementation NSThread (Dummy)
00006
00007 - (void) run;
00008 {
00009 }
00010
00011 @end
00012
00013 void *CreateOSXCocoaPool(void)
00014 {
00015
00016
00017
00018 if (![NSThread isMultiThreaded])
00019 {
00020 NSThread *thr = [[NSThread alloc] init];
00021 SEL threadSelector = @selector(run);
00022 [NSThread detachNewThreadSelector:threadSelector
00023 toTarget:thr
00024 withObject:nil];
00025 }
00026
00027 NSAutoreleasePool *pool = NULL;
00028 pool = [[NSAutoreleasePool alloc] init];
00029 return pool;
00030 }
00031
00032 void DeleteOSXCocoaPool(void* &pool)
00033 {
00034 if (pool)
00035 {
00036 NSAutoreleasePool *a_pool = (NSAutoreleasePool*) pool;
00037 pool = NULL;
00038 [a_pool release];
00039 }
00040 }
00041
00042 CGDirectDisplayID GetOSXCocoaDisplay(void* view)
00043 {
00044 NSView *thisview = static_cast<NSView *>(view);
00045 if (!thisview)
00046 return NULL;
00047 NSScreen *screen = [[thisview window] screen];
00048 if (!screen)
00049 return NULL;
00050 NSDictionary* desc = [screen deviceDescription];
00051 return (CGDirectDisplayID)[[desc objectForKey:@"NSScreenNumber"] intValue];
00052 }