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