16 #ifndef NS_RETURNS_INNER_POINTER
17 #define NS_RETURNS_INNER_POINTER
19 #import <AppKit/AppKit.h>
20 #undef NS_RETURNS_INNER_POINTER
25 #include <mach-o/dyld.h>
46 static dispatch_once_t once = 0;
47 dispatch_once(&once, ^{
54 VUserLog(
"Error: Couldn't find VuoApp_mainThread.");
61 VUserLog(
"Error: VuoApp_mainThread isn't set.");
89 dispatch_sync(dispatch_get_main_queue(), ^{
119 char **dylibPath = (
char **)dlsym(RTLD_SELF,
"VuoApp_dylibPath");
121 dylibPath = (
char **)dlsym(RTLD_DEFAULT,
"VuoApp_dylibPath");
124 char *filename = strrchr(*dylibPath,
'/');
127 char *name = strdup(filename + 1);
128 name[strlen(name) - strlen("-XXXXXX.dylib")] = 0;
130 if (strcmp(name,
"VuoComposition") == 0)
133 return strdup(
"Vuo Composition");
143 char *runnerName = (
char *)malloc(2*MAXCOMLEN);
144 proc_name(
runnerPid, runnerName, 2*MAXCOMLEN);
148 NSBundle *mainBundle = [NSBundle mainBundle];
149 NSString *name = [mainBundle objectForInfoDictionaryKey:@"CFBundleDisplayName"];
151 name = [mainBundle objectForInfoDictionaryKey:@"CFBundleName"];
153 name = [mainBundle objectForInfoDictionaryKey:@"CFBundleExecutable"];
155 name = [[[mainBundle executablePath] stringByDeletingPathExtension] lastPathComponent];
158 return strdup([name UTF8String]);
170 static char frameworkPath[PATH_MAX+1] =
"";
171 static dispatch_once_t once = 0;
172 dispatch_once(&once, ^{
173 uint32_t imageCount = _dyld_image_count();
174 for (uint32_t i = 0; i < imageCount; ++i)
176 const char *dylibPath = _dyld_get_image_name(i);
178 if ( (pos = strstr(dylibPath,
"/Vuo.framework/")) )
180 strncpy(frameworkPath, dylibPath, pos-dylibPath);
185 return frameworkPath;
196 static char frameworkPath[PATH_MAX+1] =
"";
197 static dispatch_once_t once = 0;
198 dispatch_once(&once, ^{
199 uint32_t imageCount = _dyld_image_count();
200 for (uint32_t i = 0; i < imageCount; ++i)
202 const char *dylibPath = _dyld_get_image_name(i);
204 if ( (pos = strstr(dylibPath,
"/VuoRunner.framework/")) )
206 strncpy(frameworkPath, dylibPath, pos-dylibPath);
211 return frameworkPath;
221 NSAutoreleasePool *pool = [NSAutoreleasePool new];
224 NSApplication *app = [NSApplication sharedApplication];
234 [app setActivationPolicy:requiresDockIcon ? NSApplicationActivationPolicyRegular : NSApplicationActivationPolicyAccessory];
237 [app finishLaunching];
274 && NSApplication.sharedApplication.activationPolicy != NSApplicationActivationPolicyRegular)
275 [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
280 static dispatch_once_t once = 0;
281 dispatch_once(&once, ^{
296 SEL stopRecording =
@selector(stopRecording);
297 SEL compositionUidSel =
@selector(compositionUid);
298 for (NSWindow *window in [NSApp windows])
302 if ([window respondsToSelector:stopRecording]
303 && [window respondsToSelector:compositionUidSel]
304 && (uint64_t)[window performSelector:compositionUidSel] == compositionUid)
305 [window performSelector:stopRecording];
307 if ([NSApp windows].count)
310 [NSApp setActivationPolicy:NSApplicationActivationPolicyProhibited];
313 [NSRunLoop.currentRunLoop runUntilDate:[NSDate dateWithTimeIntervalSinceNow:VuoApp_windowFadeSeconds + fudge]];
335 free(compositionState);
342 dispatch_sync(dispatch_get_main_queue(), ^{