Scanning all the children to see who has the focus seems to work good
enough, except for the case of bringing up any of the right click popup
menus. The popup menu of the textview doesn't seem to be considered a
child of the textview. And from what I remember of a comment in
gtkmenu.h, menu's can't
Unfortunately I think that when the popup menu appears, focus switches
to it automatically, and so the window really *has* lost focus.
Easiest solution I can see is to examine all the children
(recursively) of the window that has "lost" focus, and check to see if
any of them has focus. You can do