using gtk with windowless NPAPI plugins



Hi all,

I'd like to use gtk to create the UI for a NPAPI (web browser) plugin.
 The wrinkle is that this needs to be a windowless plugin, so I can't
use XEmbed with a GtkPlug.  The way this works is that the browser
gives me an offscreen X Pixmap to draw the plugin's contents (and also
synthesizes X events for me, but that's a separate issue).

I was thinking about using the new gdk_window_redirect_to_drawable()
feature, but I still have the problem of not having a toplevel widget
to pack my widgets into.  The browser will also give me the XID of its
toplevel window (not necessarily the XID of the browser's web view
frame).

I was thinking about creating a "GtkForeignWindow" wrapper widget that
inherits from GtkWindow that wraps a GdkWindow created via
gdk_window_foreign_new(), and then I can pack my plugin's widgets in
that.  Or maybe even just a "GtkOffscreenWindow" that pretends to be a
toplevel (for the benefit of what its child windows want), but really
isn't.

From there, I'm not sure exactly what to do.  There are a few options
that I'm not sure I quite understand based on the API docs:

1.  Use gdk_window_set_composited()
2.  Use gdk_window_redirect_to_drawable()
3.  Use gdk_window_set_embedder()

I suspect #3 is not the right answer here, but I'm not sure about #1
or #2.  Assuming that both of them could be used to achieve what I
want, #2 at least has the nice property that I can tell gdk which
drawable to render to (so I could use the Pixmap passed from the
browser directly) instead of having gdk draw to something, and then
repaint it to the browser-provided Pixmap.

My reading of gdkwindow.c seems to indicate that I could use
_redirect_to_drawable(), and as sub-GdkWindows are added and removed
from the parent, the reidrection will automatically get applied or
removed.  Is that correct?

Is there anything I'm not thinking of, maybe something easier?  Is
this totally crack-brained?  Or am I on the right (if painful)
path...?

Thanks,
Brian



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]