1
0
Fork 0
forked from wry/wry

head-management: add ReadOnlyHeadState

This commit is contained in:
Julian Orth 2026-03-07 12:04:13 +01:00
parent cf8b696f03
commit cbe190274e

View file

@ -18,7 +18,7 @@ use {
wire::JayHeadManagerSessionV1Id,
},
std::{
cell::{Cell, RefCell},
cell::{Cell, Ref, RefCell},
rc::Rc,
},
thiserror::Error,
@ -94,6 +94,17 @@ pub struct HeadState {
pub brightness: Option<f64>,
}
pub struct ReadOnlyHeadState {
state: Rc<RefCell<HeadState>>,
}
impl ReadOnlyHeadState {
#[expect(dead_code)]
pub fn borrow(&self) -> Ref<'_, HeadState> {
self.state.borrow()
}
}
impl HeadState {
fn update_in_compositor_space(&mut self, wl_output: Option<GlobalName>) {
self.in_compositor_space = false;
@ -218,6 +229,13 @@ impl HeadManagers {
}
}
#[expect(dead_code)]
pub fn state(&self) -> ReadOnlyHeadState {
ReadOnlyHeadState {
state: self.state.clone(),
}
}
pub fn handle_removed(&self) {
for head in self.managers.lock().drain_values() {
skip_in_transaction!(head);