pebble_skip/user_interface/
window_stack.rs

1use super::window::Window;
2#[allow(clippy::wildcard_imports)]
3use pebble_sys::user_interface::window_stack::*;
4
5pub fn push<T: ?Sized>(window: &Window<T>, animated: bool) {
6	unsafe {
7		//SAFETY: This wrapper does not allow reacquiring windows from the window stack.
8		window_stack_push(&mut *(window.0.as_mut_unchecked() as *mut _), animated)
9	}
10}
11
12#[allow(clippy::must_use_candidate)] // side effects
13pub fn pop(animated: bool) -> bool {
14	unsafe { window_stack_pop(animated) }.is_some()
15}
16
17pub fn pop_all(animated: bool) {
18	unsafe { window_stack_pop_all(animated) }
19}
20
21#[allow(clippy::must_use_candidate)] // side effects
22pub fn remove<T: ?Sized>(window: &Window<T>, animated: bool) -> bool {
23	unsafe { window_stack_remove(window.0.as_mut_unchecked(), animated) }
24}
25
26#[must_use]
27pub fn is_empty() -> bool {
28	unsafe { window_stack_get_top_window() }.is_none()
29}
30
31#[must_use]
32pub fn contains_window<T: ?Sized>(window: &Window<T>) -> bool {
33	unsafe { window_stack_contains_window(window.0.as_mut_unchecked()) }
34}