Skip to content

Commit 8a84abf

Browse files
authored
fix: Return a null object for AT-SPI application's parent (#454)
1 parent 119aa1d commit 8a84abf

File tree

5 files changed

+29
-41
lines changed

5 files changed

+29
-41
lines changed

platforms/unix/src/atspi/bus.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,15 @@ impl Bus {
7878
.at(path.clone(), ApplicationInterface(node.clone()))
7979
.await?
8080
{
81-
let desktop = self
82-
.socket_proxy
81+
self.socket_proxy
8382
.embed(&(self.unique_name().as_str(), ObjectId::Root.path().into()))
8483
.await?;
8584

8685
self.conn
8786
.object_server()
8887
.at(
8988
path,
90-
RootAccessibleInterface::new(
91-
self.unique_name().to_owned(),
92-
desktop.into(),
93-
node,
94-
),
89+
RootAccessibleInterface::new(self.unique_name().to_owned(), node),
9590
)
9691
.await?;
9792
}
@@ -230,7 +225,7 @@ impl Bus {
230225
kind: "",
231226
detail1: 0,
232227
detail2: 0,
233-
any_data: child.to_address(self.unique_name().clone()).into(),
228+
any_data: child.to_address(self.unique_name().inner()).into(),
234229
properties,
235230
},
236231
)
@@ -294,7 +289,7 @@ impl Bus {
294289
kind: "add",
295290
detail1: index as i32,
296291
detail2: 0,
297-
any_data: child.to_address(self.unique_name().clone()).into(),
292+
any_data: child.to_address(self.unique_name().inner()).into(),
298293
properties,
299294
},
300295
)
@@ -313,7 +308,7 @@ impl Bus {
313308
kind: "remove",
314309
detail1: -1,
315310
detail2: 0,
316-
any_data: child.to_address(self.unique_name().clone()).into(),
311+
any_data: child.to_address(self.unique_name().inner()).into(),
317312
properties,
318313
},
319314
)
@@ -345,7 +340,7 @@ impl Bus {
345340
},
346341
NodeIdOrRoot::Root => ObjectId::Root,
347342
};
348-
parent.to_address(self.unique_name().clone()).into()
343+
parent.to_address(self.unique_name().inner()).into()
349344
}
350345
Property::Role(value) => Value::U32(value as u32),
351346
Property::Value(value) => Value::F64(value),

platforms/unix/src/atspi/interfaces/accessible.rs

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl NodeAccessibleInterface {
4949
},
5050
NodeIdOrRoot::Root => ObjectId::Root,
5151
}
52-
.to_address(self.bus_name.clone())
52+
.to_address(self.bus_name.inner())
5353
})
5454
}
5555

@@ -90,7 +90,7 @@ impl NodeAccessibleInterface {
9090
adapter: self.node.adapter_id(),
9191
node: child,
9292
}
93-
.to_address(self.bus_name.clone())
93+
.to_address(self.bus_name.inner())
9494
})
9595
.map_err(self.map_error())
9696
}
@@ -116,7 +116,7 @@ impl NodeAccessibleInterface {
116116
}
117117

118118
fn get_application(&self) -> (OwnedObjectAddress,) {
119-
(ObjectId::Root.to_address(self.bus_name.clone()),)
119+
(ObjectId::Root.to_address(self.bus_name.inner()),)
120120
}
121121

