1use anyhow::Result;
21
22#[cfg(target_os = "macos")]
23mod darwin;
24#[cfg(target_os = "macos")]
25use core_graphics::display::CGDisplay;
26#[cfg(target_os = "macos")]
27use darwin::*;
28
29#[cfg(target_os = "windows")]
30mod win32;
31#[cfg(target_os = "windows")]
32use win32::*;
33#[cfg(target_os = "windows")]
34use windows::Win32::Graphics::Gdi::HMONITOR;
35
36#[cfg(target_os = "linux")]
37mod linux;
38#[cfg(target_os = "linux")]
39use linux::*;
40#[cfg(target_os = "linux")]
41use xcb::randr::Output;
42
43#[derive(Debug, Clone, Copy)]
44pub struct DisplayInfo {
45 pub id: u32,
47 #[cfg(target_os = "macos")]
48 pub raw_handle: CGDisplay,
49 #[cfg(target_os = "windows")]
50 pub raw_handle: HMONITOR,
51 #[cfg(target_os = "linux")]
52 pub raw_handle: Output,
53 pub x: i32,
55 pub y: i32,
57 pub width: u32,
59 pub height: u32,
61 pub rotation: f32,
63 pub scale_factor: f32,
65 pub frequency: f32,
67 pub is_primary: bool,
69}
70
71impl DisplayInfo {
72 pub fn all() -> Result<Vec<DisplayInfo>> {
73 get_all()
74 }
75
76 pub fn from_point(x: i32, y: i32) -> Result<DisplayInfo> {
77 get_from_point(x, y)
78 }
79}