#[cfg(target_os = "macos")]
use futures::executor::block_on;
use anyhow::Result;
#[cfg(target_os = "macos")]
mod mac;
#[cfg(target_os = "windows")]
mod win;
#[cfg(target_os = "linux")]
mod linux;
#[derive(Debug, Clone)]
pub struct Window {
pub id: u32,
pub title: String,
#[cfg(target_os = "windows")]
pub raw_handle: windows::Win32::Foundation::HWND,
#[cfg(target_os = "macos")]
pub raw_handle: cidre::cg::WindowId,
}
#[derive(Debug, Clone)]
pub struct Display {
pub id: u32,
pub title: String,
#[cfg(target_os = "windows")]
pub raw_handle: windows::Win32::Graphics::Gdi::HMONITOR,
#[cfg(target_os = "macos")]
pub raw_handle: cidre::cg::DirectDisplayId,
#[cfg(any(target_os = "linux", target_os = "windows"))]
pub width: u16,
#[cfg(any(target_os = "linux", target_os = "windows"))]
pub height: u16,
}
#[derive(Debug, Clone)]
pub enum Target {
Window(Window),
Display(Display),
}
#[cfg(target_os = "windows")]
unsafe impl Send for Display {}
#[cfg(target_os = "windows")]
unsafe impl Sync for Display {}
#[cfg(target_os = "windows")]
unsafe impl Send for Window {}
#[cfg(target_os = "windows")]
unsafe impl Sync for Window {}
pub fn get_all_targets() -> Result<Vec<Target>> {
#[cfg(target_os = "macos")]
return Ok(mac::get_all_targets());
#[cfg(target_os = "windows")]
return win::get_all_targets();
#[cfg(target_os = "linux")]
return Ok(linux::get_all_targets());
}
pub fn get_scale_factor(target: &Target) -> f64 {
#[cfg(target_os = "macos")]
return mac::get_scale_factor(target);
#[cfg(target_os = "windows")]
return win::get_scale_factor(target);
#[cfg(target_os = "linux")]
return 1.0;
}
pub fn get_main_display() -> Display {
#[cfg(target_os = "macos")]
return mac::get_main_display();
#[cfg(target_os = "windows")]
return win::get_main_display();
#[cfg(target_os = "linux")]
unreachable!();
}
pub fn get_target_dimensions(target: &Target) -> (u64, u64) {
#[cfg(target_os = "macos")]
return mac::get_target_dimensions(target);
#[cfg(target_os = "windows")]
return win::get_target_dimensions(target);
#[cfg(target_os = "linux")]
unreachable!();
}