'Returns a chain of targets that can handle this event
Finds functions named `handle_X`, either on the window object itself or
on the Qtile instance, where X is the event name (e.g.  EnterNotify,
ConfigureNotify, etc).
The event will be passed to each target in turn for handling, until one
of the handlers returns False or None, or the end of the chain is
reached.'

def get_target_chain(self, ename, e):

    chain = []
    handler = ('handle_%s' % ename)
    eventEvents = ['EnterNotify', 'ButtonPress', 'ButtonRelease', 'KeyPress']
    if hasattr(e, 'window'):
        c = self.windowMap.get(e.window)
    elif hasattr(e, 'drawable'):
        c = self.windowMap.get(e.drawable)
    elif (ename in eventEvents):
        c = self.windowMap.get(e.event)
    else:
        c = None
    if ((c is not None) and hasattr(c, handler)):
        chain.append(getattr(c, handler))
    if hasattr(self, handler):
        chain.append(getattr(self, handler))
    if (not chain):
        logger.info(('Unhandled    event:    %r' % ename))
    return chain
