0

NPAPI in MacOs gives me CGrafPtr in NPWindow structure, I need a WindowRef. Is there a way to get WindowRef from CGrafPtr ?

Thanks!

1 Answers1

2

NPAPI only gives you a CGrafPtr if you are using the very, very deprecated QuickDraw drawing model (with Carbon event model). Writing a new plugin using the QuickDraw model would be a terrible idea: Firefox 64-bit doesn't support it, Safari 64-bit doesn't support it, and Chrome doesn't really support it (and soon won't at all). Your plugin wouldn't work for most users.

Instead, you should be using either Core Animation (drawing) + Cocoa (event), or CoreGraphics + Cocoa. In the Cocoa event model there is, deliberately, no way to get a reference to the browser window. Modern browsers almost all run plugins in a separate process, and you can't reference windows across processes.

In short, if you are trying to make a new NPAPI plugin that requires access to the browser window, your design is wrong.

smorgan
  • 20,228
  • 3
  • 47
  • 55
  • I'm using the code from Mozilla website, which is probably very old. Can you point me to some newer example? What event target should I use instead of window? –  May 23 '12 at 17:23
  • Check out FireBreath (http://firebreath.org). Even if you don't use the framework the website has a lot of good information. The mozilla website, however, does have up to date information. You just have to find it =] https://wiki.mozilla.org/NPAPI and https://developer.mozilla.org/en/Gecko_Plugin_API_Reference are the main documentation locations. – taxilian May 23 '12 at 18:24
  • I don't know what you mean by "event target"; I'd suggest posting a new NPAPI-tagged question with more information about what you are actually trying to accomplish, since "what event target should I use" may well be the wrong question just as "how do I get a WindowRef from a CGrafPtr" was the wrong question. – smorgan May 24 '12 at 09:33
  • http://code.google.com/p/npapi-sdk/ also has a more modern example plugin, and it also has the headers you should be using to develop your plugin. – smorgan May 24 '12 at 09:35