chore(wayland): update waynest

Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
Schmarni
2025-09-30 22:32:09 +02:00
parent 2d6bc06cbe
commit 0ebfc1153e
29 changed files with 204 additions and 99 deletions

View File

@@ -8,6 +8,7 @@ use bevy_dmabuf::dmatex::DmatexPlane;
use drm_fourcc::DrmFourcc;
use parking_lot::Mutex;
use rustc_hash::FxHashMap;
use waynest_server::Client as _;
use std::os::fd::{AsRawFd, OwnedFd};
use waynest::ObjectId;
use waynest_protocols::server::stable::linux_dmabuf_v1::zwp_linux_buffer_params_v1::{
@@ -20,7 +21,7 @@ use waynest_protocols::server::stable::linux_dmabuf_v1::zwp_linux_buffer_params_
/// that together form a single logical buffer. The object may eventually
/// create one wl_buffer unless cancelled by destroying it.
#[derive(Debug, waynest_server::RequestDispatcher)]
#[waynest(error = crate::wayland::WaylandError)]
#[waynest(error = crate::wayland::WaylandError, connection = crate::wayland::Client)]
pub struct BufferParams {
pub id: ObjectId,
pub(super) planes: Mutex<FxHashMap<u32, DmatexPlane>>,
@@ -120,7 +121,7 @@ impl ZwpLinuxBufferParamsV1 for BufferParams {
});
match buffer {
Ok(buffer) => self.created(client, self.id, buffer.id).await,
Ok(buffer) => self.created(client, self.id, buffer?.id).await,
Err(_) => {
client.remove(self.id);
self.failed(client, self.id).await
@@ -148,7 +149,7 @@ impl ZwpLinuxBufferParamsV1 for BufferParams {
flags,
) {
Ok(backing) => {
Buffer::new(client, buffer_id, BufferBacking::Dmabuf(backing));
Buffer::new(client, buffer_id, BufferBacking::Dmabuf(backing))?;
}
Err(e) => {
tracing::error!("Failed to import dmabuf because {e}");

View File

@@ -3,7 +3,7 @@ use crate::wayland::{Client, WaylandResult, vulkano_data::VULKANO_CONTEXT};
use memfd::MemfdOptions;
use std::{
io::Write,
os::fd::{FromRawFd, IntoRawFd, OwnedFd},
os::fd::{AsFd as _, FromRawFd, IntoRawFd, OwnedFd},
sync::Arc,
};
use waynest::ObjectId;
@@ -12,7 +12,7 @@ use waynest_protocols::server::stable::linux_dmabuf_v1::zwp_linux_dmabuf_feedbac
};
#[derive(Debug, waynest_server::RequestDispatcher)]
#[waynest(error = crate::wayland::WaylandError)]
#[waynest(error = crate::wayland::WaylandError, connection = crate::wayland::Client)]
pub struct DmabufFeedback(pub Arc<Dmabuf>);
impl DmabufFeedback {
#[tracing::instrument(level = "debug", skip_all)]
@@ -81,14 +81,9 @@ impl DmabufFeedback {
mfd.as_file().write_all(&0_u32.to_ne_bytes())?;
mfd.as_file().write_all(&modifier.to_ne_bytes())?;
}
self.format_table(
client,
sender_id,
unsafe { OwnedFd::from_raw_fd(mfd.into_raw_fd()) },
size,
)
.await?;
let fd = unsafe { OwnedFd::from_raw_fd(mfd.into_raw_fd()) };
self.format_table(client, sender_id, fd.as_fd(), size)
.await?;
Ok(())
}
}

View File

@@ -15,6 +15,7 @@ use buffer_params::BufferParams;
use drm_fourcc::DrmFourcc;
use feedback::DmabufFeedback;
use rustc_hash::FxHashSet;
use waynest_server::Client as _;
use std::sync::LazyLock;
use vulkano::format::FormatFeatures;
use waynest::ObjectId;
@@ -74,7 +75,7 @@ pub static DMABUF_FORMATS: LazyLock<Vec<(DrmFourcc, u64)>> = LazyLock::new(|| {
/// - Proper lifetime management of dmabuf file descriptors
/// - Safe handling of buffer attachments
#[derive(Debug, waynest_server::RequestDispatcher)]
#[waynest(error = crate::wayland::WaylandError)]
#[waynest(error = crate::wayland::WaylandError, connection = crate::wayland::Client)]
pub struct Dmabuf {
// Track supported formats and modifiers
// formats: Mutex<FxHashSet<DrmFormat>>,
@@ -138,7 +139,7 @@ impl ZwpLinuxDmabufV1 for Dmabuf {
params_id: ObjectId,
) -> WaylandResult<()> {
// Create new buffer parameters object
let params = client.insert(params_id, BufferParams::new(params_id));
let params = client.insert(params_id, BufferParams::new(params_id))?;
self.active_params.add_raw(&params);
Ok(())
}
@@ -157,7 +158,7 @@ impl ZwpLinuxDmabufV1 for Dmabuf {
});
}
// Create feedback object for default (non-surface-specific) settings
let feedback = client.insert(id, DmabufFeedback(client.get::<Dmabuf>(sender_id).unwrap()));
let feedback = client.insert(id, DmabufFeedback(client.get::<Dmabuf>(sender_id).unwrap()))?;
feedback.send_params(client, id).await?;
Ok(())
}