1use anyhow::Result;
2use uuid::Uuid;
3
4use crate::{Bounds, DisplayId, GlobalPixels, PlatformDisplay, Size};
5
6#[derive(Debug)]
7pub(crate) struct X11Display {
8 x_screen_index: i32,
9 bounds: Bounds<GlobalPixels>,
10 uuid: Uuid,
11}
12
13impl X11Display {
14 pub(crate) fn new(xc: &xcb::Connection, x_screen_index: i32) -> Self {
15 let screen = xc.get_setup().roots().nth(x_screen_index as usize).unwrap();
16 Self {
17 x_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 X11Display {
31 fn id(&self) -> DisplayId {
32 DisplayId(self.x_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}