ui/x11
lib/ui/x11.vklib/ui/x11.vk
Pure-Veko X11 core wire-protocol codec (X11R6 little-endian over AF_UNIX /tmp/.X11-unix/X<n>).
Zero capabilities required; encodes connection setup, .Xauthority MIT-MAGIC-COOKIE-1 parsing,
pipelined CreateWindow/CreateGC/ChangeProperty/MapWindow requests, scanline-band chunked
PutImage frames (<= 128 KB per packet so 4K/Retina surfaces never hit X11's 262 KB BadLength cap),
and 32-byte X11 input/structure event packets.
X11Setup = struct { id_base i64, id_mask i64, root_window i64, white_pixel i64, root_visual i64, root_depth i64 }
Parsed X11 server setup parameters for the default root screen.
X11Band = struct { y i64, height i64, req_words i64, byte_count i64 }
One scanline band descriptor (y offset + height rows) for chunked PutImage transmission.
X11Event = struct { kind i64, x i64, y i64, key i64, btn i64 }
Decoded 32-byte X11 wire event mapped to canonical Veko ui event fields (kind, x, y, key, btn).
display-socket-path = fn [display str] str
Resolves the canonical AF_UNIX socket path (e.g. '/tmp/.X11-unix/X0') from a DISPLAY string (':0', 'unix:1.0').
use [x11 = ui/x11]
p0 = x11/display-socket-path ':0'
p2 = x11/display-socket-path 'unix:2.0'
if p0 != '/tmp/.X11-unix/X0' or p2 != '/tmp/.X11-unix/X2' [ err 'bad x11 path' ] else [ .ok ]
parse-xauthority-cookie = fn [raw bytes] bytes
Extracts the first 16-byte MIT-MAGIC-COOKIE-1 token from raw .Xauthority bytes (or empty bytes if absent).
encode-setup = fn [cookie bytes] bytes
Encodes the little-endian X11 connection setup packet (12 bytes unauthenticated, or 48 bytes with a 16-byte MIT-MAGIC-COOKIE-1).
parse-setup-reply = fn [pkt bytes] X11Setup
Parses a complete X11 Setup reply buffer (8-byte header + body) into X11Setup.
encode-window-init = fn [setup X11Setup, wid i64, gcid i64, title str, w i64, h i64] bytes
Encodes pipelined CreateWindow + CreateGC + ChangeProperty(WM_NAME) + MapWindow core requests.
plan-put-image-bands = fn [w i64, h i64] block[X11Band]
Plans scanline bands (<= 128 KB pixel payload per packet) so PutImage never exceeds X11's 16-bit 4-byte-word request cap (262,140 bytes).
use [x11 = ui/x11]
bands = x11/plan-put-image-bands 960 600
if (len bands) != 18 or bands[0].height != 34 or bands[0].req_words >= 65535 [ err 'bad bands' ] else [ .ok ]
encode-put-image-band = fn [wid i64, gcid i64, depth i64, rgba bytes, w i64, band X11Band] bytes
Encodes one 24-byte PutImage (ZPixmap) band packet + BGRA-swizzled scanlines from rgba.
decode-event-32 = fn [ev bytes] X11Event
Decodes a 32-byte X11 wire event packet into a canonical X11Event (kind = 0 when ignored).