[Xfce4-commits] <xfce4-embed-plugin:master> Added embedding of the matched window.
David Schneider
noreply at xfce.org
Sun Jan 1 21:44:23 CET 2012
Updating branch refs/heads/master
to 4f185dd6f50c56c98abc7d22613287982ae61b90 (commit)
from fdb0a68200026076dbee8b30e4cd53b6ba282c43 (commit)
commit 4f185dd6f50c56c98abc7d22613287982ae61b90
Author: David Schneider <dnschneid at gmail.com>
Date: Thu Dec 29 02:56:05 2011 -0500
Added embedding of the matched window.
Unfortunately, GtkSocket will destroy it if we try to pop it out; a more drastic
solution will be required.
panel-plugin/embed.c | 34 +++++++++++++++++++++++++---------
panel-plugin/ewmh.c | 7 +++++++
panel-plugin/ewmh.h | 2 ++
3 files changed, 34 insertions(+), 9 deletions(-)
diff --git a/panel-plugin/embed.c b/panel-plugin/embed.c
index 633fe67..cbad6d2 100644
--- a/panel-plugin/embed.c
+++ b/panel-plugin/embed.c
@@ -149,11 +149,15 @@ embed_read (EmbedPlugin *embed)
embed->min_size = DEFAULT_MIN_SIZE;
}
+
+
static void
embed_update_separator (EmbedPlugin* embed, GtkOrientation orientation)
{
}
+
+
static EmbedPlugin *
embed_new (XfcePanelPlugin *plugin)
{
@@ -216,6 +220,8 @@ embed_free (XfcePanelPlugin *plugin, EmbedPlugin *embed)
{
GtkWidget *dialog;
+ DBG(".");
+
/* Don't hold onto the embedded window */
embed_popout (GTK_MENU_ITEM(embed->popout_menu), embed);
@@ -291,6 +297,13 @@ embed_size_changed (XfcePanelPlugin *plugin, gint size, EmbedPlugin *embed)
}
+static void
+embed_size_changed_simple (EmbedPlugin *embed)
+{
+ embed_size_changed (embed->plugin,
+ xfce_panel_plugin_get_size(embed->plugin), embed);
+}
+
static void
embed_update_label (EmbedPlugin *embed)
@@ -343,8 +356,9 @@ embed_search (EmbedPlugin *embed)
&embed->plug_width, &embed->plug_height);
DBG ("found window 0x%X of geometry %dx%d",
embed->plug, embed->plug_width, embed->plug_height);
- /* TODO: reparent */
embed_update_label (embed);
+ embed_size_changed_simple (embed);
+ gtk_socket_steal (GTK_SOCKET (embed->socket), embed->plug);
break;
}
}
@@ -414,8 +428,7 @@ embed_plug_added (GtkSocket *socket, EmbedPlugin *embed)
embed_update_label (embed);
/* Update the size of the panel. */
- embed_size_changed (embed->plugin,
- xfce_panel_plugin_get_size(embed->plugin), embed);
+ embed_size_changed_simple (embed);
}
@@ -433,6 +446,8 @@ embed_add_socket_and_resize (EmbedPlugin *embed)
static gboolean
embed_plug_removed (GtkSocket *socket, EmbedPlugin *embed)
{
+ DBG(".");
+
g_assert (embed->socket);
gtk_widget_hide(embed->popout_menu);
@@ -451,8 +466,6 @@ embed_plug_removed (GtkSocket *socket, EmbedPlugin *embed)
static void
embed_add_socket (EmbedPlugin *embed, gboolean update_size)
{
- /* Should call embed_size_changed after adding a socket so that its size is
- * updated */
if (embed->socket)
return;
@@ -468,8 +481,7 @@ embed_add_socket (EmbedPlugin *embed, gboolean update_size)
G_CALLBACK (embed_start_search), embed);
if (update_size)
- embed_size_changed (embed->plugin,
- xfce_panel_plugin_get_size(embed->plugin), embed);
+ embed_size_changed_simple (embed);
}
@@ -478,15 +490,19 @@ static void
embed_popout (GtkMenuItem *popout_menu, EmbedPlugin *embed)
{
GtkWidget *socket;
+
+ DBG(".");
+
if (!embed->plug_is_gtkplug) {
/* Since we're not hosting a gtkplug, we should reparent the window so we
* don't break the program we were hosting. */
- /* TODO: reparent */
+ /* Unfortunately, gtksocket auto-destroys its plugs, and just reparenting
+ * doesn't prevent that. More drastic measures will be needed. */
+ /* make_window_toplevel (embed->disp, embed->plug); */
}
/* Don't enable searching for a new window. */
embed->disable_search = TRUE;
/* destroy socket and make a new one. destroy does not trigger plug_removed */
- DBG("destroy");
socket = embed->socket;
embed_plug_removed (GTK_SOCKET (embed->socket), embed);
gtk_widget_destroy (socket);
diff --git a/panel-plugin/ewmh.c b/panel-plugin/ewmh.c
index 90c91da..68a236c 100644
--- a/panel-plugin/ewmh.c
+++ b/panel-plugin/ewmh.c
@@ -209,3 +209,10 @@ void get_window_size (Display *disp, Window win, gint *width, gint *height)
XGetGeometry (disp, win, &root, &relx, &rely,
(guint *)width, (guint *)height, &bw, &depth);
}
+
+
+void make_window_toplevel (Display *disp, Window win)
+{
+ XReparentWindow (disp, win, DefaultRootWindow (disp), 0, 0);
+ XFlush (disp);
+}
diff --git a/panel-plugin/ewmh.h b/panel-plugin/ewmh.h
index 1198293..fb2e697 100644
--- a/panel-plugin/ewmh.h
+++ b/panel-plugin/ewmh.h
@@ -28,6 +28,8 @@ gchar *get_window_title (Display *disp, Window win);
gchar *get_window_class (Display *disp, Window win);
void get_window_size (Display *disp, Window win, gint *width, gint *height);
+void make_window_toplevel (Display *disp, Window win);
+
G_END_DECLS
#endif /* !__EWMH_H__ */
More information about the Xfce4-commits
mailing list