$ xwininfo -tree
1 child:
0x5a00005 (has no name): ("explorer.exe"
"Wine") 20x24+0+0 +953+0
1 child:
0x5a00006 (has no name): () 20x24+0+0 +953+0
On my system, it shows the location of wine's tray icon area, known as
"explorer.exe" at position 953,0 as well as an unnamed icon for
taskmgr. (I was running taskmgr in the tray at the time.) That's the
problem. A lot of these tray icons aren't going to have names.
The xwininfo source code should offer up enough information to write a program
for linux.
[Embarassed] You didn't specify if you wanted to program for linux or
windows.
Windows stuff: Get to know the Windows API. Use FindWindow() if you know the
name or title of the icon and pass the hwnd to GetWindowRect(). For all intents
and purposes, the icons can be treated as desktop windows.
If you don't know the name of the icon or they don't have one, you can
enumerate top-level windows with GetDesktopWindow(), EnumChildWindows(). Have
fun!