gpui_platform/window_metrics.rs
1//! A sampled snapshot of a window's geometry and state.
2
3use crate::DisplayId;
4use gpui_types::{Bounds, Pixels, Size};
5
6/// The state a window is presenting, sampled once from its platform window.
7///
8/// The getters on [`PlatformWindow`](crate::PlatformWindow) query the operating
9/// system, so they can only be called while the window is borrowed. A
10/// `WindowMetrics` is a plain value taken from those getters at a moment in
11/// time, which makes it cheap to publish and safe to read from another thread.
12#[derive(Clone, Debug, PartialEq)]
13pub struct WindowMetrics {
14 /// The window's bounds in the global coordinate space, which can span displays.
15 pub bounds: Bounds<Pixels>,
16 /// The visible viewport in window-local logical pixels.
17 ///
18 /// Unlike [`Self::content_size`], this can shrink or move when a software
19 /// keyboard opens.
20 pub viewport: Bounds<Pixels>,
21 /// The size of the drawable area, which is the window's full layout size.
22 pub content_size: Size<Pixels>,
23 /// The scale factor of the display the window is on.
24 pub scale_factor: f32,
25 /// The display the window is on, when the platform reports one.
26 pub display_id: Option<DisplayId>,
27 /// Whether this is the platform's active, or focused, window.
28 pub is_active: bool,
29 /// Whether the window is fullscreen.
30 pub is_fullscreen: bool,
31}