Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SDL_GetWindowBordersSize() #733

Merged
merged 6 commits into from
Dec 12, 2017
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/sdl2/video.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,26 @@ impl Window {
unsafe { sys::SDL_GetWindowPosition(self.context.raw, &mut x, &mut y) };
(x as i32, y as i32)
}

/// Use this function to get the size of a window's borders (decorations) around the client area.
///
/// # Remarks
/// This function is only supported on X11, otherwise (0, 0, 0, 0) is returned.
///
/// #Notes
/// If this function fails, (0, 0, 0, 0) will be returned
Copy link
Member

@Cobrand Cobrand Dec 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot to change this part of the documentation.

pub fn border_size(&self) -> Result<(u16, u16, u16, u16), String> {
let mut top: c_int = 0;
let mut left: c_int = 0;
let mut bottom: c_int = 0;
let mut right: c_int = 0;
let result = unsafe { sys::SDL_GetWindowBordersSize(self.context.raw, &mut top, &mut left, &mut bottom, &mut right) };
if result < 0 {
Err(get_error())
} else {
Ok((top as u16, left as u16, bottom as u16, right as u16))
}
}

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