It has always annoyed me that xwd's -frame option does not work
when a window id is given with -id.  Yes, i know that these are
separate windows with separate ids, but the id of the actual
client window is much more easily available than the window
manager frame's id (for example, easily available to fvwm
functions via $w).

So i changed the frame_only logic (any way we can change that
variable name?  It isn't at all accurate...) instead of just
skipping the find-the-real-client-window step if -frame is given,
it will actually climb the window tree to find the wm frame.

What do you think?

Index: programs/xwd/xwd.c
===================================================================
RCS file: /cvs/xc/programs/xwd/xwd.c,v
retrieving revision 3.12
diff -a -u -r3.12 xwd.c
--- programs/xwd/xwd.c  2002/09/19 00:19:56     3.12
+++ programs/xwd/xwd.c  2002/11/21 22:19:20
@@ -203,16 +203,37 @@
        target_win = Select_Window(dpy);
     }
     
-    if (target_win != None && !frame_only) {
-        Window root;
-        int dummyi;
-        unsigned int dummy;
+    if (target_win != None) {
+        if (frame_only) {
+            Status status;
+            Window root, parent;
+            Window *children;
+            int nchildren;
 
-        if (XGetGeometry (dpy, target_win, &root, &dummyi, &dummyi,
+            for (;;) {
+                status = XQueryTree(dpy, target_win, &root, &parent,
+                                    &children, &nchildren);
+                if (!status)
+                    break;
+                if (children)
+                    XFree(children);
+
+                if (!parent || parent == root)
+                    break;
+                else
+                    target_win = parent;
+            }
+        } else {
+            Window root;
+            int dummyi;
+            unsigned int dummy;
+
+            if (XGetGeometry (dpy, target_win, &root, &dummyi, &dummyi,
                              &dummy, &dummy, &dummy, &dummy) &&
-                              target_win != root) {
-             target_win = XmuClientWindow (dpy, target_win);
-       }
+                target_win != root) {
+                target_win = XmuClientWindow (dpy, target_win);
+            }
+        }
     }
 
 
Index: programs/xwd/xwd.man
===================================================================
RCS file: /cvs/xc/programs/xwd/xwd.man,v
retrieving revision 1.9
diff -a -u -r1.9 xwd.man
--- programs/xwd/xwd.man        2002/04/22 20:53:10     1.9
+++ programs/xwd/xwd.man        2002/11/21 22:19:21
@@ -77,8 +77,7 @@
 .PP
 .TP 8
 .B "-frame"
-This option indicates that the window manager frame should be included when
-manually selecting a window.
+This option indicates that the window manager frame should be included.
 .PP
 .TP 8
 .B "-root"
_______________________________________________
Xpert mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/xpert

Reply via email to