MythTV  master
util-osx-cocoa.mm
Go to the documentation of this file.
1 #include "util-osx-cocoa.h"
2 #import <Cocoa/Cocoa.h>
3 
4 // Dummy NSThread for Cocoa multithread initialization
5 @implementation NSThread (Dummy)
6 
7  - (void) run;
8 {
9 }
10 
11 @end
12 
13 void *CreateOSXCocoaPool(void)
14 {
15  // Cocoa requires a message to be sent informing the Cocoa event
16  // thread that the application is multi-threaded. Apple recommends
17  // creating a dummy NSThread to get this message sent.
18  if (![NSThread isMultiThreaded])
19  {
20  NSThread *thr = [[NSThread alloc] init];
21  SEL threadSelector = @selector(run);
22  [NSThread detachNewThreadSelector:threadSelector
23  toTarget:thr
24  withObject:nil];
25  }
26 
27  NSAutoreleasePool *pool = nullptr;
28  pool = [[NSAutoreleasePool alloc] init];
29  return pool;
30 }
31 
32 void DeleteOSXCocoaPool(void* &pool)
33 {
34  if (pool)
35  {
36  NSAutoreleasePool *a_pool = (NSAutoreleasePool*) pool;
37  pool = nullptr;
38  [a_pool release];
39  }
40 }
41 
42 CGDirectDisplayID GetOSXCocoaDisplay(void* view)
43 {
44  NSView *thisview = static_cast<NSView *>(view);
45  if (!thisview)
46  return 0;
47  NSScreen *screen = [[thisview window] screen];
48  if (!screen)
49  return 0;
50  NSDictionary* desc = [screen deviceDescription];
51  return (CGDirectDisplayID)[[desc objectForKey:@"NSScreenNumber"] intValue];
52 }
CGDirectDisplayID GetOSXCocoaDisplay(void *view)
void * CreateOSXCocoaPool(void)
static int run(MythMediaDevice *dev=nullptr, bool startRandomShow=false)
void DeleteOSXCocoaPool(void *&pool)