[Xfce4-commits] <xfce4-embed-plugin:master> Fixed breakage due to reparenting windows not on the current workspace

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


Updating branch refs/heads/master
         to 3970bd1bfb63801071872841d6aba24686830c9e (commit)
       from b6a2527384b8ef0b3f28734065d1e7c4da5f3a20 (commit)

commit 3970bd1bfb63801071872841d6aba24686830c9e
Author: David Schneider <dnschneid at gmail.com>
Date:   Thu Dec 29 04:17:25 2011 -0500

    Fixed breakage due to reparenting windows not on the current workspace

 TODO                 |    6 +-----
 panel-plugin/embed.c |    3 ++-
 panel-plugin/ewmh.c  |   39 +++++++++++++++++++++++++++++++++++++++
 panel-plugin/ewmh.h  |    1 +
 4 files changed, 43 insertions(+), 6 deletions(-)

diff --git a/TODO b/TODO
index df8ddbd..2354c26 100644
--- a/TODO
+++ b/TODO
@@ -1,8 +1,4 @@
-Window detection and embedding (avoid excessive polling)
-Resizing, fixed/dynamic
-    * Fixed dimension (px)
-    * Set to window size
-    * Expand to available panel space
 Launching with parameters, delayed relaunch
     * Including %s or something with the GtkSocket id
+Generating label
 Option windows
diff --git a/panel-plugin/embed.c b/panel-plugin/embed.c
index f6f5af3..b7390ce 100644
--- a/panel-plugin/embed.c
+++ b/panel-plugin/embed.c
@@ -516,8 +516,9 @@ embed_add_fake_socket (EmbedPlugin *embed)
   gtk_box_pack_start (GTK_BOX (embed->hvbox), embed->socket, TRUE, TRUE, 0);
   g_signal_connect (G_OBJECT (embed->socket), "size-allocate",
                     G_CALLBACK (embed_size_allocate), embed);
+  show_window (embed->disp, embed->plug);
   reparent_window (embed->disp, embed->plug,
-                   gdk_x11_drawable_get_xid (gtk_widget_get_window (embed->socket)), 0, 0);
+      gdk_x11_drawable_get_xid (gtk_widget_get_window (embed->socket)), 0, 0);
   embed_plug_added (embed->socket, embed);
 }
 
diff --git a/panel-plugin/ewmh.c b/panel-plugin/ewmh.c
index 84a54aa..3b62487 100644
--- a/panel-plugin/ewmh.c
+++ b/panel-plugin/ewmh.c
@@ -94,6 +94,26 @@ static gchar *get_property (Display *disp, Window win, Atom xa_prop_type,
     return ret;
 }
 
+static void client_msg(Display *disp, Window win, gchar *msg, gulong data0) {
+    XEvent event;
+    glong mask = SubstructureRedirectMask | SubstructureNotifyMask;
+
+    event.xclient.type = ClientMessage;
+    event.xclient.serial = 0;
+    event.xclient.send_event = True;
+    event.xclient.message_type = XInternAtom(disp, msg, False);
+    event.xclient.window = win;
+    event.xclient.format = 32;
+    event.xclient.data.l[0] = data0;
+    event.xclient.data.l[1] = 0;
+    event.xclient.data.l[2] = 0;
+    event.xclient.data.l[3] = 0;
+    event.xclient.data.l[4] = 0;
+
+    if (!XSendEvent(disp, DefaultRootWindow(disp), False, mask, &event))
+        DBG("Cannot send %s event.", msg);
+    XSync (disp, False);
+}
 
 Window *get_client_list (Display *disp, gulong *size)
 {
@@ -229,3 +249,22 @@ void resize_window (Display *disp, Window win, gint width, gint height)
         XResizeWindow (disp, win, (guint)width, (guint)height);
     XSync (disp, False);
 }
+
+void show_window (Display *disp, Window win)
+{
+    gulong *cur_desktop = NULL;
+    Window root = DefaultRootWindow(disp);
+
+    if (! (cur_desktop = (unsigned long *)get_property(disp, root,
+            XA_CARDINAL, "_NET_CURRENT_DESKTOP", NULL))) {
+        if (! (cur_desktop = (unsigned long *)get_property(disp, root,
+                XA_CARDINAL, "_WIN_WORKSPACE", NULL))) {
+            DBG("Cannot get current desktop properties. "
+                "(_NET_CURRENT_DESKTOP or _WIN_WORKSPACE property)");
+            return;
+        }
+    }
+
+    client_msg(disp, win, "_NET_WM_DESKTOP", *cur_desktop);
+    g_free(cur_desktop);
+}
diff --git a/panel-plugin/ewmh.h b/panel-plugin/ewmh.h
index 302a298..f91b1a2 100644
--- a/panel-plugin/ewmh.h
+++ b/panel-plugin/ewmh.h
@@ -32,6 +32,7 @@ void make_window_toplevel (Display *disp, Window win, gint width, gint height);
 void reparent_window (Display *disp, Window win, Window parent,
 		      gint width, gint height);
 void resize_window (Display *disp, Window win, gint width, gint height);
+void show_window (Display *disp, Window win);
 
 G_END_DECLS
 


More information about the Xfce4-commits mailing list