1use crate::{Bounds, DisplayId, GlobalPixels, PlatformDisplay, Size};
2use anyhow::Result;
3use uuid::Uuid;
4
5#[derive(Debug)]
6pub(crate) struct LinuxDisplay {
7 x_screen_index: i32,
8 bounds: Bounds<GlobalPixels>,
9 uuid: Uuid,
10}
11
12impl LinuxDisplay {
13 pub(crate) fn new(xc: &xcb::Connection, x_screen_index: i32) -> Self {
14 let screen = xc.get_setup().roots().nth(x_screen_index as usize).unwrap();
15 Self {
16 x_screen_index,
17 bounds: Bounds {
18 origin: Default::default(),
19 size: Size {
20 width: GlobalPixels(screen.width_in_pixels() as f32),
21 height: GlobalPixels(screen.height_in_pixels() as f32),
22 },
23 },
24 uuid: Uuid::from_bytes([0; 16]),
25 }
26 }
27}
28
29impl PlatformDisplay for LinuxDisplay {
30 fn id(&self) -> DisplayId {
31 DisplayId(self.x_screen_index as u32)
32 }
33
34 fn uuid(&self) -> Result<Uuid> {
35 Ok(self.uuid)
36 }
37
38 fn bounds(&self) -> Bounds<GlobalPixels> {
39 self.bounds
40 }
41}