I would like to know how can I ask X11 which windows has focus. And if for any reason my own application (that may be visible or not) got the focus I want be able to let the former windows to get focus again.
For instance, my application is running with many others (e.g. firefox, gvim, nautilus,...)
Suppose that at first firefox has focus and that the user clicked on my app which now has the focus. I want that my application put focus on firefox again.
Does anyone knows how to achieve this? Books recommendations would be very nice.
Thanks a lot.