Expand description
softer_gui: CPU-rendered windowing with vblank-exact frame pacing and a single ordered input+render event stream. Design lifted from lingua_brevis fulcra/unix_future_gui.lbc; platform layers speak the X11/Wayland wire protocols directly so the binary links statically. Zero dependencies.
Plain polling, no callbacks:
let mut gui = softer_gui::open(“title”, “com.example.app”, 800, 600).unwrap(); let mut ev = Event::default(); loop { gui.wait(); while gui.next_event(&mut ev) { match ev.kind { EVENT_RENDER => { let fb = gui.get_framebuffer(); // fb.pixels is null on backpressure: skip the frame if !fb.pixels.is_null() { draw(&fb); gui.submit(); } } EVENT_CLOSE => return, _ => apply_input(&ev), } } }
The framebuffer is a square power-of-two, bigger than the window; render the
window-sized top-left sub-rect with stride = side. key is stable per buffer
in steady state and changes for both on any realloc, so a renderer can cache
“what I drew per key” and patch only the diff.
On macOS call open from the main thread: the library keeps that thread for
AppKit and hands the caller’s stack to a new thread, which is what returns
from open. Nothing else differs.
Re-exports§
pub use event::*;
Modules§
- event
- The event model: one totally ordered SPSC ring carrying input AND frame boundaries, stamped with DISPLAY time; the pump-side keyboard state machine (absolute button bitmap, layout text, dead keys, WM-driven autorepeat).
- icon
- Icon pixels, and the two container formats the host systems demand of us.
- install
- Installing the running program into the host system so it shows up in application search with its icon.
- keysym
- Keysym ↔ name/char, keypad and modifier classification, dead-key composition.
- sys
- Raw Linux syscalls. No libc declarations, no header crates: the kernel ABI is the only contract. x86_64 and aarch64.
- x11_
conn - X11 wire protocol: socket, .Xauthority, setup, request encoding, packet reading. Little-endian host only (the setup announces our byte order; x86_64/aarch64 both LE).
- xkb
- A minimal XKB keymap engine: keycode + (real modifier mask, group) -> keysym. Fed either from the XKB text keymap a Wayland compositor hands over, or from the X server’s XkbGetMap reply. Key types, symbols and virtual-modifier resolution only — no actions, indicators, geometry or compose; modifier and group STATE is computed by the server on both platforms and arrives with each key event, so nothing here has to model latching or locking.
Structs§
- Framebuffer
- A back buffer to draw into. Pixels are 0xAARRGGBB with alpha 0xFF; stride is
side.pixelsis null when no buffer is free (both still held by the display server). - Gui
- Options
- How to open the window.
Enums§
- Backend_
- Which backend to use, when more than one could serve.
- D3dDriver
- Which D3D11 device to ask for. Windows only, and only for
Backend_::D3d.
Functions§
- next_
pow2 - Smallest power of two ≥ n (and ≥ 256): the square framebuffer’s side.
- open
- Open a window.
app_idnames the application for the desktop (WM_CLASS / xdg app_id, e.g. “com.example.app”; seeinstall). Linux: Wayland first, X11 fallback (SOFTER_GUI_X11=1 forces X11). macOS: main thread only. In an APE the host is not known until the program starts, so the backend is picked here rather than by the compiler. - open_
with open, with the choices made explicitly rather than read from the environment. This is what a program with its own command line should call.