ailloli_ui_winit/dpi.rs
1//! DPI and physical size helpers aligned with `ailloli_ui_core`.
2
3use winit::window::Window;
4
5/// Returns `(scale_factor, inner_width_px, inner_height_px)`.
6///
7/// The scale factor is `f64`; dimensions are the current physical client size
8/// in pixels and may be zero while a surface is minimized or not configured.
9///
10/// # Examples
11///
12/// ```no_run
13/// use ailloli_ui_winit::dpi::window_scale_and_inner_px;
14/// use winit::window::Window;
15/// fn inspect(window: &Window) {
16/// let (scale, width_px, height_px): (f64, u32, u32) = window_scale_and_inner_px(window);
17/// assert!(scale > 0.0);
18/// let _ = (width_px, height_px);
19/// }
20/// ```
21pub fn window_scale_and_inner_px(window: &Window) -> (f64, u32, u32) {
22 let s = window.inner_size();
23 (window.scale_factor(), s.width, s.height)
24}