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

binding for SDL_FlashWindow added #1204

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions sdl2-sys/sdl_bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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);
Expand Down
13 changes: 12 additions & 1 deletion src/sdl2/video.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1768,6 +1768,17 @@ impl Window {
Ok(opacity)
}
}

#[doc(alias = "SDL_FlashWindow")]
pub fn flash_window(&mut self, operation: sys::SDL_FlashOperation) -> Result<(), String> {

Choose a reason for hiding this comment

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

probably should just be called pub fn flash(…)

Copy link
Author

Choose a reason for hiding this comment

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

okay i will change that.

let result = unsafe{ sys::SDL_FlashWindow(self.context.raw, operation) };
if result == 0 {
Ok(())
}
else {
Err(get_error())
}
}
}

#[derive(Copy, Clone)]
Expand Down Expand Up @@ -1818,4 +1829,4 @@ pub fn drivers() -> DriverIterator {
length: unsafe { sys::SDL_GetNumVideoDrivers() },
index: 0,
}
}
}