Skip to repository content52 lines · 1.3 KB · rust
tenant.openagents/omega
No repository description is available.
OpenAgents Git authority 2026-07-28T05:03:40.037Z Public web read
NIP-34 coordinate
30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omegaMaintainersHidden in public view
References2 branches · 1 tag
Read-only clone
git clone https://openagents.com/git/tenant.openagents/omega.gitBrowse files
display.rs
1use anyhow::Context as _;
2use uuid::Uuid;
3use x11rb::{connection::Connection as _, xcb_ffi::XCBConnection};
4
5use gpui::{Bounds, DisplayId, Pixels, PlatformDisplay, Size, px};
6
7#[derive(Debug)]
8pub(crate) struct X11Display {
9 x_screen_index: usize,
10 bounds: Bounds<Pixels>,
11 uuid: Uuid,
12}
13
14impl X11Display {
15 pub(crate) fn new(
16 xcb: &XCBConnection,
17 scale_factor: f32,
18 x_screen_index: usize,
19 ) -> anyhow::Result<Self> {
20 let screen = xcb
21 .setup()
22 .roots
23 .get(x_screen_index)
24 .with_context(|| format!("No screen found with index {x_screen_index}"))?;
25 Ok(Self {
26 x_screen_index,
27 bounds: Bounds {
28 origin: Default::default(),
29 size: Size {
30 width: px(screen.width_in_pixels as f32 / scale_factor),
31 height: px(screen.height_in_pixels as f32 / scale_factor),
32 },
33 },
34 uuid: Uuid::from_bytes([0; 16]),
35 })
36 }
37}
38
39impl PlatformDisplay for X11Display {
40 fn id(&self) -> DisplayId {
41 DisplayId::new(self.x_screen_index as u64)
42 }
43
44 fn uuid(&self) -> anyhow::Result<Uuid> {
45 Ok(self.uuid)
46 }
47
48 fn bounds(&self) -> Bounds<Pixels> {
49 self.bounds
50 }
51}
52