Documentation
¶
Overview ¶
Package atspi is the accessibility bridge for Linux desktops (SPEC §8.10): it mirrors the framework's semantics tree as AT-SPI2 objects on the accessibility bus, so that screen readers such as Orca can read the app and act on it.
The bridge is enabled only while a screen reader is on (the property org.a11y.Status.ScreenReaderEnabled of the session bus), so the semantics tree costs nothing otherwise. The model of the tree (model.go) and the mapping of roles and states (roles.go) do not touch the bus; the bridge (bridge.go) puts them on it.
Flutter: no counterpart (Flutter's accessibility bridge for Linux is the GTK embedder's)
Index ¶
- type Bridge
- type Change
- type ChangeKind
- type Extents
- type Host
- type Model
- func (m *Model) Apply(view ui.ViewID, update *ui.SemanticsUpdate) []Change
- func (m *Model) Children(n *Node) []NodeRef
- func (m *Model) Extents(n *Node) Extents
- func (m *Model) HitTest(n *Node, x, y int32) *Node
- func (m *Model) Name(n *Node) string
- func (m *Model) Node(ref NodeRef) *Node
- func (m *Model) RemoveView(view ui.ViewID) []Change
- func (m *Model) Role(n *Node) Role
- func (m *Model) SetWindow(view ui.ViewID, title string, active bool) []Change
- func (m *Model) States(n *Node) StateSet
- func (m *Model) Views() []ui.ViewID
- type Node
- type NodeRef
- type Options
- type Role
- type State
- type StateSet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bridge ¶
type Bridge struct {
// contains filtered or unexported fields
}
Bridge mirrors the semantics trees of the views as AT-SPI2 objects while a screen reader is on. Its methods are for the UI thread, except Close.
Flutter: no counterpart
func (*Bridge) Close ¶
func (b *Bridge) Close()
Close stops the bridge and takes the objects off the bus.
func (*Bridge) RemoveView ¶
RemoveView forgets the tree of a view that closed.
func (*Bridge) SetWindow ¶
SetWindow tells the title of the window of the view, which names its frame, and whether it has the focus.
func (*Bridge) Start ¶
Start follows the screen reader flag of the session bus in the background, until ctx ends or Close is called. A desktop without the accessibility service is not an error: the bridge stays off (and says so in the debug log).
func (*Bridge) UpdateSemantics ¶
func (b *Bridge) UpdateSemantics(view ui.ViewID, update *ui.SemanticsUpdate)
UpdateSemantics takes the changes of the semantics tree of a view.
type Change ¶
type Change struct {
Kind ChangeKind
Ref NodeRef
Parent NodeRef
Child NodeRef
Index int
State State
On bool
Property string
Value string
Length int
Number float64
}
Change is one change that Apply or the window setters made.
type ChangeKind ¶
type ChangeKind int
ChangeKind says what a Change is.
const ( // ChangeNodeAdded: a node appeared and has to be exported. ChangeNodeAdded ChangeKind = iota + 1 // ChangeNodeRemoved: a node went away and has to be unexported. ChangeNodeRemoved // ChangeChildAdded: Child was added to the children of Parent, at Index. A Parent // with View -1 is the application. ChangeChildAdded // ChangeChildRemoved: Child was removed from the children of Parent, which had it at Index. ChangeChildRemoved // ChangeState: the state State of Ref is now On. ChangeState // ChangeProperty: the property Property ("accessible-name" or "accessible-description") // of Ref changed to Value. ChangeProperty // ChangeWindow: the window of View became active (On) or inactive. ChangeWindow // ChangeNodeUpdated: the node that exists was updated; its interfaces may have changed. ChangeNodeUpdated // ChangeText: Value was inserted (Property "insert") into the text of Ref at the // character Index, or deleted (Property "delete") from there; Length is the number // of characters. ChangeText // ChangeCaret: the caret of the text of Ref is now at the character Index. ChangeCaret // ChangeTextSelection: the selected part of the text of Ref changed. ChangeTextSelection // ChangeValue: the numeric value of Ref is now Number. ChangeValue // ChangeVisibleData: the position or the size of Ref changed. ChangeVisibleData // ChangeSelection: the selected children of Ref changed. ChangeSelection )
The kinds of change.
type Extents ¶
type Extents struct{ X, Y, Width, Height int32 }
Extents is a rectangle in pixels of the window.
type Host ¶
type Host interface {
// ScreenReaderChanged tells that a screen reader started or stopped: the framework
// then produces the semantics tree, or stops.
ScreenReaderChanged(enabled bool)
// PerformAction asks the framework to perform an action of a node, the request of
// the assistive technology.
PerformAction(event ui.SemanticsActionEvent)
}
Host is what the bridge needs of the app. The bridge calls it on the UI thread (through Options.Post).
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is the mirror of the semantics trees of the views of the app. It does not touch the bus: Apply says what changed, and the bridge turns that into events. A Model is not safe for concurrent use; the bridge locks it.
func (*Model) Apply ¶
Apply takes an update of the tree of a view and returns what changed. Nodes that the update leaves unreachable from the root are removed, as the engine does.
func (*Model) Children ¶
Children are the refs of the children of the node, in traversal order; those that the tree does not have are left out.
func (*Model) Extents ¶
Extents is the rectangle of the node in the pixels of its window: the rectangle of the node in its own coordinates, moved by the transforms of the node and of its ancestors up to the root (whose transform has the device pixel ratio).
func (*Model) HitTest ¶
HitTest is the deepest node under the point (in the pixels of the window) that is under the node, or nil. A hidden node and its children are not hit; the last children are tried first, as they are on top.
func (*Model) Name ¶
Name is the name of the node: its label; the frame of a window has the title of the window when it has no label.
func (*Model) RemoveView ¶
RemoveView forgets the tree of a view that closed and says what that changed.
type Node ¶
type Node struct {
ui.SemanticsNodeUpdate
// View is the view of the node.
View ui.ViewID
// Parent is the ID of the parent, or -1 for the root.
Parent int
}
Node is a node of the mirrored tree: what the framework last said about it.
type Options ¶
type Options struct {
// AppName is the name of the application, as the screen reader says it.
AppName string
// Version is the version of the toolkit; it defaults to "1.0".
Version string
// Post runs a function on the UI thread, from any goroutine. It is required.
Post func(func())
// OpenSession connects to the session bus; nil is dbus.Connect.
OpenSession func(ctx context.Context) (dbus.Bus, error)
// OpenA11y connects to the accessibility bus at the address that the session bus
// gives; nil is dbus.ConnectAddress.
OpenA11y func(ctx context.Context, address string) (dbus.Bus, error)
// WindowOrigin is where the window is on the screen, for the coordinates of the
// screen. Wayland does not tell, and the default is the origin.
WindowOrigin func(view ui.ViewID) (x, y int)
// Getenv reads the environment (for the locale); nil is os.Getenv.
Getenv func(string) string
// Logger gets the debug messages; nil is slog.Default().
Logger *slog.Logger
}
Options are the parameters of New.
type Role ¶
type Role uint32
Role is an AT-SPI2 role (AtspiRole of atspi-constants.h). Only the roles that the mapping uses are named.
const ( RoleInvalid Role = 0 RoleAcceleratorLabel Role = 1 RoleAlert Role = 2 RoleAnimation Role = 3 RoleCheckBox Role = 7 RoleCheckMenuItem Role = 8 RoleColumnHeader Role = 10 RoleComboBox Role = 11 RoleDialog Role = 16 RoleFiller Role = 20 RoleFrame Role = 23 RoleImage Role = 27 RoleLabel Role = 29 RoleList Role = 31 RoleListItem Role = 32 RoleMenu Role = 33 RoleMenuBar Role = 34 RoleMenuItem Role = 35 RolePageTab Role = 37 RolePageTabList Role = 38 RolePanel Role = 39 RolePasswordText Role = 40 RoleProgressBar Role = 42 RolePushButton Role = 43 RoleRadioButton Role = 44 RoleRadioMenuItem Role = 45 RoleScrollBar Role = 48 RoleScrollPane Role = 49 RoleSeparator Role = 50 RoleSlider Role = 51 RoleSpinButton Role = 52 RoleStatusBar Role = 54 RoleTable Role = 55 RoleTableCell Role = 56 RoleTableColumnHeader Role = 57 RoleText Role = 61 RoleToggleButton Role = 62 RoleToolTip Role = 64 RoleTree Role = 65 RoleWindow Role = 69 RoleHeader Role = 71 RoleParagraph Role = 73 RoleApplication Role = 75 RoleEntry Role = 79 RoleDocumentFrame Role = 82 RoleHeading Role = 83 RoleSection Role = 85 RoleForm Role = 87 RoleLink Role = 88 RoleTableRow Role = 90 RoleListBox Role = 98 RoleGrouping Role = 99 RoleNotification Role = 101 RoleLandmark Role = 110 RoleStatic Role = 116 )
The roles that the mapping gives to nodes.
type State ¶
type State uint32
State is an AT-SPI2 state (AtspiStateType): the number of a bit in the 64 bits of the two words that GetState returns.
const ( StateActive State = 1 StateChecked State = 4 StateCollapsed State = 5 StateEditable State = 7 StateEnabled State = 8 StateExpandable State = 9 StateExpanded State = 10 StateFocusable State = 11 StateFocused State = 12 StateHasTooltip State = 13 StateModal State = 16 StateMultiLine State = 17 StateSelectable State = 22 StateSelected State = 23 StateSensitive State = 24 StateShowing State = 25 StateSingleLine State = 26 StateVisible State = 30 StateIndeterminate State = 32 StateRequired State = 33 StateInvalidEntry State = 36 StateSelectableText State = 38 StateCheckable State = 41 StateReadOnly State = 43 )
The states that the mapping sets.