122122
fn get_interfaces(&self) -> fdo::Result<InterfaceSet> {
@@ -126,21 +126,12 @@ impl NodeAccessibleInterface {
126126

127127
pub(crate) struct RootAccessibleInterface {
128128
bus_name: OwnedUniqueName,
129-
desktop_address: OwnedObjectAddress,
130129
root: PlatformRoot,
131130
}
132131

133132
impl RootAccessibleInterface {
134-
pub fn new(
135-
bus_name: OwnedUniqueName,
136-
desktop_address: OwnedObjectAddress,
137-
root: PlatformRoot,
138-
) -> Self {
139-
Self {
140-
bus_name,
141-
desktop_address,
142-
root,
143-
}
133+
pub fn new(bus_name: OwnedUniqueName, root: PlatformRoot) -> Self {
134+
Self { bus_name, root }
144135
}
145136
}
146137

@@ -158,7 +149,7 @@ impl RootAccessibleInterface {
158149

159150
#[dbus_interface(property)]
160151
fn parent(&self) -> OwnedObjectAddress {
161-
self.desktop_address.clone()
152+
OwnedObjectAddress::null()
162153
}
163154

164155
#[dbus_interface(property)]
@@ -191,7 +182,7 @@ impl RootAccessibleInterface {
191182
fn get_children(&self) -> fdo::Result<Vec<OwnedObjectAddress>> {
192183
self.root
193184
.map_child_ids(|(adapter, node)| {
194-
ObjectId::Node { adapter, node }.to_address(self.bus_name.clone())
185+
ObjectId::Node { adapter, node }.to_address(self.bus_name.inner())
195186
})
196187
.map_err(map_root_error)
197188
}
@@ -209,7 +200,7 @@ impl RootAccessibleInterface {
209200
}
210201

211202
fn get_application(&self) -> (OwnedObjectAddress,) {
212-
(ObjectId::Root.to_address(self.bus_name.clone()),)
203+
(ObjectId::Root.to_address(self.bus_name.inner()),)
213204
}
214205

215206
fn get_interfaces(&self) -> InterfaceSet {

platforms/unix/src/atspi/interfaces/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,19 @@ mod text;
1111
mod value;
1212

1313
use crate::atspi::{ObjectId, OwnedObjectAddress};
14-
use zbus::{fdo, names::OwnedUniqueName};
14+
use zbus::{fdo, names::UniqueName};
1515

1616
fn map_root_error(error: accesskit_atspi_common::Error) -> fdo::Error {
1717
crate::util::map_error(ObjectId::Root, error)
1818
}
1919

2020
fn optional_object_address(
21-
bus_name: &OwnedUniqueName,
21+
bus_name: &UniqueName,
2222
object_id: Option<ObjectId>,
2323
) -> (OwnedObjectAddress,) {
24-
let bus_name = bus_name.clone();
2524
match object_id {
2625
Some(id) => (id.to_address(bus_name),),
27-
None => (OwnedObjectAddress::null(bus_name),),
26+
None => (OwnedObjectAddress::null(),),
2827
}
2928
}
3029

platforms/unix/src/atspi/object_address.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,29 @@
66
use atspi::Accessible;
77
use serde::{Deserialize, Serialize};
88
use zbus::{
9-
names::{OwnedUniqueName, UniqueName},
9+
names::UniqueName,
1010
zvariant::{ObjectPath, OwnedObjectPath, OwnedValue, Type, Value},
1111
};
1212

1313
const NULL_PATH: &str = "/org/a11y/atspi/null";
1414

1515
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, OwnedValue, Type, Value)]
1616
pub(crate) struct OwnedObjectAddress {
17-
bus_name: OwnedUniqueName,
17+
bus_name: String,
1818
path: OwnedObjectPath,
1919
}
2020

2121
impl OwnedObjectAddress {
22-
pub(crate) fn new(bus_name: OwnedUniqueName, path: OwnedObjectPath) -> Self {
23-
Self { bus_name, path }
22+
pub(crate) fn new(bus_name: &UniqueName, path: OwnedObjectPath) -> Self {
23+
Self {
24+
bus_name: bus_name.to_string(),
25+
path,
26+
}
2427
}
2528

26-
pub(crate) fn null(bus_name: OwnedUniqueName) -> Self {
29+
pub(crate) fn null() -> Self {
2730
Self {
28-
bus_name,
31+
bus_name: String::new(),
2932
path: ObjectPath::from_str_unchecked(NULL_PATH).into(),
3033
}
3134
}
@@ -34,7 +37,7 @@ impl OwnedObjectAddress {
3437
impl From<Accessible> for OwnedObjectAddress {
3538
fn from(object: Accessible) -> Self {
3639
Self {
37-
bus_name: OwnedUniqueName::from(UniqueName::from_string_unchecked(object.name)),
40+
bus_name: object.name,
3841
path: object.path,
3942
}
4043
}

platforms/unix/src/atspi/object_id.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use accesskit::NodeId;
88
use accesskit_atspi_common::PlatformNode;
99
use serde::{Serialize, Serializer};
1010
use zbus::{
11-
names::OwnedUniqueName,
11+
names::UniqueName,
1212
zvariant::{ObjectPath, OwnedObjectPath, Signature, Structure, StructureBuilder, Type},
1313
};
1414

@@ -22,7 +22,7 @@ pub(crate) enum ObjectId {
2222
}
2323

2424
impl ObjectId {
25-
pub(crate) fn to_address(&self, bus_name: OwnedUniqueName) -> OwnedObjectAddress {
25+
pub(crate) fn to_address(&self, bus_name: &UniqueName) -> OwnedObjectAddress {
2626
OwnedObjectAddress::new(bus_name, self.path())
2727
}
2828

0 commit comments

Comments
 (0)