(chibi xlib)

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))))

(display? obj)

(graphics-context? obj)

(font? obj)

(font-id XFontStruct)

(any-event-serial 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)

(key-event-x 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)

(motion-event-x XMotionEvent)

(motion-event-y XMotionEvent)

(motion-event-time XMotionEvent)

(motion-event-state XMotionEvent)

unsigned-long: NoEventMask

unsigned-long: ExposureMask

unsigned-long: KeyPressMask

unsigned-long: KeyReleaseMask

unsigned-long: ButtonPressMask

unsigned-long: EnterWindowMask

unsigned-long: LeaveWindowMask

unsigned-long: KeyPress

unsigned-long: KeyRelease

unsigned-long: ButtonPress

unsigned-long: ButtonRelease

unsigned-long: MotionNotify

unsigned-long: EnterNotify

unsigned-long: LeaveNotify

unsigned-long: FocusIn

unsigned-long: FocusOut

unsigned-long: KeymapNotify

unsigned-long: Expose

unsigned-long: GraphicsExpose

unsigned-long: NoExpose

(open-display string)

(default-screen Display)

(root-window Display int)

(default-colormap Display int)

(black-pixel Display int)

(white-pixel Display int)

(store-name Display unsigned-long string)

(create-simple-window Display unsigned-long int int unsigned-int unsigned-int unsigned-int unsigned-long unsigned-long)

(create-gc Display unsigned-long int void*)

(set-foreground Display GC unsigned-long)

(select-input Display unsigned-long unsigned-long)

(map-window Display unsigned-long)

(flush Display)

(next-event Display _XEvent)

(put-back-event Display _XEvent)

(draw-point Display unsigned-long GC int int)

(draw-line Display unsigned-long GC int int int int)

(draw-arc Display unsigned-long GC int int int int int int)

(draw-rectangle Display unsigned-long GC int int int int)

(fill-rectangle Display unsigned-long GC int int int int)

(load-query-font Display string)

(set-font Display GC unsigned-long)

(draw-string Display unsigned-long GC int int string)