fix: full wayland version compliance

This commit is contained in:
Nova
2025-08-11 18:02:25 -07:00
parent 2719c0b00a
commit 41d6b02506
6 changed files with 69 additions and 30 deletions

View File

@@ -49,22 +49,31 @@ pub fn fixed_from_f32(f: f32) -> Fixed {
#[derive(Default, Dispatcher)]
pub struct Seat {
version: u32,
pointer: OnceLock<Arc<Pointer>>,
keyboard: OnceLock<Arc<Keyboard>>,
touch: OnceLock<Arc<Touch>>,
}
impl Seat {
pub fn new() -> Self {
Self::default()
}
pub async fn new(client: &mut Client, id: ObjectId, version: u32) -> Result<Self> {
let seat = Self {
version,
pointer: OnceLock::new(),
keyboard: OnceLock::new(),
touch: OnceLock::new(),
};
if version >= 2 {
seat.name(client, id, "theonlyseat".into()).await?;
}
pub async fn advertise_capabilities(&self, client: &mut Client, id: ObjectId) -> Result<()> {
tracing::debug!("Advertising seat capabilities with id {}", id);
let capabilities = Capability::Pointer | Capability::Keyboard | Capability::Touch;
WlSeat::capabilities(self, client, id, capabilities).await?;
WlSeat::capabilities(&seat, client, id, capabilities).await?;
tracing::debug!("Capabilities advertised: {:?}", capabilities);
Ok(())
Ok(seat)
}
pub async fn handle_message(&self, client: &mut Client, message: SeatMessage) -> Result<()> {
@@ -154,7 +163,7 @@ impl WlSeat for Seat {
_sender_id: ObjectId,
id: ObjectId,
) -> Result<()> {
let pointer = client.insert(id, Pointer::new(id));
let pointer = client.insert(id, Pointer::new(id, self.version));
let _ = self.pointer.set(pointer);
Ok(())
}