Is it possible to find out what application/window/frame is currently hold a focus? It may be a shell command or a library that I can program with.
A:
Yes
At the low level this information can be extracted from the X server via xlib calls. At a higher level the window managers sometimes implement accessibility protocols which must communicate focus, and in any case their corresponding toolkits will have higher level abstractions.
An example of accessibility features are atk and at-spi. Libraries that provide window management functions will be good examples, see: XEmbed. Check Qt and Gnome documentation for C++ API elements dealing with focus.
DigitalRoss
2009-09-07 20:14:16
+1
A:
Modern window managers set a _NET_ACTIVE_WINDOW
property on the root window. See question http://stackoverflow.com/questions/1014822/
Marten
2009-09-07 20:23:51
Seems a lot more plausible than my answer.
Michiel Buddingh'
2009-09-07 20:38:46
What a shame ... I should have found that question in a search. Thanks anyway.
NawaMan
2009-09-07 22:51:59
A:
A quick excursion to Google suggests XGetInputFocus
. There's a nice example program linked here
Michiel Buddingh'
2009-09-07 20:30:44