Skip to content

Commit 0be7f4f

Browse files
committed
fix
1 parent ecb3b9c commit 0be7f4f

1 file changed

Lines changed: 21 additions & 28 deletions

File tree

src/platform/linux.rs

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -563,14 +563,8 @@ impl LinuxUiBackend {
563563
let cb = child.name.clone();
564564
let cp = child.path.to_string();
565565

566-
if let Ok(app_proxy) =
567-
Self::make_application_proxy(&self.connection, &cb, &cp).await
568-
{
569-
if let Ok(p) = app_proxy.id().await {
570-
if p as u32 == pid {
571-
return Ok((cb, cp));
572-
}
573-
}
566+
if self.get_dbus_pid(&cb).await == Some(pid) {
567+
return Ok((cb, cp));
574568
}
575569
}
576570
}
@@ -602,6 +596,23 @@ impl LinuxUiBackend {
602596
fn block_on<F: std::future::Future<Output = T>, T>(&self, f: F) -> T {
603597
self.rt.block_on(f)
604598
}
599+
600+
/// Get the real Unix PID for a D-Bus connection by asking the bus daemon.
601+
/// Unlike org.a11y.atspi.Application.Id (which apps can set to anything),
602+
/// this returns the actual OS process ID tracked by D-Bus itself.
603+
async fn get_dbus_pid(&self, bus_name: &str) -> Option<u32> {
604+
self.connection
605+
.call_method(
606+
Some("org.freedesktop.DBus"),
607+
"/org/freedesktop/DBus",
608+
Some("org.freedesktop.DBus"),
609+
"GetConnectionUnixProcessID",
610+
&(bus_name,),
611+
)
612+
.await
613+
.ok()
614+
.and_then(|msg| msg.body::<u32>().ok())
615+
}
605616
}
606617

607618
// ── UiBackend implementation ──────────────────────────────────────────────────
@@ -642,26 +653,8 @@ impl UiBackend for LinuxUiBackend {
642653
continue;
643654
}
644655

645-
// Get PID via Application interface
646-
let pid = async {
647-
let msg = self.connection
648-
.call_method(
649-
Some(cb.as_str()),
650-
cp_str,
651-
Some("org.freedesktop.DBus.Properties"),
652-
"Get",
653-
&("org.a11y.atspi.Application", "Id"),
654-
)
655-
.await
656-
.ok()?;
657-
let v = msg.body::<zbus::zvariant::Value>().ok()?;
658-
match v {
659-
zbus::zvariant::Value::I32(n) => Some(n as u32),
660-
zbus::zvariant::Value::U32(n) => Some(n),
661-
zbus::zvariant::Value::I64(n) => Some(n as u32),
662-
_ => None,
663-
}
664-
}.await.unwrap_or(0);
656+
// Get real OS PID via D-Bus connection tracking
657+
let pid = self.get_dbus_pid(cb.as_str()).await.unwrap_or(0);
665658

666659
// Get children of this app (its windows)
667660
let app_children: Vec<(String, zbus::zvariant::OwnedObjectPath)> = match self

0 commit comments

Comments
 (0)