Merge pull request #385 from Smithay/feature/dmabuf_filter
This commit is contained in:
commit
dd6919dd5f
|
@ -22,6 +22,7 @@
|
|||
- Setting the parent of a toplevel surface is now possible with the `xdg::ToplevelSurface::set_parent` function.
|
||||
- Add support for the zxdg-foreign-v2 protocol.
|
||||
- Support for `xdg_wm_base` protocol version 3
|
||||
- Added the option to initialize the dmabuf global with a client filter
|
||||
|
||||
### Bugfixes
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ use wayland_protocols::unstable::linux_dmabuf::v1::server::{
|
|||
},
|
||||
zwp_linux_dmabuf_v1,
|
||||
};
|
||||
use wayland_server::{protocol::wl_buffer, DispatchData, Display, Filter, Global, Main};
|
||||
use wayland_server::{protocol::wl_buffer, Client, DispatchData, Display, Filter, Global, Main};
|
||||
|
||||
use slog::{o, trace};
|
||||
|
||||
|
@ -63,9 +63,7 @@ use crate::backend::allocator::{
|
|||
Format, Fourcc, Modifier,
|
||||
};
|
||||
|
||||
/// Handler trait for dmabuf validation
|
||||
///
|
||||
/// You need to provide an implementation of this trait
|
||||
const DMABUF_VERSION: u32 = 3;
|
||||
|
||||
/// Initialize a dmabuf global.
|
||||
///
|
||||
|
@ -77,6 +75,37 @@ pub fn init_dmabuf_global<F, L>(
|
|||
handler: F,
|
||||
logger: L,
|
||||
) -> Global<zwp_linux_dmabuf_v1::ZwpLinuxDmabufV1>
|
||||
where
|
||||
L: Into<Option<::slog::Logger>>,
|
||||
F: for<'a> FnMut(&Dmabuf, DispatchData<'a>) -> bool + 'static,
|
||||
{
|
||||
display.create_global(DMABUF_VERSION, dmabuf_global(formats, handler, logger))
|
||||
}
|
||||
|
||||
/// Initialize a dmabuf global with a client filter.
|
||||
///
|
||||
/// You need to provide a vector of the supported formats, as well as a closure,
|
||||
/// that will validate the parameters provided by the client and tests the import as a dmabuf.
|
||||
pub fn init_dmabuf_global_with_filter<H, F, L>(
|
||||
display: &mut Display,
|
||||
formats: Vec<Format>,
|
||||
handler: H,
|
||||
filter: F,
|
||||
logger: L,
|
||||
) -> Global<zwp_linux_dmabuf_v1::ZwpLinuxDmabufV1>
|
||||
where
|
||||
L: Into<Option<::slog::Logger>>,
|
||||
H: for<'a> FnMut(&Dmabuf, DispatchData<'a>) -> bool + 'static,
|
||||
F: FnMut(Client) -> bool + 'static,
|
||||
{
|
||||
display.create_global_with_filter(DMABUF_VERSION, dmabuf_global(formats, handler, logger), filter)
|
||||
}
|
||||
|
||||
fn dmabuf_global<F, L>(
|
||||
formats: Vec<Format>,
|
||||
handler: F,
|
||||
logger: L,
|
||||
) -> Filter<(Main<zwp_linux_dmabuf_v1::ZwpLinuxDmabufV1>, u32)>
|
||||
where
|
||||
L: Into<Option<::slog::Logger>>,
|
||||
F: for<'a> FnMut(&Dmabuf, DispatchData<'a>) -> bool + 'static,
|
||||
|
@ -92,8 +121,6 @@ where
|
|||
formats.len()
|
||||
);
|
||||
|
||||
display.create_global(
|
||||
3,
|
||||
Filter::new(
|
||||
move |(dmabuf, version): (Main<zwp_linux_dmabuf_v1::ZwpLinuxDmabufV1>, u32), _, _| {
|
||||
let dma_formats = formats.clone();
|
||||
|
@ -137,9 +164,7 @@ where
|
|||
height,
|
||||
format,
|
||||
flags,
|
||||
} => {
|
||||
handler.create_immed(&*params, buffer_id, width, height, format, flags, ddata)
|
||||
}
|
||||
} => handler.create_immed(&*params, buffer_id, width, height, format, flags, ddata),
|
||||
_ => {}
|
||||
});
|
||||
}
|
||||
|
@ -157,7 +182,6 @@ where
|
|||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue