#!/usr/bin/python3

import pyatspi

def listener(e):
    if e.type == "object:state-changed:focused" and not e.detail1:
        return

    if e.source.toolkitName != 'gtk':
        return

    if e.source.getRole() != pyatspi.ROLE_TEXT:
        return

    print(e)

pyatspi.Registry.registerEventListener(listener, "object:state-changed:focused", "focus:")
pyatspi.Registry.start()
