Skip to main content

ShellSurface

Struct ShellSurface 

Source
pub struct ShellSurface {
    pub kind: ShellSurfaceKind,
    pub name: String,
    pub pid: Option<u32>,
    pub data: ElementData,
    /* private fields */
}
Expand description

A shell surface: one OS-owned top-level accessibility root, tagged with what it is. The entry point for shell queries, as App is for application queries.

ShellSurface is not an Element — it represents the surface as a whole and provides a locator to search its accessibility tree.

Fields§

§kind: ShellSurfaceKind

What this surface is.

§name: String

Human-readable name: the owning app for per-app surfaces (“Safari” menu bar, “Arq” status items), the platform’s own name otherwise (“Taskbar”, “Dock”). Falls back to the kind’s snake_case spelling when the platform vends no name for the root.

§pid: Option<u32>

Owning process where the platform reports one honestly. On macOS this is always the true owner. On Windows it is the process that hosts the surface: explorer.exe / ShellHost.exe for shell chrome, or the owning application for a native popup menu. UIA carries no per-icon owner, so taskbar and tray-icon elements still report their shell host, never a guessed application. On Linux it is the panel process.

§data: ElementData

The surface’s root element data.

Implementations§

Source§

impl ShellSurface

Source

pub fn list_with(provider: Arc<dyn Provider>) -> Result<Vec<Self>>

List the OS shell surfaces currently on screen, using an explicit provider.

Prefer ShellSurface::list from the xa11y crate which uses the global singleton provider. Use this variant when you need to supply a specific provider (e.g. a mock in unit tests).

The listing is live: Flyout surfaces appear only while they are open, and enumerating never opens, closes, or presses anything. A platform with no surface of a given kind simply returns none — that is honest scope, not a failure.

Source

pub fn by_kind_with( provider: Arc<dyn Provider>, kind: ShellSurfaceKind, timeout: Duration, ) -> Result<Self>

Wait for exactly one surface of kind, using an explicit provider.

Prefer ShellSurface::by_kind from the xa11y crate which uses the global singleton provider.

Polls list_with until a single surface of kind exists or timeout elapses; Duration::ZERO performs exactly one attempt (no waiting). An enumeration failure short-circuits — “the shell cannot be listed” is not “the surface isn’t up yet”. The wait is what makes the flyout workflow a one-liner: press the tray chevron, then wait for the overflow window to materialise.

§Errors

Returns Error::SelectorNotMatched both when no surface of kind is present and when several are — a second Panel frame, status items from several processes, a leftover Flyout. Ambiguity is refused rather than first-matched: for a surface whose consumers are mostly agents, silently acting on one of several indistinguishable candidates is the failure mode worth ruling out. The refusal is terminal, not a retry — the diagnosis lists the candidates so the caller can disambiguate with list_with and a pid.

Source

pub fn locator(&self, selector: &str) -> Locator

Create a Locator to search this surface’s accessibility tree.

Source

pub fn children(&self) -> Result<Vec<Element>>

Get direct children of the surface root.

Source

pub fn tree(&self, max_depth: Option<usize>) -> Result<TreeNode>

Capture the surface’s accessibility tree as a recursive snapshot, rooted at the surface element.

Equivalent to self.as_element().tree(max_depth). See Element::tree for max_depth semantics.

Source

pub fn dump(&self, max_depth: Option<usize>) -> Result<String>

Render the surface’s accessibility tree as an indented string, rooted at the surface element.

The primary inspection helper for figuring out the role/name of every element in a shell surface before writing selectors. Equivalent to self.as_element().dump(max_depth). See Element::dump for the output format.

Source

pub fn as_element(&self) -> Element

Get an Element handle for the surface root.

Useful when you want to use Element-level methods (e.g. tree, dump, children) without going through a locator.

Trait Implementations§

Source§

impl Debug for ShellSurface

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ShellSurface

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.