[Xfce4-commits] <xfce4-embed-plugin:master> Fixed destruction of embedded window when the plugin is destroyed.

David Schneider noreply at xfce.org
Sun Jan 1 21:44:33 CET 2012


Updating branch refs/heads/master
         to aea573224bf37c34f07b6c38080a70fe76492886 (commit)
       from 9778a3d6f477b7dbf211b27cc9daee005a1f56a0 (commit)

commit aea573224bf37c34f07b6c38080a70fe76492886
Author: David Schneider <dnschneid at gmail.com>
Date:   Fri Dec 30 16:20:42 2011 -0500

    Fixed destruction of embedded window when the plugin is destroyed.

 TODO                 |    1 -
 panel-plugin/embed.c |   23 +++++++++++++++++------
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/TODO b/TODO
index 7503d0c..25a8f93 100644
--- a/TODO
+++ b/TODO
@@ -9,5 +9,4 @@ Fake socket no longer necessary?
       to work.
     * Might be worth doing for simplicity, but not high priority
 Option to enable click-to-activate keyboard input
-Fix plugin destruction destroying window
 Label font
diff --git a/panel-plugin/embed.c b/panel-plugin/embed.c
index a6d07a4..40009b6 100644
--- a/panel-plugin/embed.c
+++ b/panel-plugin/embed.c
@@ -233,8 +233,9 @@ embed_new (XfcePanelPlugin *plugin)
 
 
 
-/* Frees up the EmbedPlugin structure, popping out the embedded window if there
- * still is one embedded. */
+/* Frees up the EmbedPlugin structure.
+ * At this point it seems that GDK no longer provides direct access to the X11
+ * server. */
 static void
 embed_free (XfcePanelPlugin *plugin, EmbedPlugin *embed)
 {
@@ -242,10 +243,6 @@ embed_free (XfcePanelPlugin *plugin, EmbedPlugin *embed)
 
   DBG (".");
 
-  /* Don't hold onto the embedded window, as if it is a normal window, it will
-   * get lost if we don't reparent it. */
-  embed_popout (GTK_MENU_ITEM (embed->popout_menu), embed);
-
   /* check if the dialog is still open. if so, destroy it */
   dialog = g_object_get_data (G_OBJECT (plugin), "dialog");
   if (G_UNLIKELY (dialog != NULL))
@@ -788,6 +785,17 @@ embed_destroyed (EmbedPlugin *embed)
 }
 
 
+/* Callback for when the plugin is unrealized, usually right before being
+ * destroyed.  We use the opportunity to ditch any normal windows we may have
+ * embedded. */
+static void
+embed_unrealize (GtkWidget *plugin, EmbedPlugin *embed)
+{
+  /* Don't hold onto the embedded window, as if it is a normal window, it will
+   * get lost if we don't reparent it. */
+  embed_popout (GTK_MENU_ITEM (embed->popout_menu), embed);
+}
+
 
 /* Pop out whatever is embedded and start a new search.
  * Called when the window criteria have been updated. */
@@ -856,6 +864,9 @@ embed_construct (XfcePanelPlugin *plugin)
   g_signal_connect (G_OBJECT (plugin), "orientation-changed",
                     G_CALLBACK (embed_orientation_changed), embed);
 
+  g_signal_connect (G_OBJECT (plugin), "unrealize",
+                    G_CALLBACK (embed_unrealize), embed);
+
   /* Add the "pop out" menu item */
   xfce_panel_plugin_menu_insert_item (plugin,
                                       GTK_MENU_ITEM (embed->popout_menu));


More information about the Xfce4-commits mailing list