Skip to content

AT-SPI injector: Replace Collection.GetMatches with event-driven or StateSet approach #299

@Coldaine

Description

@Coldaine

Problem

The AT-SPI text injector currently uses Collection.GetMatches to find focused editable elements, but this method is:

  1. Not universally available - The Collection interface isn't implemented by all AT-SPI registries
  2. Overkill for the use case - Collection is for complex multi-criteria queries, not simple focus detection
  3. Fails on KDE Plasma - Even with at-spi2-core 2.58.1, GetMatches returns UnknownMethod

Error

Collection.get_matches failed: org.freedesktop.DBus.Error.UnknownMethod: 
Method "GetMatches" with signature "(aiia{ss}iaiiasib)uib" on interface 
"org.a11y.atspi.Collection" doesn't exist

Research Findings

Alternative Approaches (simpler and more portable)

  1. Event-driven (most efficient):

    listener.register("object:state-changed:focused");
    // Receive ObjectRef of newly focused element directly
  2. StateSet querying (most direct):

    let state_set = accessible_proxy.get_state().await?;
    if state_set.contains(State::Focused) {
        // This element is focused
    }
  3. Tree walking with state checks:

    async fn find_focused_element(accessible: &AccessibleProxy) -> Option<AccessibleProxy> {
        let state_set = accessible.get_state().await.ok()?;
        if state_set.contains(State::Focused) {
            return Some(accessible.clone());
        }
        // Recursively check children...
    }

KDE Plasma Requirements

Environment variables needed:

export QT_ACCESSIBILITY=1
export QT_LINUX_ACCESSIBILITY_ALWAYS_ON=1

Proposed Solution

  1. Replace Collection.GetMatches with event-driven focus tracking
  2. Use StateSet queries as fallback
  3. Add runtime check for AT-SPI availability before attempting text injection
  4. Keep clipboard-based injection as fallback when AT-SPI EditableText unavailable

Affected Code

  • crates/coldvox-text-injection/src/injectors/atspi.rs (lines 87-120, 297-330)

Environment

  • Nobara Linux 42 (Fedora-based)
  • KDE Plasma 6 on Wayland
  • at-spi2-core 2.58.1
  • Rust atspi crate 0.29

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions