简体   繁体   中英

Mac OSX, Cocoa event model in NPAPI , NSView, and Out of process plugins

Well, currently chrome has out of process plugins. and firefox 4 will use same model.

That means plugin process is now seperated from browser process. Plugin process might NOT have window at all.

My plugin is based on NSView .

Before cocoa event model, when I can access NSWindow in browser process, All I have to do is just add my_view as a subview of the contentView in the window.

[[the_window contentView] addSubview:my_view] 

I do NOT need to process events myself. It worked itself.

But now, I convert NPCocoaEvents into NSEvents in event process code.

Do I have to change it myself?

Also some instance of NSEvents , I can not make them for example, wheel mouse events.

What should do I do?

Did I approach a wrong way?

Please enlighten me.

Do I have to change it myself?

If you plan to use the approach of forwarding NSEvents to your existing NSView then yes; there's no way to get access to the original NSEvents. They don't exist in the plugin process.

Another option would be to move away from trying to use native controls, and do your own drawing and event handling. This is the way most NPAPI plugins work.

A third possibility would be to open a separate window for your plugin content, and put your view in that window. This isn't technically supported by NPAPI, and it won't be perfect, but it might be a short-term way to get your plugin working while you explore long-term options.

Did I approach a wrong way?

Yes, what you were doing before was an unsupported hack, and not how NPAPI was intended to be used. Adding a view to a browser's window assumes things about the browser's view hierarchy that are implementation details, and subject to change at any time.

One option would be to use the FireBreath framework to create your plugin, as it already has a lot of the abstraction for negotiating the event and drawing models as well as an event abstraction. It's pretty straightforward to get up and going.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM