Disclaimer: I know there is a very similar question on this topic.
I am trying to get exactly the same result that NoozNooz42 described here. However mdma answer doesn't fit my needs, because I'm interested in doing the same on linux. Preferrably with gnome, if it matters. So using JNA with user32 library is not a option here (or is it?).
Any suggestions will be great, I couldn't find almost anything on the topic.
P.S. The only thing I have found is wmctrl command (I could call and parse it in java eventually) that lists windows but doesn't give me any information about the z-order.
Update: It would be perfect if I could get a notification/callback when the z-order changes.
Use xprop, it shows window properties. List of windows in z-order is in property _NET_CLIENT_LIST_STACKING
of the root window:
xprop -root | grep '_NET_CLIENT_LIST_STACKING(WINDOW)'
Output should look like this:
_NET_CLIENT_LIST_STACKING(WINDOW): window id # 0x2000003, 0x4000004,
0x1c00004, 0x1c00030, 0x1c00033, 0x2e00004
Later you can get more info about particular windows with:
xprop -id <id>
or
xwininfo -id <id>