Can a plugin(for safari on mac) be made windowed or windowless programmatically?

馋奶兔 提交于 2019-12-25 16:09:11

问题


We are making a plugin for safari browser on mac.

After browsing over internet, i found that generally plugins on mac are windowless but i want a windowed plugin. Even in function NPP_SetWindow i tried to print the value of variable type(which is of type NPWindowType) as following:

NPError NPP_SetWindow(NPP instance, NPWindow * pNPWindow)
{
...
printf("....: %d",pNPWindow->type);
...
}

It prints 2 i.e its value is NPWindowTypeDrawable means windowless.

Moreover, I read the following code somewhere:

NPError NPP_New(NPMIMEType pluginType,
        NPP instance, uint16 mode,
        int16 argc, char *argn[],
        char *argv[], NPSavedData *saved)
{
 ...
 NPError result = NPN_SetValue(instance, NPPVpluginWindowBool, (void*)false);
}

Here it says that a plugin can be made windowless by passing value for NPPVpluginWindowBool as false in NPN_SetValue function call. If a plugin does not make this call, it is considered a windowed plugin. But then it also says that " Plug-ins on Mac OS X are always windowless ". I haven't been sured about this yet.

My question is, will passing true value for NPPVpluginWindowBool here make plugin windowed? I haven't tried it yet.

Please suggest how to make it a windowed plugin whether programmatically or any other way around so that pNPWindow->type(in first code snippet) would also print 1 i.e NPWindowTypeWindow means windowed plugin.

Thanks.


回答1:


There are no windowed plugins on Mac; there were at one time, but there aren't anymore.

Now you just have drawing models, and there are three:

  • CoreGraphics
  • CoreAnimation
  • InvalidatingCoreAnimation

The first two are the only ones that work on Safari. There is no way to get a window object on Mac. There used to be a couple of hacks you could use with Quartz and QuickDraw, possibly also with Carbon and CoreGraphics, but those models are long gone now.

See also:

  • https://developer.apple.com/library/safari/qa/qa1755/_index.html
  • https://wiki.mozilla.org/NPAPI:CoreGraphicsDrawing
  • http://www.firebreath.org/display/documentation/Event+models+and+drawing+models
  • How do I get an NSView in a cocoa event model NPAPI plugin


来源:https://stackoverflow.com/questions/33359683/can-a-pluginfor-safari-on-mac-be-made-windowed-or-windowless-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!