Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions libs/cua-driver/rust/crates/platform-linux/src/atspi/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,15 +389,35 @@ pub fn insert_text(pid: u32, text: &str) -> Result<bool> {
None => return Ok(false),
};
dlog!(
"insert target: role={:?} in_web_doc={} focused={}",
target.role, target.in_web_doc, target.focused
"insert target: role={:?} in_web_doc={} focused={} has_component={}",
target.role, target.in_web_doc, target.focused, target.has_component
);

let proxies = target
.acc
.proxies()
.await
.map_err(|e| anyhow!("interface proxies unavailable: {e}"))?;

// Try to grab focus on the widget via AT-SPI Component.GrabFocus.
// This should give the widget internal keyboard focus without activating
// the window, allowing GTK4 (and similar toolkits) to expose EditableText
// on an unfocused window's focused widget.
if target.has_component {
if let Ok(comp) = proxies.component().await {
match call(comp.grab_focus()).await {
Some(Ok(true)) => dlog!("GrabFocus succeeded on {:?}", target.role),
Some(Ok(false)) => dlog!("GrabFocus returned false on {:?}", target.role),
Some(Err(e)) => dlog!("GrabFocus failed on {:?}: {}", target.role, e),
None => dlog!("GrabFocus timed out on {:?}", target.role),
}
} else {
dlog!("Component interface unavailable despite has_component=true");
}
} else {
dlog!("Target has no Component interface, skipping GrabFocus");
}

let et = proxies
.editable_text()
.await
Expand Down
Loading