(defvar xa-wait-for (intern-atom "EPOCH_WAIT_FOR"))
(pop-event 'focus)
(push-event 'focus
  (function
    (lambda (type state scr)
      (when (and state (not (equal (minibuf-screen) scr)))
	(select-screen scr)
	(ignore-event 'focus)
	(send-client-message scr nil xa-wait-for xa-wait-for)
      ))))
(push-message xa-wait-for
  (function
    (lambda (type value scr)
      (if (equal scr (current-screen)) (resume-event 'focus))
    )))
