#![allow(unused)] use super::{Message, MessageSink, display::Display}; use crate::wayland::{Client, WaylandError, WaylandResult}; use std::{fmt::Debug, sync::Arc}; use waynest::ObjectId; use waynest_protocols::server::core::wayland::wl_display::WlDisplay; use waynest_server::{Client as _, RequestDispatcher}; pub trait ClientExt { fn message_sink(&self) -> MessageSink; fn display(&self) -> Arc; fn try_get(&self, id: ObjectId) -> WaylandResult>; } impl ClientExt for Client { fn message_sink(&self) -> MessageSink { self.get::(ObjectId::DISPLAY) .unwrap() .message_sink .clone() } fn display(&self) -> Arc { self.get::(ObjectId::DISPLAY).unwrap() } fn try_get(&self, id: ObjectId) -> WaylandResult> { self.get::(id).ok_or(WaylandError::MissingObject(id)) } } #[derive(Debug, Default)] pub struct DoubleBuffer { pub current: State, pub pending: State, } impl DoubleBuffer { pub fn new(initial_state: State) -> Self { DoubleBuffer { current: initial_state.clone(), pending: initial_state, } } pub fn apply(&mut self) { self.current = self.pending.clone(); } pub fn current(&self) -> &State { &self.current } }