Re: Receiving a callback on GDK window destroy



I do get one XID per instance, but that XID is created by Firefox's
plugin host code in GtkSocket's internal GdkWindow. So the XID is
already mapped to that GdkWindow by the time NPP_SetWindow runs, hence
gdk_window_foreign_new() just returns a pointer to that pre-existing
GdkWindow, so the parentage tree that _gdk_window_destroy_hierarchy
traverses is still hooked up.

But after some more hacking I was able to figure out a work-around.
gdk_window_foreign_new() only re-uses the existing GdkWindow if the
GdkDisplay pointers match, and gdk_display_open does _not_ re-use
existing connections! So by explicitly opening the display and using
gdk_window_foreign_new_for_display I was able to force it to really
use a foreign window, and now I get all the expected callbacks (unmap,
delete, unrealize). In fact, with the _for_display() trick I can use a
GtkPlug and get the same callbacks just fine. So the code I eventually
settled on is basically this:

// Re-open the X11 connection
gdk_display_ = gdk_display_open(XDisplayString(display));
// Create plug.
gtk_plug_ = gtk_plug_new_for_display(gdk_display_, windowId);
// Stop the browser from destroying our GtkPlug too soon.
g_signal_connect(G_OBJECT(gtk_plug_), "delete-event",
                   G_CALLBACK(gtk_widget_hide_on_delete), NULL);

Thanks for the help!

On 19 January 2010 20:55, Kevin DeKorte <kdekorte gmail com> wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 01/19/10 20:29, Tristan Schmelcher wrote:
Actually, after debugging and looking at the code, it seems that
gdk_window_foreign_new() first looks up if there is already a GdkWindow
for that XID and re-uses it if so (gdk/x11/gdkwindow-x11.c:1008). So I
don't think this approach will work. :(

You must be doing something wrong since you should get one xid per
windowed plugin instance. I've been using this method for years in both
the mplayerplug-in plugin and the gecko-mediaplayer plugin.

Take a look at either of those projects source code. I'm sure there is
something there that will help you.

Kevin
- --
Get my public GnuPG key from
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x7D0BD5D1
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAktWjNQACgkQ6w2kMH0L1dG7vACcDZNHS0dTEbXCTHD0IesjVmeF
BCsAn3oewKsZFv/Dv6uV3vfKgR6k7iJl
=uFlq
-----END PGP SIGNATURE-----



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