atspi

package
v0.2.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 and nothing it does on the loop waits on a bus. Serve runs off the loop. A poller goroutine watches the scene's accessibility generation and only when it moved does a sampling pass run on the application's loop goroutine (Scene.Invoke), rebuilding the tree of widget.A11yState snapshots keyed by stable widget identity. The emitter goroutine takes the finished tree, publishes it, and diffs it against the previous one: every difference becomes the AT-SPI events it sends: 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

View Source
const CachePath dbus.ObjectPath = "/org/a11y/atspi/cache"

CachePath is the Cache object's path, fixed by the AT-SPI spec.

View Source
const DefaultPoll = 100 * time.Millisecond

DefaultPoll is the cadence the scene's generation is checked at: fast enough that a screen reader hears state changes promptly. A check that finds no change costs one atomic load, so an idle scene never wakes the loop.

View Source
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

func WatchStatus(address string, fn func(enabled bool)) (stop func(), err error)

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. It waits on the bus, so call it off the loop goroutine.

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

func Serve(scene Scene, opts Options) (*Bridge, error)

Serve connects to the accessibility bus, exports the scene, embeds with the registry, and starts sampling. It waits on the bus, so call it off the loop goroutine. 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.

func (*Bridge) Refresh

func (b *Bridge) Refresh()

Refresh runs one sampling pass whatever the generation and returns once its tree is published and its events sent: for embedders that drive sampling themselves (Options.Poll < 0) and for tests. It queues through the scene's Invoke like the poller does, so it must not run on the loop goroutine.

func (*Bridge) Stop

func (b *Bridge) Stop()

Stop tears the bridge down: the poller and the emitter stop, and the bus connection closes. An emitter stuck in a write to a bus that stopped reading keeps its goroutine until the write fails. Safe to call twice; Serve's error path never returns a bridge.

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
	// contains filtered or unexported fields
}

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())
	A11yGeneration() uint64
	// 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL