Well, I changed your patch a little bit, since you expect that
XQueryTree will set children_return to NULL if there aren't any
windows. Unfortunately at least in the past there were some X
implementations which didn't touch children_return but depended on
nchildren_return, that's why I keep wins initialized to NULL.

Kind regards,
Anselm

2008/8/15 Martin Hurton <[EMAIL PROTECTED]>:
> The patch below makes the scan() function a little simpler.
> Comments are welcome.
>
> Cheers,
> /Martin
>
> diff -r bca7a556aa03 dwm.c
> --- a/dwm.c     Thu Aug 14 22:35:52 2008 +0200
> +++ b/dwm.c     Fri Aug 15 13:34:05 2008 +0200
> @@ -1249,7 +1249,6 @@
>        Window *wins, d1, d2;
>        XWindowAttributes wa;
>
> -       wins = NULL;
>        if(XQueryTree(dpy, root, &d1, &d2, &wins, &num)) {
>                for(i = 0; i < num; i++) {
>                        if(!XGetWindowAttributes(dpy, wins[i], &wa)
> @@ -1265,9 +1264,9 @@
>                        && (wa.map_state == IsViewable || getstate(wins[i]) == 
> IconicState))
>                                manage(wins[i], &wa);
>                }
> +               if(wins)
> +                       XFree(wins);
>        }
> -       if(wins)
> -               XFree(wins);
>  }
>
>  void

Reply via email to