Find out in Linux which application / frame is in focus?

Is it possible to find out which application / window / frame is currently holding focus? It could be a shell command or a library that I can program with.

+2


source to share


3 answers


Modern window managers set a property _NET_ACTIVE_WINDOW

on the root window. See Question How do I know which window has focus and how can I change it?



+2


source


Yes

At a low level, this information can be retrieved from the X server using xlib calls. At a higher level, window administrators sometimes implement accessibility protocols that must bind focus, and in any case, their respective tools will have higher level abstractions.



Examples of accessibility functions are atk and at-spi. Libraries that provide windowing functions are good examples: see XEmbed. Check out Qt and Gnome documentation for focus related C ++ API elements.

0


source


A quick tour of Google suggests XGetInputFocus

. There's a good example program linked here

0


source







All Articles