import pyatspi

def adc(event):
    print event, event.source, event.source.getState().contains(pyatspi.STATE_FOCUSED)
    print

pyatspi.Registry.registerEventListener(adc, "object:active-descendant-changed")
pyatspi.Registry.registerEventListener(adc, "focus:")

pyatspi.Registry.start()
