3 Home
dxtr edited this page 2026-10-17 13:09:56 +02:00

cl-windowing

cl-windowing gives Common Lisp native windows and input on Wayland and Windows, and later on X11, without SDL or GLFW. It opens windows and popups and reports what happens to them: resizes, scale changes, close requests, focus, the keyboard, input methods and the pointer. All of it arrives as one event stream that allocates nothing. It also sets the pointer's cursor, holds the pointer for games, makes windows fullscreen, and reads and sets the clipboard's text. The optional system cl-windowing/vulkan creates Vulkan surfaces for its windows.

cl-windowing does not draw. Draw into its windows with cl-gfx, through cl-gfx/windowing, or with Vulkan directly, through cl-windowing/vulkan.

cl-windowing is one of the libraries of the Pyssel game engine. It does not depend on the engine and works on its own.

A first look

This opens a window, waits until the window system has given it a size, and lists the events that came in:

(asdf:load-system :cl-windowing/wayland)    ; on Windows, :cl-windowing/win32

(defpackage #:example
  (:use #:cl)
  (:local-nicknames (#:win #:cl-windowing)))
(in-package #:example)

(win:with-window-system (window-system)
  (win:with-window (window window-system :title "Hello" :width 800 :height 600)
    (loop until (win:window-configured-p window)
          do (win:process-events window-system :timeout 1))
    (let ((event (win:make-event)))
      (loop while (win:poll-event window-system event)
            collect (list (win:event-type event)
                          (win:event-width event) (win:event-height event))))))
;; => ((:RESIZE 800 600))
;; On Windows, the window gets the keyboard at once:
;; => ((:RESIZE 800 600) (:FOCUS-IN 0 0))

On Wayland a window appears only once something is drawn in it. To see the window and get input, go on to Getting Started, which draws into it with cl-gfx.

Pages

Using cl-windowing

  • Getting Started: requirements, the ASDF systems, a complete program, running the tests.
  • Concepts: the model behind the API. Read this before the rest.
  • Window Systems and Windows: connecting, backends, creating windows, titles, decorations, fullscreen, capabilities.
  • Events: process-events, poll-event, copy-event, the event types and their fields.
  • Keyboard: physical keys, logical keys, text, modifiers and key repeat.
  • Pointer: the pointer's position, motion, buttons and scrolling.
  • Cursors and Pointer Modes: the cursor over a window, and confining or capturing the pointer.
  • Popups: menus, lists to choose from and tooltips, placed against their parent.
  • Dialogs: windows made on another, modal or not.
  • Input Methods: text composed in an input method, as for Chinese and Japanese.
  • Clipboard: reading and setting the clipboard's text.
  • Resizing and Scaling: the resize handshake, units and pixels, fractional scales.
  • Threads: the event thread and the render thread.
  • Vulkan Surfaces: cl-windowing/vulkan, and swapchains of the right size.
  • Errors: the condition types and object lifetimes.

Reference

Status

Early work, on Wayland and Windows: windows, dialogs and popups, resizing by the user and by the program, fullscreen, whole and fractional scales, close requests, keyboard and pointer input, confining and capturing the pointer, input methods, the pointer's cursor, the clipboard's text, server-side decorations, and Vulkan surfaces. X11 comes next.

Licence

MIT.