pub mod error;
use error::{DIError, DIResult};
#[cfg(all(target_family = "unix", not(target_os = "macos")))]
mod linux;
#[cfg(all(target_family = "unix", not(target_os = "macos")))]
use linux::ScreenRawHandle;
#[cfg(target_os = "macos")]
mod macos;
#[cfg(target_os = "macos")]
use macos::ScreenRawHandle;
#[cfg(target_os = "windows")]
mod windows;
#[cfg(target_os = "windows")]
use windows::ScreenRawHandle;
#[derive(Debug, Clone)]
pub struct DisplayInfo {
pub id: u32,
pub name: String,
pub friendly_name: String,
pub raw_handle: ScreenRawHandle,
pub x: i32,
pub y: i32,
pub width: u32,
pub height: u32,
pub width_mm: i32,
pub height_mm: i32,
pub rotation: f32,
pub scale_factor: f32,
pub frequency: f32,
pub is_primary: bool,
pub is_builtin: bool,
}
impl DisplayInfo {
pub fn from_name(name: impl ToString) -> DIResult<DisplayInfo> {
let name = name.to_string();
let display_infos = DisplayInfo::all()?;
display_infos
.iter()
.find(|&d| d.name == name)
.cloned()
.ok_or_else(|| DIError::new("Get display info failed"))
}
}