This document describes the architectural design, component interactions, and data flow of wayshadow.
wayshadow is a minimalist, elegant keystroke visualization overlay designed for Wayland compositors. It intercepts input events system-wide using libinput via udev and renders smooth, configurable visual indicators onto a Wayland ARGB surface with cairo and pango.
+---------------------+
| libinput / |
| evdev (udev) |
+----------+----------+
|
v
+------------------+ InputManager +------------------+
| TrayIcon | | | WaylandContext |
| (AppIndicator) | v | (wl_compositor,|
+--------+---------+ XkbHandler | xdg_wm_base, |
| | | wl_shm) |
| v +--------+---------+
| TextBuffer |
| | |
+--------\ v /--------+
\ Application /
\ | /
v v v
WindowManager
|
v
Renderer
|
v
Cairo / wl_shm
Color: Strong value-type representation of RGBA values withconstexprpalette constants and hex parser (#RRGGBB/#RRGGBBAA).Config: Strong configuration settings loaded from~/.config/wayshadow/wayshadow.confor command-line arguments.TextBuffer: Manages the visible keystroke stream, history, repeat compaction (e.g.k×4), atomic backspaces, and word deletions.ClientState: Encapsulates runtime application state, modifier keys status, mouse position, click timestamps, and redraw dirty flags.
InputManager: Openslibinputdevices viaudevunderseat0. Dispatches events into high-level C++ callbacks.XkbHandler: RAII wrapper aroundxkb_context,xkb_keymap, andxkb_state. Translates Linux input scancodes into UTF-8 characters, special symbol names (Enter,Esc,Tab), and modifier combos (Ctrl+Shift+T).
ShmPool: POSIX shared memory file creator (shm_open,ftruncate,wl_shm_create_pool).Icons: Procedural vector drawing for keyboard glyphs (Arrows, Enter, Media controls, Function key badges) rendered directly into Cairo contexts.Renderer: Computes text measurements, right-aligned scrolling offsets, superscripts for repeat multipliers, and mouse coordinate badges.
WaylandContext: Manages Wayland client connection (wl_display), registry listener, compositor, seat, andxdg_wm_base.WindowManager: Manages creation, configuration, destruction, and presentation ofxdg_surfaceandxdg_toplevel.TrayIcon: Integrates with Desktop Application Status Tray (libappindicatorandgtk3) to toggle overlay visibility or exit the application.Application: Glues GLib main event loop (GMainLoop), Wayland socket file descriptors, input event channel, and frame timer (16ms / ~60 FPS).