fix(wayland): protocol error

This commit is contained in:
Nova
2025-08-03 15:43:51 -07:00
parent de045a1c68
commit 24beda4a4a
4 changed files with 60 additions and 23 deletions

View File

@@ -12,7 +12,7 @@ use waynest::{
server::{
Client, Dispatcher, Result,
protocol::stable::linux_dmabuf_v1::zwp_linux_buffer_params_v1::{
Flags, ZwpLinuxBufferParamsV1,
Error, Flags, ZwpLinuxBufferParamsV1,
},
},
wire::ObjectId,
@@ -129,7 +129,7 @@ impl ZwpLinuxBufferParamsV1 for BufferParams {
async fn create_immed(
&self,
client: &mut Client,
_sender_id: ObjectId,
sender_id: ObjectId,
buffer_id: ObjectId,
width: i32,
height: i32,
@@ -138,15 +138,27 @@ impl ZwpLinuxBufferParamsV1 for BufferParams {
) -> Result<()> {
// TODO: terminate client on fail, or send a fail event or something
// Create the buffer with DMA-BUF backing using self as the backing
_ = DmabufBacking::from_params(
match DmabufBacking::from_params(
client.get::<Self>(self.id).unwrap(),
[width as u32, height as u32].into(),
DrmFourcc::try_from(format).unwrap(),
flags,
)
.inspect_err(|e| tracing::error!("Failed to import dmabuf because {e}"))
.map(|backing| Buffer::new(client, buffer_id, BufferBacking::Dmabuf(backing)));
) {
Ok(backing) => {
Buffer::new(client, buffer_id, BufferBacking::Dmabuf(backing));
}
Err(e) => {
client
.protocol_error(
sender_id,
buffer_id,
Error::Incomplete as u32,
format!("Failed to import dmabuf because {e}"),
)
.await?;
tracing::error!("Failed to import dmabuf because {e}");
}
}
Ok(())
}
}

View File

@@ -15,10 +15,7 @@ use vulkano::format::FormatFeatures;
use waynest::{
server::{
Client, Dispatcher, Error, Result,
protocol::{
core::wayland::wl_display::WlDisplay,
stable::linux_dmabuf_v1::zwp_linux_dmabuf_v1::ZwpLinuxDmabufV1,
},
protocol::stable::linux_dmabuf_v1::zwp_linux_dmabuf_v1::ZwpLinuxDmabufV1,
},
wire::ObjectId,
};
@@ -146,9 +143,7 @@ impl ZwpLinuxDmabufV1 for Dmabuf {
) -> Result<()> {
if self.version < 3 {
client
.display()
.error(
client,
.protocol_error(
sender_id,
id,
71,