GNOME Bugzilla – Bug 324876
Add function to get toplevel of a GtkPlug
Last modified: 2016-05-24 11:42:14 UTC
Right now, when creating a GtkPlug, the developer has to use X himself to get the toplevel window of a GtkPlug. This would be useful to be able to parent dialogues properly for the GtkPlug/GtkPlug's toplevel window.
Do you have a patch, Bastian ?
I have a patch which tries to do that for Totem, but fails miserably, I have no idea why. The patch is in bug #323759
Fixed in Totem. The function is totem_gtk_plug_get_toplevel() in this patch: http://cvs.gnome.org/viewcvs/totem/src/totem-mozilla-viewer.c?r1=1.28&r2=1.29 My guess now is whether we should implement gtk_plug_get_toplevel(), or rather a gtk_window_set_transient_for_plug () which is likely to be the main reason to use this function.
Created attachment 58948 [details] [review] gtk-plug-get-toplevel.patch
Created attachment 64398 [details] [review] patch that actually works
Ha, missed exporting the symbols, sorry.
Created attachment 74595 [details] [review] gtk+-set-plug-toplevel-automatically.patch Same as the previous patch, but also automatically looking at whether the toplevel window is a GTkPlug or not, and work appropriately. It would also fix the use case in bug 359066
+ * Return value: a newly-created #GdkWindow with a reference count of 1, or + * NULL if the #GtkPlug is not embedded. Is slightly wrong, since the GdkWindow isn't necessarily newly created, and in fact, never has a reference count of 1 though the caller shouldn't worry about the reference count in any case. - This patch will trigger a known bug in foreign window handling, where a foreign window where you don't select for structure-change events will get leaked. (This is the "XID table shouldn't reference" issue) - The way that the patch checks for toplevel windows isn't correct (I'm not sure how it passed testing. It would work with compiz, but I dont' see how it would work with a reparenting window manager like Metacity) See activate-window in: http://svn.mugshot.org/dumbhippo/trunk/client/linux/src/hippo-ui.c for the correct technique. - You *must* always use an error trap when walking around in windows not owned by GTK+. Again, see the code referenced above.