Connecting to window server after a user login
Connecting to window server after a user login
- Subject: Connecting to window server after a user login
- From: John Scalo <email@hidden>
- Date: Fri, 01 Aug 2003 00:39:25 -0700
In Panther how should a daemon attach to the window server when a user logs
in? In Jaguar I could accomplish this by doing something like:
void attachToWindowServer(void)
{
mach_port_t port = 0;
mach_port_t task = 0;
kern_return_t result;
long windowServerPID;
FILE* tFILE = popen("ps -axcocommand,pid | grep \"Window
Manager\"","r");
if (tFILE)
{
fscanf(tFILE,"Window Manager %ld",&windowServerPID);
pclose(tFILE);
}
else
{
fileLog("pipe for ps call faild");
return;
}
result = task_for_pid(task_self_trap(),windowServerPID, &task);
if (0 != result)
fileLog("\ntask_for_pid error: %d",result);
result = task_get_special_port(task,TASK_BOOTSTRAP_PORT,&port);
if (0 != result)
fileLog("\ntask_get_special_port error: %d",result);
result = task_set_special_port(task_self_trap(),
TASK_BOOTSTRAP_PORT,port);
if (0 != result)
fileLog("\ntask_set_special_port error: %d",result);
}
But this fails in Panther and seems rather hacky anyway.
BTW, all I really need this for is so that the daemon can call 'open' to
launch another Cocoa app. For security reasons, this app cannot be a user
login item.
Thanks
John
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.