1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
use crate::{bind, Result};
use super::Window;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct BorderWidths {
pub top: u32,
pub right: u32,
pub bottom: u32,
pub left: u32,
}
pub trait BorderExt {
fn border_widths(&self) -> Result<BorderWidths>;
}
impl BorderExt for Window<'_> {
fn border_widths(&self) -> Result<BorderWidths> {
let (mut top, mut left, mut bottom, mut right) = (0, 0, 0, 0);
let ret = unsafe {
bind::SDL_GetWindowBordersSize(
self.as_ptr(),
&mut top,
&mut left,
&mut bottom,
&mut right,
)
};
if ret != 0 {
return Err(crate::SdlError::UnsupportedFeature);
}
Ok(BorderWidths {
top: top as u32,
right: right as u32,
bottom: bottom as u32,
left: left as u32,
})
}
}