Reputation: 4267
Is there a way to find the id and maybe the path or the type(browser, ...) of the front most window in X?
Upvotes: 1
Views: 815
Reputation: 93468
To find out the window ID, try:
xprop -root|grep "_NET_CLIENT_LIST_STACKING(WINDOW): window id"
_NET_CLIENT_LIST_STACKING has bottom-to-top stacking order
One way to accomplish this is to parse the output of this command inside your application. The topmost window is the last on the list.
EDIT:
If you need to retrieve the process ID from the window ID, there's a small application here that shows how to do this trick. I successfully compiled it with:
g++ win_procid.cpp -o win_procid -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/libgtop-2.0 -lXtst -lgtop-2.0
I had to install the package libgtop2-dev because I didn't have it on my system.
Upvotes: 1