ailloli_ui_core/event/
window.rs

1//! Platform-neutral window surface and lifecycle notifications.
2
3/// Window-level lifecycle and surface events.
4///
5/// Possible notifications cover resize, scale factor, focus, close requests,
6/// and redraw requests.
7///
8/// # Examples
9///
10/// ```
11/// use ailloli_ui_core::event::WindowEvent;
12/// let event = WindowEvent::Resized { w: 800, h: 600 };
13/// assert!(matches!(event, WindowEvent::Resized { w: 800, h: 600 }));
14/// ```
15#[non_exhaustive]
16#[derive(Debug, Clone, PartialEq)]
17pub enum WindowEvent {
18    /// Inner size changed (physical pixels).
19    Resized {
20        /// Inner surface width in physical pixels; zero is valid while minimized.
21        w: u32,
22        /// Inner surface height in physical pixels; zero is valid while minimized.
23        h: u32,
24    },
25    /// HiDPI scale factor changed.
26    ScaleFactorChanged {
27        /// Provider device-pixel ratio; adapters should supply a finite positive value.
28        scale_factor: f32,
29    },
30    /// Window gained or lost focus.
31    Focused {
32        /// `true` when the native window gained focus and `false` when it lost focus.
33        focused: bool,
34    },
35    /// User or chrome requested close.
36    CloseRequested,
37    /// Compositor or app requested a redraw.
38    RedrawRequested,
39}