Documentation
¶
Overview ¶
Package atspi is the in-process AT-SPI bridge (#65): it serves the widget tree's accessibility semantics (widget.Describe and the semantic roles, the plain-Go model of widget/a11y.go) over D-Bus in the AT-SPI2 shape, so screen readers and tools like accerciser can walk a lys-ui application. It ships in every build; the application starts it when the desktop asks for assistive technologies (org.a11y.Status, status.go), so without one it costs nothing.
The bridge is snapshot-driven: a sampling pass runs on the application's loop goroutine (Scene.Invoke), rebuilds the tree of widget.A11yState snapshots keyed by stable widget identity, and diffs it against the previous pass — every difference becomes the AT-SPI events: focus (and state-changed focused), state-changed (checked, enabled, sensitive, editable), text-changed, text-selection-changed, text-caret-moved, property-change (name, value), bounds-changed, children-changed for tree updates, and the Cache's add/remove. Handlers answer D-Bus method calls from the published snapshot only, never touching widgets off the loop goroutine.
Snapshot lookups, properties, text boundaries, and introspection — the read-side helpers behind the exported tables. Everything reads the published tree under the bridge mutex and returns copies; no handler can observe a half-built pass.
The D-Bus object surface: the AT-SPI interface handlers exported per accessible object. Each interface is a small struct with the interface's methods (godbus's ExportAll path — the map form of Export does not dispatch in this godbus version, which the appearance tests already note). Every handler reads the published snapshot under the bridge mutex — no widget is ever touched from the D-Bus handler goroutine — and the actions that must reach widgets (DoAction, SetCurrentValue, GrabFocus, the caret and selection setters) hop through Scene.Invoke onto the loop; the geometry probes wait for theirs (programmatic.go).
Introspection XML for the served interfaces, mirroring the at-spi2-core interface definitions (xml/*.xml) — AT tooling introspects objects before calling, so the signatures must match the specs exactly.
Index ¶
Constants ¶
const CachePath dbus.ObjectPath = "/org/a11y/atspi/cache"
CachePath is the Cache object's path, fixed by the AT-SPI spec.
const DefaultPoll = 100 * time.Millisecond
DefaultPoll is the sampling cadence: fast enough that a screen reader hears state changes promptly, slow enough that the walk never matters in a profile (it is a DescribeTree over the window roots).
const RootPath dbus.ObjectPath = "/org/a11y/atspi/accessible/root"
RootPath is the application root's object path, fixed by the AT-SPI spec ("An application must have a single root object, called /org/a11y/atspi/accessible/root").
Variables ¶
This section is empty.
Functions ¶
func WatchStatus ¶
WatchStatus reports the switch to fn: once before returning, then on every change, from the watch's goroutine. address is the session bus; empty reads DBUS_SESSION_BUS_ADDRESS. No session bus, or none with org.a11y.Bus, is an error. stop ends the watch.
Types ¶
type Bridge ¶
type Bridge struct {
// contains filtered or unexported fields
}
Bridge is a served scene. Serve starts it; Stop tears it down. Every method is safe from any goroutine; snapshots are immutable and swapped under the bridge mutex.
func Serve ¶
Serve connects to the accessibility bus, exports the scene, embeds with the registry, and starts sampling. The returned error is fatal for the bridge; a registry without a Socket.Embed (older at-spi2 watches for new bus names instead) is not — it logs and idles.
type Options ¶
type Options struct {
// Address is the accessibility bus address; empty discovers it
// through org.a11y.Bus.GetAddress on the session bus (which
// dbus-activates at-spi-bus-launcher on a real desktop).
Address string
// Name is the bus name to claim; empty picks
// org.a11y.atspi.lysui.p<pid> (a bus element may not lead with a
// digit).
Name string
// Poll is the sampling interval. Zero means the default (100ms);
// negative means no ticker — the embedder drives Refresh itself.
Poll time.Duration
}
Options tune Serve. The zero value is the production default.
type Scene ¶
type Scene interface {
// Roots returns the window roots in window order; the bridge's
// synthetic application node parents them.
Roots() []widget.Widget
// Focused returns the focused widget of the topmost window, nil
// when nothing holds focus.
Focused() widget.Widget
// Invoke runs fn on the application's loop goroutine, asynchronously.
Invoke(fn func())
// SetFocus moves keyboard focus to w through its window's router
// (AT-driven focus), failing as widget.Router.SetFocus does; called
// on the loop goroutine.
SetFocus(w widget.Widget) error
}
Scene is what the bridge serves: the accessible roots (one per window, in window order) and their focus, plus the loop bridge. app.Application implements it (app/atspi.go); Roots and Focused are only ever called inside Invoke — on the loop goroutine, where the widget tree and its routers are consistent.