Re: Share NSView between processes
Re: Share NSView between processes
- Subject: Re: Share NSView between processes
- From: Mikevann <email@hidden>
- Date: Fri, 21 Sep 2012 22:53:53 -0600
Well there's CGEventPostToPSN (note you need the ProcessSerialNumber for the process and not its unix pid) but that's mostly useful if you're trying to control an app that's not yours. It might be a better approach to go the IPC route setting up communications and trading data objects between the apps and let them handle their own drawing. Checkout NSConnection and look up the Distributed Objects info on how to share data and communicate with each other with higher level APIs that do a lot of the grunt work for you. NSConnection is pretty flexible.
But NSApp's sendEvent is for the process to send events to itself; they won't go to outside processes.
On Sep 19, 2012, at 8:05 PM, Zak Nelson wrote:
> At a high level, I'd like to share an NSView between processes. On Windows, you can share HWNDs across the process boundary, but on mac this doesn't seem possible (http://stackoverflow.com/questions/583202/mac-os-x-can-one-process-render-to-another-processs-window). To get around this, I'm hiding my subprocess' view and using the IOSurface APIs (http://developer.apple.com/library/mac/#documentation/Miscellaneous/Reference/IOSurfaceAPI_header_reference/Reference/reference.html) to get the bitmap back into the parent process.
>
> I've had some success with this approach and it seems performant enough. The problem I'm having now is in sending mouse events to the subprocess' view. Calling [NSApp sendEvent] from the subprocess, the events don't arrive, which I guess is because the application is not in the foreground. I've also tried using CGEventPost which requires the view to be visible and the API moves the mouse, two non-starters. Based on this research it appears impossible to send mouse events to views without key focus.
>
> The next approach I've been considering, which is even more outlandish than my current setup, is to overlay the subprocess' window on top of parent's window. There are a number of edge cases I'm not keen on handling, and that's assuming it's efficient enough to not look terrible.
>
> So at this stage I thought I'd take a step back and seek help. Do my assumptions look valid? Is there perhaps an alternative approach?
>
> Thanks for any help.
_______________________________________________
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