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.
Asked
Active
Viewed 2,139 times
3 Answers
2
Modern window managers set a _NET_ACTIVE_WINDOW
property on the root window. See question How to know which window has focus and how to change it?
-
Seems a lot more plausible than my answer. – Michiel Buddingh Sep 07 '09 at 20:38
-
What a shame ... I should have found that question in a search. Thanks anyway. – NawaMan Sep 07 '09 at 22:51
0
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
- 143,651
- 25
- 248
- 329
0
A quick excursion to Google suggests XGetInputFocus
. There's a nice example program linked here

Michiel Buddingh
- 5,783
- 1
- 21
- 32
-
That link currently goes to a "modern web site layout spectacular parade" site, not a nice example program? – Dronz Oct 24 '20 at 02:34