dampen_dev/persistence/monitor.rs
1/// Check if a window position is reasonable (likely on screen).
2///
3/// Since we can't easily detect monitors without a window handle or active event loop,
4/// we use heuristics to filter out obviously invalid coordinates (e.g. from corrupted state
5/// or disconnected monitors resulting in huge coordinates).
6pub fn position_is_reasonable(x: i32, y: i32) -> bool {
7 // Arbitrary bounds: -30,000 to +30,000
8 // Most multi-monitor setups are within this range.
9 const MAX_COORD: i32 = 30_000;
10 const MIN_COORD: i32 = -30_000;
11
12 (MIN_COORD..=MAX_COORD).contains(&x) && (MIN_COORD..=MAX_COORD).contains(&y)
13}