Re: Suppressing visibility in the Dock
Re: Suppressing visibility in the Dock
- Subject: Re: Suppressing visibility in the Dock
- From: Ben Haller <email@hidden>
- Date: Mon, 24 May 2010 12:19:05 -0400
On 24-May-10, at 12:30 AM, Ben Haller wrote:
On 24-May-10, at 12:12 AM, Ken Thomases wrote:
I think you can also get away with using LSBackgroundOnly or
LSUIElement and then, when you want it to be a foreground GUI app,
use TransformProcessType() to make it one.
This seems pretty plausible. Somebody else suggested the same
thing off-list. I'll give it a go and report back once I've got
results.
For the list: this worked very nicely. Very easy to set up. These
pages were useful:
http://www.cocoadev.com/index.pl?TransformProcessType
http://www.cocoadev.com/index.pl?LSUIElement
http://www.cocoadev.com/index.pl?LSBackgroundOnly
My new main():
int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
NSArray *arguments = [processInfo arguments];
if ([arguments containsObject:@"-nohead"])
{
int retval = AKRunHeadless();
[pool drain];
return retval;
}
else
{
// Our plist has LSBackgroundOnly set, so that when we run as a
command-line tool we don't get a Dock icon (it would
// pop up if we started playing with views and images). So when
running with UI, we have to transform.
ProcessSerialNumber psn = { 0, kCurrentProcess };
OSStatus returnCode = TransformProcessType(& psn,
kProcessTransformToForegroundApplication);
if (returnCode != 0)
{
NSLog(@"Could not bring the application to front. Error %d",
returnCode);
return EXIT_FAILURE;
}
[pool drain];
return NSApplicationMain(argc, (const char **) argv);
}
}
Ben Haller
McGill University
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden