可以通过编程方式制作窗口化或无窗口化插件(适用于Mac上的Safari)吗? [英] Can a plugin(for safari on mac) be made windowed or windowless programmatically?
问题描述
我们正在为Mac上的Safari浏览器制作一个插件。
We are making a plugin for safari browser on mac.
通过Internet浏览后,我发现Mac上的插件通常没有窗口,但我想要一个窗口插件。即使在函数 NPP_SetWindow 中,我也尝试打印变量 type (类型为 NPWindowType )的值,如下所示:
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);
...
}
它显示 2
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);
}
此处表示可以通过传递的值来使插件变为无窗口在 NPN_SetValue 函数调用中将> NPPVpluginWindowBool 设置为 false 。
如果某个插件未进行此调用,则将其视为带窗口的插件。但是随后它又说 Mac OS X上的插件始终没有窗口。我还不确定。
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.
我的问题是,是否将 NPPVpluginWindowBool 的 true 值传递给此处,以使插件窗口化?我尚未尝试过。
My question is, will passing true value for NPPVpluginWindowBool here make plugin windowed? I haven't tried it yet.
请提出如何以编程方式或其他方式使其成为窗口式插件的建议,以使 pNPWindow-> type (在第一个代码段中)还将打印1,即 NPWindowTypeWindow 表示窗口插件。
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.
谢谢。
推荐答案
Mac上没有窗口式插件;
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
前两个是可在Safari上运行的仅有的两个。在Mac上无法获取窗口对象。过去,您可以使用Quartz和QuickDraw,甚至可以使用Carbon和CoreGraphics,使用过几款黑客工具,但是这些模型现在已经不复存在了。
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.
另请参见:
- 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 +绘图+模型
- 如何在可可事件模型NPAPI插件中获取NSView
- 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
这篇关于可以通过编程方式制作窗口化或无窗口化插件(适用于Mac上的Safari)吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!