Minimal xlib bindings. Names are converted from CamelCase to camel-case, with the "X" prefix dropped. Example:
;; Connect and open a small black window.
(define dsp (open-display ":0"))
(define screen (default-screen dsp))
(define rootwin (root-window dsp screen))
(define cmap (default-colormap dsp screen))
(define white (white-pixel dsp screen))
(define black (black-pixel dsp screen))
(define win (create-simple-window dsp rootwin 0 0 200 200 1 black black))
(define gc1 (create-gc dsp win 0))
(set-foreground dsp gc1 white)
(define gc2 (create-gc dsp win 0))
(set-foreground dsp gc2 black)
(define font (load-query-font dsp "*-helvetica-*-12-*"))
(set-font dsp gc1 (font-id font))
(select-input dsp win (+ KeyPressMask ButtonPressMask ExposureMask))
(map-window dsp win)
(flush dsp)
;; Loop, displaying each keystroke until a button is clicked.
(define e (make-event))
(let lp ()
(next-event dsp e)
(cond
((eq? (event-type e) Expose)
(draw-string dsp win gc 10 10 "Hello World!")
(lp))
((eq? (event-type e) KeyPress)
(let* ((code (key-event-keycode (event-key e)))
(state (key-event-state (event-key e)))
(str (string-append "key: " (number->string code)
" state: " (number->string state))))
(fill-rectangle dsp win gc2 0 11 200 30)
(draw-string dsp win gc 10 30 str))
(lp))
((not (eq? (event-type e) ButtonPress))
(lp))))
(any-event-serial XAnyEvent)
(any-event-send-event XAnyEvent)
(any-event-display XAnyEvent)
(any-event-window XAnyEvent)
(any-event-send-event XAnyEvent)
(any-event-display XAnyEvent)
(any-event-window XAnyEvent)
(expose-event-x XExposeEvent)
(expose-event-y XExposeEvent)
(expose-event-width XExposeEvent)
(expose-event-height XExposeEvent)
(expose-event-count XExposeEvent)
(expose-event-y XExposeEvent)
(expose-event-width XExposeEvent)
(expose-event-height XExposeEvent)
(expose-event-count XExposeEvent)
(key-event-x XKeyEvent)
(key-event-y XKeyEvent)
(key-event-time XKeyEvent)
(key-event-state XKeyEvent)
(key-event-keycode XKeyEvent)
(key-event-y XKeyEvent)
(key-event-time XKeyEvent)
(key-event-state XKeyEvent)
(key-event-keycode XKeyEvent)
(button-event-x XButtonEvent)
(button-event-y XButtonEvent)
(button-event-time XButtonEvent)
(button-event-state XButtonEvent)
(button-event-button XButtonEvent)
(button-event-y XButtonEvent)
(button-event-time XButtonEvent)
(button-event-state XButtonEvent)
(button-event-button XButtonEvent)
(motion-event-x XMotionEvent)
(motion-event-y XMotionEvent)
(motion-event-time XMotionEvent)
(motion-event-state XMotionEvent)
(motion-event-y XMotionEvent)
(motion-event-time XMotionEvent)
(motion-event-state XMotionEvent)