14 #ifndef NS_RETURNS_INNER_POINTER
15 #define NS_RETURNS_INNER_POINTER
17 #import <AppKit/AppKit.h>
40 NSAutoreleasePool *pool = [NSAutoreleasePool new];
43 id *nsAppGlobal = (
id *)dlsym(RTLD_DEFAULT,
"NSApp");
46 if (nsAppGlobal && *nsAppGlobal)
53 NSEvent *
event = [*nsAppGlobal nextEventMatchingMask:NSAnyEventMask
54 untilDate:(mode == VuoEventLoop_WaitIndefinitely ? [NSDate distantFuture] : [NSDate distantPast])
55 inMode:NSDefaultRunLoopMode
57 [*nsAppGlobal sendEvent:event];
58 [*nsAppGlobal updateWindows];
64 if (mode == VuoEventLoop_WaitIndefinitely)
67 CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0,
false);
79 id *nsAppGlobal = (
id *)dlsym(RTLD_DEFAULT,
"NSApp");
81 if (nsAppGlobal && *nsAppGlobal)
84 NSEvent *killswitch = [NSEvent otherEventWithType:NSApplicationDefined
85 location:NSMakePoint(0,0)
93 [*nsAppGlobal postEvent:killswitch atStart:NO];
96 CFRunLoopStop(CFRunLoopGetMain());
104 CFRunLoopStop(CFRunLoopGetMain());
113 id *nsAppGlobal = (
id *)dlsym(RTLD_DEFAULT,
"NSApp");
114 if (!nsAppGlobal || !*nsAppGlobal)
117 if ([*nsAppGlobal modalWindow])
120 for (NSWindow *window in [*nsAppGlobal windows])
121 if ([window attachedSheet])
135 static dispatch_queue_attr_t attr = 0;
136 static dispatch_once_t once = 0;
137 dispatch_once(&once, ^{
138 attr = dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_USER_INTERACTIVE, 0);
149 vuoStopCompositionType
vuoStopComposition = (vuoStopCompositionType)dlsym(RTLD_SELF,
"vuoStopComposition");
151 vuoStopComposition = (vuoStopCompositionType)dlsym(RTLD_DEFAULT,
"vuoStopComposition");
154 VUserLog(
"Warning: Couldn't find vuoStopComposition symbol; not installing clean-shutdown signal handlers.");
159 signal(SIGINT, SIG_IGN);
160 signal(SIGQUIT, SIG_IGN);
161 signal(SIGTERM, SIG_IGN);
165 void (^stop)(void) = ^{
168 dispatch_source_t sigintSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL, SIGINT, 0, dispatch_get_main_queue());
169 dispatch_source_t sigquitSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL, SIGQUIT, 0, dispatch_get_main_queue());
170 dispatch_source_t sigtermSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL, SIGTERM, 0, dispatch_get_main_queue());
171 dispatch_source_set_event_handler(sigintSource, stop);
172 dispatch_source_set_event_handler(sigquitSource, stop);
173 dispatch_source_set_event_handler(sigtermSource, stop);
174 dispatch_resume(sigintSource);
175 dispatch_resume(sigquitSource);
176 dispatch_resume(sigtermSource);
186 id activityToken = [[NSProcessInfo processInfo] performSelector:@selector(beginActivityWithOptions:reason:)
187 withObject: (id)((0x00FFFFFFULL | (1ULL << 20)) & ~(1ULL << 14))
188 withObject: @"Many Vuo compositions need to process input and send output even when the app's window is not visible."];
190 [activityToken retain];