How do i programmatically determine all the non-minimized (visible) windows on screen?

view story

http://askubuntu.com – I would like to programmatically determine all of the visible windows on the desktop so that i can place my window, if possible, so that it does not cover up other windows. It is possible to do this using the wnck package (libwnck-3-dev, to be exact) on ubuntu 12.04. However, in order to actually compile and link in code from wnck, you must define the symbol WNCK_I_KNOW_THIS_IS_UNSTABLE (you get a compile error otherwise). This makes me think that this interface is not intended to be relied on. The interface is very good (provides window name, geometry, whether the window is minimized or m (HowTos)