1// Copyright 2022 The AccessKit Authors. All rights reserved.
2// Licensed under the Apache License, Version 2.0 (found in
3// the LICENSE-APACHE file) or the MIT license (found in
4// the LICENSE-MIT file), at your option.
5
6use accesskit::{Point, Rect};
7use atspi_common::CoordType;
8
9#[derive(Clone, Copy, Default)]
10pub struct WindowBounds {
11 pub outer: Rect,
12 pub inner: Rect,
13}
14
15impl WindowBounds {
16 pub fn new(outer: Rect, inner: Rect) -> Self {
17 Self { outer, inner }
18 }
19
20 pub(crate) fn top_left(&self, coord_type: CoordType, is_root: bool) -> Point {
21 match coord_type {
22 CoordType::Screen if is_root => self.outer.origin(),
23 CoordType::Screen => self.inner.origin(),
24 CoordType::Window if is_root => Point::ZERO,
25 CoordType::Window => {
26 let outer_position: Point = self.outer.origin();
27 let inner_position: Point = self.inner.origin();
28 Point::new(
29 x:inner_position.x - outer_position.x,
30 y:inner_position.y - outer_position.y,
31 )
32 }
33 _ => unimplemented!(),
34 }
35 }
36}
37