shadow: improve X11 event handling