Accessibility
Every widget exposes a semantic snapshot, every control works from the keyboard, and an in-process AT-SPI bridge serves both to screen readers.
Modes
The bridge (internal/atspi) runs while the desktop asks for assistive technologies (org.a11y.Status IsEnabled or ScreenReaderEnabled on the session bus) and stops when it stops asking. Otherwise the tree is never walked. No app code is needed.
| Setting | Effect |
|---|---|
Application.SetAccessibility(app.A11yAuto) | default: follow the desktop's switch |
app.A11yOn | always serve |
app.A11yOff | never serve |
LYS_UI_A11Y=atspi / none | overrides the app, like GTK_A11Y |
Semantic model
widget.Describe(w) returns an A11yState:
- role (
Role, mirroring AT-SPI: button, label, entry, text-area, slider, switch, check-box, progress-bar, scroll-area, list, menu, tab-list, image, ...). AnImageViewis an image described by its zoom; anImageis an image while it is named (SetAccessibleNameor a tooltip) and decoration, with no role, while it is not; - name:
SetAccessibleName, else the tooltip, else the label text; - text with caret and selection as rune offsets;
- checked state and min/max/value/step;
- expansion:
ExpansionNone, or for a disclosure triggerExpansionCollapsedorExpansionExpanded, set withSetAccessibleExpansion.Expander, anAccordionItem's trigger and anActionRowwith a disclosure (ExpanderRow) set it themselves. The bridge serves it as AT-SPI's expandable state, plus expanded while open; - editable, multiline, enabled (including ancestors), focusable;
- bounds.
Read-only text reports editable false. Disabled widgets report enabled, editable and focusable false. widget.DescribeTree(root) walks in paint order, which is also focus order.
Keyboard
Every interactive control is reachable by Tab and activated by Enter or Space. A bar takes the keyboard only when asked: BarWindow.WalkKeyboard(done) focuses its first control, moves with the arrows and Tab, presses with Enter or Space, and releases on Esc.
Announcements
widget.Announce(w, text, politeness) speaks text without moving focus. widget.SetLiveRegion(w, politeness) makes every label text change inside w speak. Politeness is widget.Polite or widget.Assertive. A live region that changes several times in one pass speaks once. Announcements from widgets not in a served window are dropped. Toasts are polite live regions.
The bridge
- On the loop, a sampling pass builds a tree of
widget.A11yStatesnapshots keyed by stable widget identity. An emitter goroutine publishes it, diffs it against the previous tree and emits events. D-Bus handlers answer from the published snapshot. - A poller checks
widget.A11yGenerationevery 100 ms and samples only when it moved.Application.ServeAccessibility(app.A11YOptions{Poll: d}, done)sets another interval. - Registration: finds the bus with
org.a11y.Bus.GetAddress, claimsorg.a11y.atspi.lysui.p<pid>, exports/org/a11y/atspi/accessible/root, embeds throughorg.a11y.atspi.Socket.Embed. - Interfaces: Accessible, Component (window-relative extents and hit testing), Text (contents, caret, selections, boundaries, character geometry), Action (through the widget's click path), Value (settable for sliders), Application on the root, and
org.a11y.atspi.Cache. All supportorg.freedesktop.DBus.Propertiesand Introspect. Component.GrabFocusmoves focus through the window's router; Text's caret and selection setters work on anywidget.TextSelector.- Events: focus, state-changed (checked, pressed, expandable, expanded, enabled, sensitive, editable), text-caret-moved, TextChanged, TextSelectionChanged, bounds-changed, children-changed, PropertyChange for name and value, and
Object.Announcement. Order is deterministic: focus first, then per node by ascending id.
Limits
- Component coordinates are window-relative; Wayland gives clients no screen position.
- Text attributes (
GetAttributeRun) report none. - No Selection or Table interfaces.
Verification
| Command | Checks |
|---|---|
just atspi | the bridge against a private bus that plays registry and AT |
just atspi-verify | against real at-spi2-core: launcher and registryd on a private bus |
go run -tags atspi ./cmd/lys-ui-a11y | the a11y demo with the bridge forced on, for Orca or Accerciser |
Applications test their own tree with atspitest: Start brings up at-spi2-core on a private bus (skipped without ATSPI_LIBEXEC; ATSPI_GSETTINGS_SCHEMA_DIR supplies the schema), Enable turns on the desktop switch, Application finds the app, and Names walks its tree.