Skip to content

Commit b83be89

Browse files
authored
Merge pull request #733 from Cyres/master
Add SDL_GetWindowBordersSize()
2 parents 871700e + 9b419fe commit b83be89

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/sdl2/video.rs

+17
Original file line numberDiff line numberDiff line change
@@ -1159,6 +1159,23 @@ impl Window {
11591159
unsafe { sys::SDL_GetWindowPosition(self.context.raw, &mut x, &mut y) };
11601160
(x as i32, y as i32)
11611161
}
1162+
1163+
/// Use this function to get the size of a window's borders (decorations) around the client area.
1164+
///
1165+
/// # Remarks
1166+
/// This function is only supported on X11, otherwise an error is returned.
1167+
pub fn border_size(&self) -> Result<(u16, u16, u16, u16), String> {
1168+
let mut top: c_int = 0;
1169+
let mut left: c_int = 0;
1170+
let mut bottom: c_int = 0;
1171+
let mut right: c_int = 0;
1172+
let result = unsafe { sys::SDL_GetWindowBordersSize(self.context.raw, &mut top, &mut left, &mut bottom, &mut right) };
1173+
if result < 0 {
1174+
Err(get_error())
1175+
} else {
1176+
Ok((top as u16, left as u16, bottom as u16, right as u16))
1177+
}
1178+
}
11621179

11631180
pub fn set_size(&mut self, width: u32, height: u32)
11641181
-> Result<(), IntegerOrSdlError> {

0 commit comments

Comments
 (0)