Skip to content

Pure-Go X11 windowing backend (sovereign wire protocol, present, input, Run loop) - #1

Merged
tannevaled merged 3 commits into
mainfrom
feat/x11-backend
Aug 8, 2026
Merged

Pure-Go X11 windowing backend (sovereign wire protocol, present, input, Run loop)#1
tannevaled merged 3 commits into
mainfrom
feat/x11-backend

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Date: 2026-08-08

A pure-Go, CGO=0, zero-non-stdlib-dependency X11 windowing backend for the go-widgets toolkit. The X11 core protocol (v11.0) is implemented from scratch over the unix socket — no Xlib, no XCB, no cgo — mirroring the sovereign transport+codec approach of go-freedesktop/dbus.

Phases

  • P1 — wire codec + connection setup (internal/x11): byte-order-parametric encoder/decoder (l/B), setup handshake (protocol 11.0), MIT-MAGIC-COOKIE-1 Xauthority parsing/matching, Setup reply parse (roots/visuals/depths/resource-id base+mask/keycodes), sequence tracking, request/reply/error/event demux. 100% statement coverage, both byte orders, error branches included.
  • P2 — window + present: XID allocation, CreateWindow (TrueColor via CopyFromParent) + WM_NAME/WM_CLASS + WM_PROTOCOLS=WM_DELETE_WINDOW, MapWindow, CreateGC, PutImage (ZPixmap; RGBA→visual pixel packing; max-request tiling). presentRect damage path ready for scene damage.
  • P3 — input + lifecycle: Expose|Key*|Button*|MotionNotify|ConfigureNotify|ClientMessagetoolkit.Event; keycode→keysym via GetKeyboardMapping; Window.Run(root) host loop (layout/draw/present + dispatch + resize relayout).

Non-linux Open returns ErrUnsupported (cross-builds stay green); the transport-agnostic windowing logic is exercised in-process vs a scripted fake X server.

Verification

  • internal/x11: 100% coverage.
  • CI: CGO=0 build+vet+test (ubuntu+macos), 100%-cov gate on internal/x11, native amd64/arm64, qemu riscv64/loong64/ppc64le/s390x (big-endian on s390x), darwin stub lane, Xvfb live-integration lane (present pattern → import capture → assert pixels; xdotool click+key → assert dispatched toolkit.Event).

Wayland is a separate future backend, out of scope here.

🤖 Generated with Claude Code

tannevaled and others added 3 commits August 8, 2026 22:05
… cov)

Pure-Go, CGO=0, stdlib-only implementation of the X11 core protocol
(v11.0) spoken directly over a byte stream: wire encoder/decoder (both
byte orders), connection setup handshake, MIT-MAGIC-COOKIE-1 Xauthority
parsing/matching, keycode->keysym mapping, request/reply/error/event
demux, PutImage with RGBA->wire pixel conversion + max-request tiling.

Transport-agnostic Conn (io.ReadWriteCloser) exercised in-process
against a scripted fake server: 100.0% statement coverage.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- window.Open (linux): dial $DISPLAY unix socket, MIT-MAGIC-COOKIE-1 auth,
  handshake, CreateWindow (TrueColor via CopyFromParent) + WM_NAME/WM_CLASS +
  WM_PROTOCOLS/WM_DELETE_WINDOW, CreateGC, MapWindow, GetKeyboardMapping.
- Non-linux Open stub returns ErrUnsupported (cross-builds stay green).
- Present: painter.PixelPainter -> RGBA buffer -> PutImage (visual pixel
  packing + max-request tiling); presentRect damage path ready for scene damage.
- Input: Expose/Key/Button/Motion/Configure/ClientMessage -> toolkit.Event;
  keycode->keysym via fetched keymap; WM_DELETE_WINDOW closes.
- Window.Run host loop: layout/draw/present + event dispatch + resize relayout.
- cmd/windowdemo example; README; CI (CGO=0, 6-arch qemu, 100% x11 cov gate,
  darwin stub lane, Xvfb live-integration lane).
- Root windowing logic tested in-process vs scripted fake X server.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit 2ef32e5 into main Aug 8, 2026
10 checks passed
@tannevaled
tannevaled deleted the feat/x11-backend branch August 8, 2026 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant