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

@@ -21,7 +21,7 @@ impl WlCompositor for Compositor {
) -> Result<()> {
let surface = client.insert(id, Surface::new(client, id));
if let Some(output) = client.display().output.get() {
surface.enter(client, id, output.0).await?;
surface.enter(client, id, output.id).await?;
}
WL_SURFACE_REGISTRY.add_raw(&surface);

View File

@@ -6,12 +6,15 @@ use waynest::{
pub use waynest::server::protocol::core::wayland::wl_output::*;
#[derive(Debug, Dispatcher)]
pub struct Output(pub ObjectId);
pub struct Output {
pub id: ObjectId,
pub version: u32,
}
impl Output {
pub async fn advertise_outputs(&self, client: &mut Client) -> Result<()> {
self.geometry(
client,
self.0,
self.id,
2048,
2048,
0,
@@ -23,10 +26,13 @@ impl Output {
)
.await?;
self.mode(client, self.0, Mode::Current, 2048, 2048, i32::MAX)
self.mode(client, self.id, Mode::Current, 2048, 2048, i32::MAX)
.await?;
self.done(client, self.0).await
if self.version >= 2 {
self.done(client, self.id).await?;
}
Ok(())
}
}
impl WlOutput for Output {

View File

@@ -13,12 +13,14 @@ use waynest::{
#[derive(Dispatcher)]
pub struct Pointer {
pub id: ObjectId,
version: u32,
focused_surface: Mutex<Weak<Surface>>,
}
impl Pointer {
pub fn new(id: ObjectId) -> Self {
pub fn new(id: ObjectId, version: u32) -> Self {
Self {
id,
version,
focused_surface: Mutex::new(Weak::new()),
}
}
@@ -77,7 +79,9 @@ impl Pointer {
fixed_from_f32(position.y),
)
.await?;
self.frame(client, self.id).await?;
if self.version >= 5 {
self.frame(client, self.id).await?;
}
Ok(())
}
@@ -141,13 +145,16 @@ impl Pointer {
)
.await?;
}
if let Some(steps) = scroll_steps {
self.axis_discrete(client, self.id, Axis::HorizontalScroll, steps.x as i32)
.await?;
self.axis_discrete(client, self.id, Axis::VerticalScroll, steps.y as i32)
.await?;
if self.version >= 5 {
if let Some(steps) = scroll_steps {
self.axis_discrete(client, self.id, Axis::HorizontalScroll, steps.x as i32)
.await?;
self.axis_discrete(client, self.id, Axis::VerticalScroll, steps.y as i32)
.await?;
}
self.frame(client, self.id).await?;
}
self.frame(client, self.id).await
Ok(())
}
pub async fn reset(&self, client: &mut Client) -> Result<()> {

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(())
}

View File

@@ -253,7 +253,11 @@ impl Surface {
.collect::<Vec<_>>();
for feedback in feedbacks {
feedback
.sync_output(client, feedback.0, client.display().output.get().unwrap().0)
.sync_output(
client,
feedback.0,
client.display().output.get().unwrap().id,
)
.await?;
let cycle_lo = refresh_cycle as u32;
let cycle_hi = (refresh_cycle >> 32) as u32;