--- src/oldClientWin.c 2006-07-29 02:30:22.000000000 -0500 +++ src/ClientWin.c 2006-07-29 02:35:06.000000000 -0500 @@ -82,18 +82,18 @@ if (!XQueryTree(dpy, win, &root, &parent, &children, &nchildren)) return 0; - for (i = 0; !inf && (i < nchildren); i++) { + for (i = nchildren; !inf && i; i--) { data = NULL; - XGetWindowProperty(dpy, children[i], WM_STATE, 0, 0, False, + XGetWindowProperty(dpy, children[i-1], WM_STATE, 0, 0, False, AnyPropertyType, &type, &format, &nitems, &after, &data); if (data) XFree(data); if (type) - inf = children[i]; + inf = children[i-1]; } - for (i = 0; !inf && (i < nchildren); i++) - inf = TryChildren(dpy, children[i], WM_STATE); + for (i = nchildren; !inf && i; i--) + inf = TryChildren(dpy, children[i-1], WM_STATE); if (children) XFree(children); return inf;