From d753f5277d54a6533c4060524b913534861026c6 Mon Sep 17 00:00:00 2001 From: Flaise Date: Thu, 22 Apr 2021 16:46:19 -0400 Subject: [PATCH 1/2] Added binding for SDL_GetDisplayUsableBounds. --- src/sdl2/video.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/sdl2/video.rs b/src/sdl2/video.rs index 2235032d71b..34e79f06548 100644 --- a/src/sdl2/video.rs +++ b/src/sdl2/video.rs @@ -676,6 +676,20 @@ impl VideoSubsystem { } } + #[doc(alias = "SDL_GetDisplayUsableBounds")] + pub fn display_usable_bounds(&self, display_index: i32) -> Result { + let mut out = mem::MaybeUninit::uninit(); + let result = unsafe { + sys::SDL_GetDisplayUsableBounds(display_index as c_int, out.as_mut_ptr()) + }; + if result == 0 { + let out = unsafe { out.assume_init() }; + Ok(Rect::from_ll(out)) + } else { + Err(get_error()) + } + } + #[doc(alias = "SDL_GetNumDisplayModes")] pub fn num_display_modes(&self, display_index: i32) -> Result { let result = unsafe { sys::SDL_GetNumDisplayModes(display_index as c_int) }; From aab62966c5125e795746e921f779df6b4ff198bc Mon Sep 17 00:00:00 2001 From: Flaise Date: Fri, 23 Apr 2021 14:42:03 -0400 Subject: [PATCH 2/2] Fixed formatting. --- src/sdl2/video.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/sdl2/video.rs b/src/sdl2/video.rs index 34e79f06548..c18eaf6f983 100644 --- a/src/sdl2/video.rs +++ b/src/sdl2/video.rs @@ -679,9 +679,8 @@ impl VideoSubsystem { #[doc(alias = "SDL_GetDisplayUsableBounds")] pub fn display_usable_bounds(&self, display_index: i32) -> Result { let mut out = mem::MaybeUninit::uninit(); - let result = unsafe { - sys::SDL_GetDisplayUsableBounds(display_index as c_int, out.as_mut_ptr()) - }; + let result = + unsafe { sys::SDL_GetDisplayUsableBounds(display_index as c_int, out.as_mut_ptr()) }; if result == 0 { let out = unsafe { out.assume_init() }; Ok(Rect::from_ll(out))