anchor.diff:  (defcfun ("XProcessInternalConnection" process-internal-connection) :void
     (display :pointer)
     (fd :int))
  +
  +(defcfun ("XGetEventData" x-get-event-data) :boolean
  +  (display-ptr :pointer)
  +  (cookie (:pointer x-generic-event-cookie)))
  +
  +(defcfun ("XFreeEventData" x-free-event-data) :void
  +  (display-ptr :pointer)
  +  (cookie (:pointer x-generic-event-cookie)))
  +
  +
  +(defcfun ("XQueryExtension" %x-query-extension) :boolean
  +  (display-ptr :pointer)
  +  (name :string)
  +  (major-opcode-return (:pointer :int))
  +  (first-event-return (:pointer :int))
  +  (first-error-return (:pointer :int)))
  +(defun x-query-extension (display name)
  +  (with-foreign-objects ((opcode :int) (event :int) (error :int))
  +    (if (%x-query-extension display name opcode event error)
  +        (values t (mem-ref opcode :int) (mem-ref event :int) (mem-ref error :int))
  +        (values nil 0 0 0))))
  +
  +
  +(defconstant +status-success+ 0)
  +(defconstant +status-bad-request+ 1)
  +(defconstant +status-bad-value+ 2)
  +(defconstant +status-bad-window+ 3)
  +;; bad-pixmap bad-atom bad-cursor bad-font bad-match bad-drawable bad-access bad-alloc bad-color bad-gc bad-id-choice bad-name bad-length bad-implementation=17
  
positive.code:          (make-instance 'glop:focus-in-event))
          (:focus-out
           (make-instance 'glop:focus-out-event))
          ;; unhandled event
          (t nil)))))
  
  (defcfun ("XLookupString" %x-lookup-string) :int
    (evt x-key-event) (buffer-return :pointer) (bytes-buffer :int)
  
negative.code:           (setf (mem-aref l :long 2) 0))))
        (x-send-event dpy (x-default-root-window dpy) nil (foreign-bitfield-value 'x-event-mask-flags '(:structure-notify-mask)) msg))))
  
  ;;; XGenericEvent events dispatch on a per-display 'opcode', so we
  ;;; store a map from display-ptr to an opcode->extension map for
  ;;; all known open display connections
  ;;; -- indexed by integer value of display-ptr since we can't portably use
  ;;;    cffi pointers as keys in a hash table (SBCL in particular can't use
  ;;;    any of the standard hash table tests on SAPs)
  
  ;; fixme: put this somewhere better?
  (defparameter *display-extensions* (make-hash-table :test 'eql))
  (defun get-display-extension-data (display opcode)
    (gethash opcode (gethash (pointer-address display) *display-extensions*)))
  
  (defun (setf get-display-extension-data) (value display opcode)
    (format t "setf get-display-extension-data ~s ~s ~s~%" value display opcode)
    (setf (gethash opcode (gethash (pointer-address display) *display-extensions*))
          value)
    (format t "-> ~s~%" (get-display-extension-data display opcode))
    value)
  
  (defclass extension-data ()
    ((name :initarg name :reader name)
     (opcode  :initarg opcode :reader opcode)
     (event-base :initarg event-base :reader event-base)
     (error-base :initarg error-base :reader error-base)))
  
  (defun x-open-display (&optional (display-name (null-pointer)))
    (let ((display (%x-open-display display-name)))
      (when (null-pointer-p display)
        (error "Unable to open display"))
      (when (gethash (pointer-address display) *display-extensions*)
        ;; can this happen? if so, need ref counts or something
        ;; so we don't remove it until all are closed...
        (warn "duplicate display in x-open-display? need to add reference couting..."))
      (setf (gethash (pointer-address display) *display-extensions*)
            (make-hash-table :test 'eql))
      display))
  
  (defun x-close-display (display)
    (remhash (pointer-address display) *display-extensions*)
    (%x-close-display display))
  
  (defmacro with-current-display (dpy-sym &body body)
    `(let ((,dpy-sym (x-open-display)))
  