diff --git a/changelog.md b/changelog.md index 8b41440f11..235b8eacc0 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,8 @@ when upgrading from a version of rust-sdl2 to another. ### v0.35.2 +[PR #1204](https://github.com/Rust-SDL2/rust-sdl2/pull/1204) binding for `SDL_FlashWindow` added + [PR #1173](https://github.com/Rust-SDL2/rust-sdl2/pull/1173) Fix segfault when using timer callbacks [PR #1183](https://github.com/Rust-SDL2/rust-sdl2/pull/1183) WinRT support for raw-window-handle diff --git a/sdl2-sys/sdl_bindings.rs b/sdl2-sys/sdl_bindings.rs index b98fc8ee05..a25b96bb98 100644 --- a/sdl2-sys/sdl_bindings.rs +++ b/sdl2-sys/sdl_bindings.rs @@ -7588,6 +7588,17 @@ pub enum SDL_DisplayOrientation { #[doc = "< The display is in portrait mode, upside down"] SDL_ORIENTATION_PORTRAIT_FLIPPED = 4, } +#[repr(u32)] +#[doc = " \\brief Window flash operation"] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum SDL_FlashOperation { + #[doc = "< Cancel any window flash state"] + SDL_FLASH_CANCEL = 0, + #[doc = "< Flash the window briefly to get attention"] + SDL_FLASH_BRIEFLY = 1, + #[doc = "< Flash the window until it gets focus"] + SDL_FLASH_UNTIL_FOCUSED = 2, +} #[doc = " \\brief An opaque handle to an OpenGL context."] pub type SDL_GLContext = *mut libc::c_void; #[repr(u32)] @@ -8467,6 +8478,14 @@ extern "C" { callback_data: *mut libc::c_void, ) -> libc::c_int; } +extern "C" { + #[doc = " \\Request a window to demand attention from the user."] + #[doc = ""] + #[doc = " \\param window the window to be flashed"] + #[doc = " \\param operation the flash operation"] + #[doc = " \\returns 0 on success or a negative error code on failure; call SDL_GetError() for more information."] + pub fn SDL_FlashWindow(window: *mut SDL_Window, operation: SDL_FlashOperation) -> libc::c_int; +} extern "C" { #[doc = " \\brief Destroy a window."] pub fn SDL_DestroyWindow(window: *mut SDL_Window); diff --git a/src/sdl2/video.rs b/src/sdl2/video.rs index e22925144e..118b235ff2 100644 --- a/src/sdl2/video.rs +++ b/src/sdl2/video.rs @@ -1768,6 +1768,17 @@ impl Window { Ok(opacity) } } + + #[doc(alias = "SDL_FlashWindow")] + pub fn flash_window(&mut self, operation: sys::SDL_FlashOperation) -> Result<(), String> { + let result = unsafe{ sys::SDL_FlashWindow(self.context.raw, operation) }; + if result == 0 { + Ok(()) + } + else { + Err(get_error()) + } + } } #[derive(Copy, Clone)] @@ -1818,4 +1829,4 @@ pub fn drivers() -> DriverIterator { length: unsafe { sys::SDL_GetNumVideoDrivers() }, index: 0, } -} +} \ No newline at end of file