Copied functions from MetalHead/gui.lisp.