0

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.

user2181750
  • 241
  • 5
  • 15

1 Answers1

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:

Community
  • 1
  • 1
taxilian
  • 14,229
  • 4
  • 34
  • 73
  • Hi @taxilian, thanks for your answer. Could you share a sample code regarding "You can get a CGContextRef and then create your own offscreen NSWindow and NSView and render them into the CGContextRef,", read from one of the links shared above? – user2181750 Oct 27 '15 at 09:05
  • Also, is there any way to get NSWindow from CGContextRef object? – user2181750 Oct 27 '15 at 10:08
  • 1
    You can't get an NSWindow from a CGContextRef. Anticipating future questions: there is *no way* to get the broswer's NSWindow in the plugin process. It's not a question of being clever, or finding a loophole, you *cannot* get it, because window pointers on OS X are process-specific, and you're in a different process (as I said in the answer to another of your questions). What you are trying to do cannot be done. I recommend asking a question that expresses a higher-level goal so someone can try to point you in the right direction, rather than asking about details on the wrong path. – smorgan Oct 27 '15 at 16:02
  • Hi @smorgan, could you please tell, what is exactly done in NPAPI plugins for safari on mac to display video in the browser? My main goal is to pass something like window's pointer i.e pointer to the browser window, to the underneath streaming engine which will use that pointer to display video in the browser. If you could share some code that would be a great help........Thanks. – user2181750 Oct 30 '15 at 05:48
  • Moreover if it is supposed to be asked in a seperate question then again it would be fine....:) – user2181750 Oct 30 '15 at 05:56
  • It should be a different question, but video could be done using either CoreAnimation or CoreGraphics. With CoreAnimation you get a CALayer, CoreGraphics gives you a CGContextRef. Either can be used to draw video frames – taxilian Oct 30 '15 at 15:48
  • 1
    Please read my comment above again. You *cannot do this*. If your streaming engine requires a window pointer, then you *cannot* show it in the browser window in modern Mac browsers. – smorgan Oct 31 '15 at 15:47
  • trust me on this one, @smorgan knows what he's talking about. You can't get a window pointer/reference. Try one of the options I suggested. The closest you could get would be to draw to your own window pointer, strip the bits, and then draw using CoreAnimation or CoreGraphics. It would be very ugly. – taxilian Nov 02 '15 at 18:03