Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

NPAPI Z-order

49 views
Skip to first unread message

Christian Frost

unread,
Apr 22, 2013, 4:54:10 AM4/22/13
to dev-tech...@lists.mozilla.org
Hi

I have made an NPAPI plugin that I need to control z-ordering of. My
problem is that the plugin is used on a site where there is some HTML5
overlay that should be placed above the plugin. However, it is placed
underneath. Is there any way to change the z-ordering from the plugin?

My idea was to change the "style" attribute to something like
style="z-index -1;" but I'm not sure if this will work.

--
Regards
Christian

Boris Zbarsky

unread,
Apr 22, 2013, 9:21:39 AM4/22/13
to
On 4/22/13 4:54 AM, Christian Frost wrote:
> I have made an NPAPI plugin that I need to control z-ordering of.

Is it a windowless plug-in? If so, it should just work.

-Boris

thec...@gmail.com

unread,
Apr 22, 2013, 9:33:29 AM4/22/13
to
I have tried to make it windowless by having the following in my NPP_GetValue():

....
case NPPVpluginWindowBool:
*((NPBool*)value) = false;
break;
....

To change the z-order use the following:

NPVariant id_var;
NPVariant style_var;
STRING_TO_NPVARIANT("position:absolute;z-index:-1;", style_var);
browser->setproperty(mNPPInstance, npobj, browser->getstringidentifier("style"),&style_var);

However, it seems to have no effect.

/Christian

Benjamin Smedberg

unread,
Apr 22, 2013, 9:58:28 AM4/22/13
to thec...@gmail.com, dev-tech...@lists.mozilla.org
On 4/22/2013 9:33 AM, thec...@gmail.com wrote:
> I have tried to make it windowless by having the following in my NPP_GetValue():
>
> ....
> case NPPVpluginWindowBool:
> *((NPBool*)value) = false;
> break;
You need to use NPN_SetValue for this. See
http://mxr.mozilla.org/mozilla-central/source/dom/plugins/test/testplugin/nptest.cpp#974
for sample code.

Note that "NPNV" are variables used with NPN_Get/Set (NPNV means NP
Navigator Variable).
"NPPV" are variables used with NPP_Get/Set (NPPV means NP Plugin Variable).

--BDS

thec...@gmail.com

unread,
Apr 22, 2013, 10:09:12 AM4/22/13
to
Oh, I see what you mean. Will just try that.

thec...@gmail.com

unread,
Apr 24, 2013, 5:01:01 AM4/24/13
to
I changed the code such that NPN_SetValue is called from the plugin indicating that it is windowless.

Now I get a GraphicsExpose XEvent. I can draw a colored rectangle given the provided Display, but I can't make it transparent. A sample of my code:

Display *disp = This->window->window;
Drawable drawable = (Drawable)This->window->ws_info;

if (!disp || ! drawable)
return NPERR_GENERIC_ERROR;

GC gc = DefaultGC(disp, DefaultScreen(disp));

Can anyone give me an example of how to make a transparent background/rectangle?

On Monday, April 22, 2013 4:09:12 PM UTC+2, thec...@gmail.com wrote:
> On Monday, April 22, 2013 3:58:28 PM UTC+2, Benjamin Smedberg wrote:
>

Benjamin Smedberg

unread,
Apr 24, 2013, 9:20:25 AM4/24/13
to thec...@gmail.com, dev-tech...@lists.mozilla.org
On 4/24/2013 5:01 AM, thec...@gmail.com wrote:
> I changed the code such that NPN_SetValue is called from the plugin indicating that it is windowless.
>
> Now I get a GraphicsExpose XEvent. I can draw a colored rectangle given the provided Display, but I can't make it transparent.
Do you mean "transparent" or "translucent"? If you really just want
transparent areas, don't draw on those areas.

If what you really want is translucent areas, then you should probably
read the code of our test plugin:
http://mxr.mozilla.org/mozilla-central/source/dom/plugins/test/testplugin/nptest_gtk2.cpp

In particular take a look at "pluginDrawSolid" "pluginDrawWindow" and
the GraphicsExpose case in pluginHandleEvent. It uses cairo to draw a
translucent box.

--BDS

thec...@gmail.com

unread,
Apr 24, 2013, 9:25:23 AM4/24/13
to
I mean transparent (totally clear).

If I don't paint in it there is a lot of invalid pixels painted (like there is a memory buffer that hasn't been cleared).


On Wednesday, April 24, 2013 3:20:25 PM UTC+2, Benjamin Smedberg wrote:

Benjamin Smedberg

unread,
Apr 24, 2013, 9:58:01 AM4/24/13
to thec...@gmail.com, dev-tech...@lists.mozilla.org
On 4/24/2013 9:25 AM, thec...@gmail.com wrote:
> I mean transparent (totally clear).
>
> If I don't paint in it there is a lot of invalid pixels painted (like there is a memory buffer that hasn't been cleared).
Ah. By default the browser assumes that plugins are not transparent. But
it asks you via NPP_GetValue(NPPVpluginTransparentBool) and if you
return true from that, then it does transparency handling.

--BDS

0 new messages