Skip to main content

euv_core/platform/info/
struct.rs

1use super::*;
2
3/// Normalized hardware and OS capability flags reported by every platform backend.
4#[derive(Clone, Copy, Debug, Default, Eq, Getter, Hash, PartialEq)]
5pub struct PlatformCapabilities {
6    /// Supports opening and managing multiple independent OS windows simultaneously.
7    #[get(type(copy))]
8    pub(crate) multi_window: bool,
9    /// Supports hover pointer tracking (mouse, trackpad, Apple Pencil hover).
10    #[get(type(copy))]
11    pub(crate) hover_pointer: bool,
12    /// Supports multi-touch gestures.
13    #[get(type(copy))]
14    pub(crate) touch: bool,
15    /// Supports stylus / Apple Pencil pressure input.
16    #[get(type(copy))]
17    pub(crate) stylus: bool,
18    /// Supports physical hardware keyboard input.
19    #[get(type(copy))]
20    pub(crate) hardware_keyboard: bool,
21    /// Reports non-trivial OS safe-area cutouts or gesture bars.
22    #[get(type(copy))]
23    pub(crate) safe_area_insets: bool,
24    /// Supports native GPU hardware acceleration (Metal / Vulkan / D3D / WebGPU / WebGL2).
25    #[get(type(copy))]
26    pub(crate) hardware_gpu: bool,
27    /// Supports direct CPU framebuffer presentation.
28    #[get(type(copy))]
29    pub(crate) software_blit: bool,
30    /// Supports native system clipboard read/write.
31    #[get(type(copy))]
32    pub(crate) clipboard: bool,
33    /// Supports native IME / soft keyboard composition.
34    #[get(type(copy))]
35    pub(crate) ime: bool,
36    /// Supports Apple Dynamic Island hardware cutout presentation (`iOS`).
37    #[get(type(copy))]
38    pub(crate) dynamic_island: bool,
39    /// Supports native Live Activities / ongoing live status surfaces (`iOS`, `iPadOS`, `Android`).
40    #[get(type(copy))]
41    pub(crate) live_activities: bool,
42    /// Supports desktop system tray or menu bar status icons (`macOS`, `Windows`, `Linux`).
43    #[get(type(copy))]
44    pub(crate) system_tray: bool,
45    /// Supports OS biometric authentication (Face ID, Touch ID, BiometricPrompt, Windows Hello, Passkeys).
46    #[get(type(copy))]
47    pub(crate) biometrics: bool,
48    /// Supports tactile haptic feedback pulses.
49    #[get(type(copy))]
50    pub(crate) haptics: bool,
51    /// Supports custom URL protocol / deep link handler registration.
52    #[get(type(copy))]
53    pub(crate) protocol_handler: bool,
54    /// Supports native OS accessibility bridge (NSAccessibility, UIAccessibility, UIA, AT-SPI2, Android, ARIA).
55    #[get(type(copy))]
56    pub(crate) accessibility_bridge: bool,
57}
58
59/// Hardware display mode descriptor reported by Android `Display.Mode` and desktop monitors.
60#[derive(Clone, Copy, Debug, Default, Getter, New, PartialEq)]
61pub struct DisplayModeInfo {
62    /// OS display mode identifier (e.g. Android `Display.Mode.getModeId()`).
63    #[get(pub(crate), type(copy))]
64    pub(crate) mode_id: i32,
65    /// Physical mode width in pixels.
66    #[get(pub(crate), type(copy))]
67    pub(crate) physical_width: u32,
68    /// Physical mode height in pixels.
69    #[get(pub(crate), type(copy))]
70    pub(crate) physical_height: u32,
71    /// Nominal hardware refresh rate in Hertz (e.g. `60.0`, `90.0`, `120.0`, `144.0`, `240.0`).
72    #[get(pub(crate), type(copy))]
73    pub(crate) refresh_rate_hz: f32,
74}
75
76/// Resolved VSync frame pacing parameters for high-refresh displays (`CADisplayLink`, `Choreographer`, desktop timers).
77#[derive(Clone, Copy, Debug, Default, Getter, New, PartialEq)]
78pub struct FramePacingConfig {
79    /// Minimum adaptive refresh rate in Hertz (`CAFrameRateRange.minimum`).
80    #[get(pub(crate), type(copy))]
81    pub(crate) min_hz: f32,
82    /// Maximum adaptive refresh rate in Hertz (`CAFrameRateRange.maximum`).
83    #[get(pub(crate), type(copy))]
84    pub(crate) max_hz: f32,
85    /// Preferred target refresh rate in Hertz (`CAFrameRateRange.preferred` / `Surface.setFrameRate`).
86    #[get(pub(crate), type(copy))]
87    pub(crate) preferred_hz: f32,
88    /// Nominal frame duration in seconds (`1.0 / preferred_hz`).
89    #[get(pub(crate), type(copy))]
90    pub(crate) frame_interval_secs: f32,
91    /// Nominal frame duration in nanoseconds (`round(1e9 / preferred_hz)`).
92    #[get(pub(crate), type(copy))]
93    pub(crate) frame_interval_nanos: u64,
94}
95
96/// Platform-side active touch contact tracker normalizing Android `MotionEvent` and iOS `UITouch` cancellation lifecycles.
97#[derive(Clone, Data, Debug, Default, PartialEq)]
98pub struct TouchPointerTracker {
99    /// Ordered set of currently live mapped pointer contact identifiers (`>= 1`).
100    #[get(pub(crate))]
101    #[get_mut(pub(crate))]
102    #[set(pub(crate))]
103    pub(crate) active_pointers: Vec<u64>,
104}
105
106/// Generation-stamped mobile host session lifecycle coordinator guarding same-process exit and re-entry races.
107#[derive(Clone, Data, Debug, Default, PartialEq)]
108pub struct MobileSessionLifecycle {
109    /// Monotonic process-wide session generation incremented on every fresh activity or scene launch.
110    #[get(pub(crate), type(copy))]
111    #[set(pub(crate))]
112    pub(crate) session_generation: u64,
113    /// Identifier of the currently active host activity or scene owning native bridge callbacks.
114    #[get(pub(crate), type(copy))]
115    #[set(pub(crate))]
116    pub(crate) active_owner_id: u64,
117    /// Monotonic frame-loop generation preventing duplicate `Choreographer` or `CADisplayLink` callbacks.
118    #[get(pub(crate), type(copy))]
119    #[set(pub(crate))]
120    pub(crate) loop_generation: u64,
121    /// Whether the active session currently has an attached native rendering surface.
122    #[get(pub(crate), type(copy))]
123    #[set(pub(crate))]
124    pub(crate) surface_attached: bool,
125    /// Whether the active session's VSync render loop is running.
126    #[get(pub(crate), type(copy))]
127    #[set(pub(crate))]
128    pub(crate) loop_running: bool,
129    /// Whether the active session's runtime `App` is still open and interactive.
130    #[get(pub(crate), type(copy))]
131    #[set(pub(crate))]
132    pub(crate) app_running: bool,
133    /// Whether the active session is currently background-frozen.
134    #[get(pub(crate), type(copy))]
135    #[set(pub(crate))]
136    pub(crate) background_frozen: bool,
137    /// Whether the active session received a terminal exit or `Terminate` signal.
138    #[get(pub(crate), type(copy))]
139    #[set(pub(crate))]
140    pub(crate) terminated: bool,
141    /// Active touch contact tracker cleared automatically on pause, focus loss, and surface teardown.
142    #[get(pub(crate))]
143    #[get_mut(pub(crate))]
144    #[set(pub(crate))]
145    pub(crate) touch_tracker: TouchPointerTracker,
146}