Index: xlsfonts/dsimple.c =================================================================== RCS file: /cvs/xorg/xc/programs/xlsfonts/dsimple.c,v retrieving revision 1.3 diff -u -r1.3 dsimple.c --- xlsfonts/dsimple.c 6 Oct 2004 19:29:59 -0000 1.3 +++ xlsfonts/dsimple.c 30 Dec 2004 17:54:22 -0000 @@ -498,13 +498,50 @@ fflush(stderr); } +/* + * Find child window at pointer position + */ +static Window Find_Child_At_Pointer(Display *dpy, Window win) +{ + Window root_return, child_return; + int dummyi; + unsigned int dummyu; + + XQueryPointer(dpy, win, &root_return, &child_return, + &dummyi, &dummyi, &dummyi, &dummyi, &dummyu); + return child_return; +} + +/* + * Check if window has WM_STATE set + */ +static int Window_Is_Client(Display *dpy, Window win) +{ + unsigned char *prop_ret; + Atom wm_state, type_ret; + unsigned long bytes_after, num_ret; + int format_ret; + + wm_state = XInternAtom(dpy, "WM_STATE", False); + if (!wm_state) return 0; + prop_ret = NULL; + XGetWindowProperty(dpy, win, wm_state, 0, 0x7fffffff, False, + wm_state, &type_ret, &format_ret, &num_ret, + &bytes_after, &prop_ret); + if (prop_ret) { + XFree(prop_ret); + return 1; + } + return 0; +} /* * Routine to let user select a window using the mouse */ -Window Select_Window(dpy) +Window Select_Window(dpy, frame) Display *dpy; + int frame; { int status; Cursor cursor; @@ -531,6 +568,14 @@ if (target_win == None) { target_win = event.xbutton.subwindow; /* window selected */ if (target_win == None) target_win = root; + if (target_win != root && !frame) { + Window win = target_win; + while (!Window_Is_Client(dpy, win)) { + win = Find_Child_At_Pointer(dpy, win); + if (win == None) break; + } + if (win != None) target_win = win; + } } buttons++; break; Index: xlsfonts/dsimple.h =================================================================== RCS file: /cvs/xorg/xc/programs/xlsfonts/dsimple.h,v retrieving revision 1.3 diff -u -r1.3 dsimple.h --- xlsfonts/dsimple.h 6 Oct 2004 19:29:59 -0000 1.3 +++ xlsfonts/dsimple.h 30 Dec 2004 17:54:22 -0000 @@ -91,7 +91,7 @@ unsigned long Resolve_Color(Window, char *); Pixmap Bitmap_To_Pixmap(Display *, Drawable, GC, Pixmap, int, int); -Window Select_Window(Display *); +Window Select_Window(Display *, int); void blip(void); Window Window_With_Name(Display *, Window, char *); #ifdef __GNUC__ Index: xprop/xprop.c =================================================================== RCS file: /cvs/xorg/xc/programs/xprop/xprop.c,v retrieving revision 1.2 diff -u -r1.2 xprop.c --- xprop/xprop.c 23 Apr 2004 19:55:03 -0000 1.2 +++ xprop/xprop.c 30 Dec 2004 17:54:25 -0000 @@ -1701,19 +1701,8 @@ if ((remove_props != NULL || set_props != NULL) && argc > 0) usage(); - if (target_win == None) { - target_win = Select_Window(dpy); - if (target_win != None && !frame_only) { - 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); - } - } + if (target_win == None) + target_win = Select_Window(dpy, frame_only); if (remove_props != NULL) { int count; Index: xwd/xwd.c =================================================================== RCS file: /cvs/xorg/xc/programs/xwd/xwd.c,v retrieving revision 1.2 diff -u -r1.2 xwd.c --- xwd/xwd.c 23 Apr 2004 19:55:09 -0000 1.2 +++ xwd/xwd.c 30 Dec 2004 17:54:31 -0000 @@ -199,22 +199,8 @@ /* * Let the user select the target window. */ - if (!target_win) { - target_win = Select_Window(dpy); - } - - if (target_win != None && !frame_only) { - 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); - } - } - + if (target_win == None) + target_win = Select_Window(dpy, frame_only); /* * Dump it! Index: xwininfo/xwininfo.c =================================================================== RCS file: /cvs/xorg/xc/programs/xwininfo/xwininfo.c,v retrieving revision 1.2 diff -u -r1.2 xwininfo.c --- xwininfo/xwininfo.c 23 Apr 2004 19:55:09 -0000 1.2 +++ xwininfo/xwininfo.c 30 Dec 2004 17:54:33 -0000 @@ -361,17 +361,7 @@ printf("xwininfo: Please select the window about which you\n"); printf(" would like information by clicking the\n"); printf(" mouse in that window.\n"); - window = Select_Window(dpy); - if (window && !frame) { - Window root; - int dummyi; - unsigned int dummy; - - if (XGetGeometry (dpy, window, &root, &dummyi, &dummyi, - &dummy, &dummy, &dummy, &dummy) && - window != root) - window = XmuClientWindow (dpy, window); - } + window = Select_Window(dpy, frame); } /*