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 serde::{Deserialize, Serialize};
7use zvariant::{OwnedValue, Type, Value};
8
9#[derive(
10 Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize, OwnedValue, Type, Value,
11)]
12pub struct Rect {
13 pub x: i32,
14 pub y: i32,
15 pub width: i32,
16 pub height: i32,
17}
18
19impl Rect {
20 pub const INVALID: Rect = Rect {
21 x: -1,
22 y: -1,
23 width: -1,
24 height: -1,
25 };
26}
27
28impl From<accesskit::Rect> for Rect {
29 fn from(value: accesskit::Rect) -> Rect {
30 Rect {
31 x: value.x0 as i32,
32 y: value.y0 as i32,
33 width: value.width() as i32,
34 height: value.height() as i32,
35 }
36 }
37}
38