The X server has no concept of widgets. It only knows windows.
If an application has a text input, a radio group, and a push button implemented all in a single window, then nothing outside of the application has any idea about which widget it currently considers active or focused or whatever.
If the text widget is actually implemented as a window, you can get focus change events on it. You need to call XSelectInput on that window.
In addition, it's not clear how you can differentiate between text input windows and other kinds of windows in other applications. The X server has no idea which windows are text-input ones.