Skip to content

Commit 7f40fbc

Browse files
authored
fix: Smarter calculation of AT-SPI extents for the window (#435)
1 parent 7086bc0 commit 7f40fbc

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

platforms/atspi-common/src/node.rs

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -434,17 +434,28 @@ impl<'a> NodeWrapper<'a> {
434434
}
435435

436436
fn extents(&self, window_bounds: &WindowBounds, coord_type: CoordType) -> Option<Rect> {
437-
self.is_root()
438-
.then(|| window_bounds.inner.with_origin(Point::ZERO))
439-
.or_else(|| self.0.bounding_box())
440-
.map(|bounds| {
441-
let new_origin = window_bounds.accesskit_point_to_atspi_point(
442-
bounds.origin(),
443-
self.0.filtered_parent(&filter),
444-
coord_type,
445-
);
446-
bounds.with_origin(new_origin)
447-
})
437+
let mut bounds = self.0.bounding_box();
438+
if self.is_root() {
439+
let window_bounds = window_bounds.inner.with_origin(Point::ZERO);
440+
if !window_bounds.is_empty() {
441+
if let Some(bounds) = &mut bounds {
442+
bounds.x0 = bounds.x0.min(window_bounds.x1);
443+
bounds.y0 = bounds.y0.min(window_bounds.y1);
444+
bounds.x1 = bounds.x1.min(window_bounds.x1);
445+
bounds.y1 = bounds.y1.min(window_bounds.y1);
446+
} else {
447+
bounds = Some(window_bounds);
448+
}
449+
}
450+
}
451+
bounds.map(|bounds| {
452+
let new_origin = window_bounds.accesskit_point_to_atspi_point(
453+
bounds.origin(),
454+
self.0.filtered_parent(&filter),
455+
coord_type,
456+
);
457+
bounds.with_origin(new_origin)
458+
})
448459
}
449460

450461
fn current_value(&self) -> Option<f64> {

0 commit comments

Comments
 (0)