Fix several clippy lints
This commit is contained in:
parent
c630bd9086
commit
9ad0edd2a3
|
@ -46,7 +46,7 @@ impl<Backend> AnvilState<Backend> {
|
||||||
// only process special actions on key press, not release
|
// only process special actions on key press, not release
|
||||||
return KeyAction::None;
|
return KeyAction::None;
|
||||||
}
|
}
|
||||||
return action;
|
action
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_pointer_button<B: InputBackend>(&mut self, evt: B::PointerButtonEvent) {
|
fn on_pointer_button<B: InputBackend>(&mut self, evt: B::PointerButtonEvent) {
|
||||||
|
@ -223,7 +223,7 @@ impl AnvilState<UdevData> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clamp_coords(&self, pos: (f64, f64)) -> (f64, f64) {
|
fn clamp_coords(&self, pos: (f64, f64)) -> (f64, f64) {
|
||||||
if self.backend_data.output_map.len() == 0 {
|
if self.backend_data.output_map.is_empty() {
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -189,7 +189,7 @@ pub fn run_winit(
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
.map_err(Into::<SwapBuffersError>::into)
|
.map_err(Into::<SwapBuffersError>::into)
|
||||||
.and_then(|x| x.into());
|
.and_then(|x| x);
|
||||||
|
|
||||||
renderer.window().set_cursor_visible(cursor_visible);
|
renderer.window().set_cursor_visible(cursor_visible);
|
||||||
|
|
||||||
|
|
|
@ -152,7 +152,7 @@ impl DmabufBuilder {
|
||||||
///
|
///
|
||||||
/// Returns `None` if the builder has no planes attached.
|
/// Returns `None` if the builder has no planes attached.
|
||||||
pub fn build(mut self) -> Option<Dmabuf> {
|
pub fn build(mut self) -> Option<Dmabuf> {
|
||||||
if self.internal.planes.len() == 0 {
|
if self.internal.planes.is_empty() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ impl Dmabuf {
|
||||||
// Note: the `src` Buffer is only used a reference for size and format.
|
// Note: the `src` Buffer is only used a reference for size and format.
|
||||||
// The contents are determined by the provided file descriptors, which
|
// The contents are determined by the provided file descriptors, which
|
||||||
// do not need to refer to the same buffer `src` does.
|
// do not need to refer to the same buffer `src` does.
|
||||||
pub fn new_from_buffer(src: &impl Buffer, flags: DmabufFlags) -> DmabufBuilder {
|
pub fn builder_from_buffer(src: &impl Buffer, flags: DmabufFlags) -> DmabufBuilder {
|
||||||
DmabufBuilder {
|
DmabufBuilder {
|
||||||
internal: DmabufInternal {
|
internal: DmabufInternal {
|
||||||
planes: Vec::with_capacity(MAX_PLANES),
|
planes: Vec::with_capacity(MAX_PLANES),
|
||||||
|
@ -179,8 +179,8 @@ impl Dmabuf {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new Dmabuf
|
/// Create a new Dmabuf builder
|
||||||
pub fn new(width: u32, height: u32, format: Fourcc, flags: DmabufFlags) -> DmabufBuilder {
|
pub fn builder(width: u32, height: u32, format: Fourcc, flags: DmabufFlags) -> DmabufBuilder {
|
||||||
DmabufBuilder {
|
DmabufBuilder {
|
||||||
internal: DmabufInternal {
|
internal: DmabufInternal {
|
||||||
planes: Vec::with_capacity(MAX_PLANES),
|
planes: Vec::with_capacity(MAX_PLANES),
|
||||||
|
@ -198,17 +198,17 @@ impl Dmabuf {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns raw handles of the planes of this buffer
|
/// Returns raw handles of the planes of this buffer
|
||||||
pub fn handles<'a>(&'a self) -> impl Iterator<Item = RawFd> + 'a {
|
pub fn handles(&self) -> impl Iterator<Item = RawFd> + '_ {
|
||||||
self.0.planes.iter().map(|p| *p.fd.as_ref().unwrap())
|
self.0.planes.iter().map(|p| *p.fd.as_ref().unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns offsets for the planes of this buffer
|
/// Returns offsets for the planes of this buffer
|
||||||
pub fn offsets<'a>(&'a self) -> impl Iterator<Item = u32> + 'a {
|
pub fn offsets(&self) -> impl Iterator<Item = u32> + '_ {
|
||||||
self.0.planes.iter().map(|p| p.offset)
|
self.0.planes.iter().map(|p| p.offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns strides for the planes of this buffer
|
/// Returns strides for the planes of this buffer
|
||||||
pub fn strides<'a>(&'a self) -> impl Iterator<Item = u32> + 'a {
|
pub fn strides(&self) -> impl Iterator<Item = u32> + '_ {
|
||||||
self.0.planes.iter().map(|p| p.stride)
|
self.0.planes.iter().map(|p| p.stride)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ impl<T> AsDmabuf for GbmBuffer<T> {
|
||||||
return Err(GbmConvertError::InvalidFD);
|
return Err(GbmConvertError::InvalidFD);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut builder = Dmabuf::new_from_buffer(self, DmabufFlags::empty());
|
let mut builder = Dmabuf::builder_from_buffer(self, DmabufFlags::empty());
|
||||||
for idx in 0..planes {
|
for idx in 0..planes {
|
||||||
builder.add_plane(
|
builder.add_plane(
|
||||||
self.fd()?,
|
self.fd()?,
|
||||||
|
|
|
@ -172,10 +172,10 @@ where
|
||||||
debug!(logger, "Success, choosen format: {:?}", format);
|
debug!(logger, "Success, choosen format: {:?}", format);
|
||||||
let buffers = Buffers::new(drm.clone(), gbm, buffer);
|
let buffers = Buffers::new(drm.clone(), gbm, buffer);
|
||||||
Ok(DrmRenderSurface {
|
Ok(DrmRenderSurface {
|
||||||
drm,
|
|
||||||
renderer,
|
|
||||||
swapchain,
|
|
||||||
buffers,
|
buffers,
|
||||||
|
swapchain,
|
||||||
|
renderer,
|
||||||
|
drm,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
@ -337,12 +337,14 @@ impl<A: AsRawFd + 'static> Drop for FbHandle<A> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type DmabufSlot<B, D> = Slot<B, (Dmabuf, BufferObject<FbHandle<D>>)>;
|
||||||
|
|
||||||
struct Buffers<D: AsRawFd + 'static, B: Buffer> {
|
struct Buffers<D: AsRawFd + 'static, B: Buffer> {
|
||||||
gbm: GbmDevice<gbm::FdWrapper>,
|
gbm: GbmDevice<gbm::FdWrapper>,
|
||||||
drm: Arc<DrmSurface<D>>,
|
drm: Arc<DrmSurface<D>>,
|
||||||
_current_fb: Slot<B, (Dmabuf, BufferObject<FbHandle<D>>)>,
|
_current_fb: DmabufSlot<B, D>,
|
||||||
pending_fb: Option<Slot<B, (Dmabuf, BufferObject<FbHandle<D>>)>>,
|
pending_fb: Option<DmabufSlot<B, D>>,
|
||||||
queued_fb: Option<Slot<B, (Dmabuf, BufferObject<FbHandle<D>>)>>,
|
queued_fb: Option<DmabufSlot<B, D>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<D, B> Buffers<D, B>
|
impl<D, B> Buffers<D, B>
|
||||||
|
|
|
@ -280,7 +280,7 @@ impl<A: AsRawFd + 'static> DrmSurface<A> {
|
||||||
.iter()
|
.iter()
|
||||||
.find(|handle| {
|
.find(|handle| {
|
||||||
// get information of that property
|
// get information of that property
|
||||||
if let Some(info) = self.get_property(**handle).ok() {
|
if let Ok(info) = self.get_property(**handle) {
|
||||||
// to find out, if we got the handle of the "IN_FORMATS" property ...
|
// to find out, if we got the handle of the "IN_FORMATS" property ...
|
||||||
if info.name().to_str().map(|x| x == "IN_FORMATS").unwrap_or(false) {
|
if info.name().to_str().map(|x| x == "IN_FORMATS").unwrap_or(false) {
|
||||||
// so we can use that to get formats
|
// so we can use that to get formats
|
||||||
|
|
|
@ -120,7 +120,7 @@ impl<'a> Debug for EGLPlatform<'a> {
|
||||||
/// Trait describing platform specific functionality to create a valid `EGLDisplay` using the `EGL_EXT_platform_base`(https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_platform_base.txt) extension.
|
/// Trait describing platform specific functionality to create a valid `EGLDisplay` using the `EGL_EXT_platform_base`(https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_platform_base.txt) extension.
|
||||||
pub trait EGLNativeDisplay: Send {
|
pub trait EGLNativeDisplay: Send {
|
||||||
/// List of supported platforms that can be used to create a display using [`eglGetPlatformDisplayEXT`](https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_platform_base.txt)
|
/// List of supported platforms that can be used to create a display using [`eglGetPlatformDisplayEXT`](https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_platform_base.txt)
|
||||||
fn supported_platforms<'a>(&'a self) -> Vec<EGLPlatform<'a>>;
|
fn supported_platforms(&self) -> Vec<EGLPlatform<'_>>;
|
||||||
|
|
||||||
/// Type of surfaces created
|
/// Type of surfaces created
|
||||||
fn surface_type(&self) -> ffi::EGLint {
|
fn surface_type(&self) -> ffi::EGLint {
|
||||||
|
@ -130,7 +130,7 @@ pub trait EGLNativeDisplay: Send {
|
||||||
|
|
||||||
#[cfg(feature = "backend_gbm")]
|
#[cfg(feature = "backend_gbm")]
|
||||||
impl<A: AsRawFd + Send + 'static> EGLNativeDisplay for GbmDevice<A> {
|
impl<A: AsRawFd + Send + 'static> EGLNativeDisplay for GbmDevice<A> {
|
||||||
fn supported_platforms<'a>(&'a self) -> Vec<EGLPlatform<'a>> {
|
fn supported_platforms(&self) -> Vec<EGLPlatform<'_>> {
|
||||||
vec![
|
vec![
|
||||||
// see: https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_platform_gbm.txt
|
// see: https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_platform_gbm.txt
|
||||||
egl_platform!(PLATFORM_GBM_KHR, self.as_raw(), &["EGL_KHR_platform_gbm"]),
|
egl_platform!(PLATFORM_GBM_KHR, self.as_raw(), &["EGL_KHR_platform_gbm"]),
|
||||||
|
@ -142,7 +142,7 @@ impl<A: AsRawFd + Send + 'static> EGLNativeDisplay for GbmDevice<A> {
|
||||||
|
|
||||||
#[cfg(feature = "backend_winit")]
|
#[cfg(feature = "backend_winit")]
|
||||||
impl EGLNativeDisplay for WinitWindow {
|
impl EGLNativeDisplay for WinitWindow {
|
||||||
fn supported_platforms<'a>(&'a self) -> Vec<EGLPlatform<'a>> {
|
fn supported_platforms(&self) -> Vec<EGLPlatform<'_>> {
|
||||||
if let Some(display) = self.wayland_display() {
|
if let Some(display) = self.wayland_display() {
|
||||||
vec![
|
vec![
|
||||||
// see: https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_platform_wayland.txt
|
// see: https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_platform_wayland.txt
|
||||||
|
|
|
@ -537,7 +537,7 @@ impl ImportShm for Gles2Renderer {
|
||||||
unsafe { self.gl.GenTextures(1, &mut tex) };
|
unsafe { self.gl.GenTextures(1, &mut tex) };
|
||||||
// new texture, upload in full
|
// new texture, upload in full
|
||||||
upload_full = true;
|
upload_full = true;
|
||||||
let texture = Rc::new(Gles2TextureInternal {
|
Rc::new(Gles2TextureInternal {
|
||||||
texture: tex,
|
texture: tex,
|
||||||
texture_kind: shader_idx,
|
texture_kind: shader_idx,
|
||||||
is_external: false,
|
is_external: false,
|
||||||
|
@ -546,8 +546,7 @@ impl ImportShm for Gles2Renderer {
|
||||||
height: height as u32,
|
height: height as u32,
|
||||||
egl_images: None,
|
egl_images: None,
|
||||||
destruction_callback_sender: self.destruction_callback_sender.clone(),
|
destruction_callback_sender: self.destruction_callback_sender.clone(),
|
||||||
});
|
})
|
||||||
texture
|
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -3,3 +3,15 @@
|
||||||
mod rectangle;
|
mod rectangle;
|
||||||
|
|
||||||
pub use self::rectangle::Rectangle;
|
pub use self::rectangle::Rectangle;
|
||||||
|
|
||||||
|
/// This resource is not managed by Smithay
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct UnmanagedResource;
|
||||||
|
|
||||||
|
impl std::fmt::Display for UnmanagedResource {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
f.write_str("This resource is not managed by Smithay.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::error::Error for UnmanagedResource {}
|
||||||
|
|
|
@ -7,8 +7,8 @@ use wayland_server::{
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
tree::{Location, SurfaceData},
|
tree::{Location, SurfaceData},
|
||||||
BufferAssignment, CompositorToken, Damage, Rectangle, RectangleKind, RegionAttributes, Role, RoleType,
|
AlreadyHasRole, BufferAssignment, CompositorToken, Damage, Rectangle, RectangleKind, RegionAttributes,
|
||||||
SubsurfaceRole, SurfaceEvent,
|
Role, RoleType, SubsurfaceRole, SurfaceEvent,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -65,11 +65,11 @@ impl<R> SurfaceImplem<R>
|
||||||
where
|
where
|
||||||
R: 'static,
|
R: 'static,
|
||||||
{
|
{
|
||||||
fn receive_surface_request<'a>(
|
fn receive_surface_request(
|
||||||
&mut self,
|
&mut self,
|
||||||
req: wl_surface::Request,
|
req: wl_surface::Request,
|
||||||
surface: wl_surface::WlSurface,
|
surface: wl_surface::WlSurface,
|
||||||
ddata: DispatchData<'a>,
|
ddata: DispatchData<'_>,
|
||||||
) {
|
) {
|
||||||
match req {
|
match req {
|
||||||
wl_surface::Request::Attach { buffer, x, y } => {
|
wl_surface::Request::Attach { buffer, x, y } => {
|
||||||
|
@ -196,7 +196,7 @@ where
|
||||||
{
|
{
|
||||||
subcompositor.quick_assign(move |subcompositor, request, _| match request {
|
subcompositor.quick_assign(move |subcompositor, request, _| match request {
|
||||||
wl_subcompositor::Request::GetSubsurface { id, surface, parent } => {
|
wl_subcompositor::Request::GetSubsurface { id, surface, parent } => {
|
||||||
if let Err(()) = SurfaceData::<R>::set_parent(&surface, &parent) {
|
if let Err(AlreadyHasRole) = SurfaceData::<R>::set_parent(&surface, &parent) {
|
||||||
subcompositor.as_ref().post_error(
|
subcompositor.as_ref().post_error(
|
||||||
wl_subcompositor::Error::BadSurface as u32,
|
wl_subcompositor::Error::BadSurface as u32,
|
||||||
"Surface already has a role.".into(),
|
"Surface already has a role.".into(),
|
||||||
|
|
|
@ -76,7 +76,7 @@ mod tree;
|
||||||
|
|
||||||
pub use self::tree::TraversalAction;
|
pub use self::tree::TraversalAction;
|
||||||
use self::{
|
use self::{
|
||||||
roles::{Role, RoleType, WrongRole},
|
roles::{AlreadyHasRole, Role, RoleType, WrongRole},
|
||||||
tree::SurfaceData,
|
tree::SurfaceData,
|
||||||
};
|
};
|
||||||
use crate::utils::Rectangle;
|
use crate::utils::Rectangle;
|
||||||
|
@ -433,7 +433,7 @@ impl<R: RoleType + 'static> CompositorToken<R> {
|
||||||
///
|
///
|
||||||
/// If the surface is not managed by the `CompositorGlobal` that provided this token, this
|
/// If the surface is not managed by the `CompositorGlobal` that provided this token, this
|
||||||
/// will panic (having more than one compositor is not supported).
|
/// will panic (having more than one compositor is not supported).
|
||||||
pub fn give_role<RoleData>(self, surface: &WlSurface) -> Result<(), ()>
|
pub fn give_role<RoleData>(self, surface: &WlSurface) -> Result<(), AlreadyHasRole>
|
||||||
where
|
where
|
||||||
R: Role<RoleData>,
|
R: Role<RoleData>,
|
||||||
RoleData: Default,
|
RoleData: Default,
|
||||||
|
|
|
@ -92,6 +92,30 @@
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct WrongRole;
|
pub struct WrongRole;
|
||||||
|
|
||||||
|
impl std::fmt::Display for WrongRole {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
f.write_str("Wrong role for surface.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::error::Error for WrongRole {}
|
||||||
|
|
||||||
|
/// An error type signifying that the surface already has a role and
|
||||||
|
/// cannot be assigned an other
|
||||||
|
///
|
||||||
|
/// Generated if you attempt a role operation on a surface that does
|
||||||
|
/// not have the role you asked for.
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct AlreadyHasRole;
|
||||||
|
|
||||||
|
impl std::fmt::Display for AlreadyHasRole {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
f.write_str("Surface already has a role.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::error::Error for AlreadyHasRole {}
|
||||||
|
|
||||||
/// A trait representing a type that can manage surface roles
|
/// A trait representing a type that can manage surface roles
|
||||||
pub trait RoleType {
|
pub trait RoleType {
|
||||||
/// Check if the associated surface has a role
|
/// Check if the associated surface has a role
|
||||||
|
@ -126,11 +150,11 @@ pub trait Role<R>: RoleType {
|
||||||
/// Set the role for the associated surface with default associated data
|
/// Set the role for the associated surface with default associated data
|
||||||
///
|
///
|
||||||
/// Fails if the surface already has a role
|
/// Fails if the surface already has a role
|
||||||
fn set(&mut self) -> Result<(), ()>
|
fn set(&mut self) -> Result<(), AlreadyHasRole>
|
||||||
where
|
where
|
||||||
R: Default,
|
R: Default,
|
||||||
{
|
{
|
||||||
self.set_with(Default::default()).map_err(|_| ())
|
self.set_with(Default::default()).map_err(|_| AlreadyHasRole)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the role for the associated surface with given data
|
/// Set the role for the associated surface with given data
|
||||||
|
|
|
@ -127,7 +127,7 @@ impl<R: RoleType + 'static> SurfaceData<R> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Register that this surface has a role, fails if it already has one
|
/// Register that this surface has a role, fails if it already has one
|
||||||
pub fn give_role<RoleData>(surface: &WlSurface) -> Result<(), ()>
|
pub fn give_role<RoleData>(surface: &WlSurface) -> Result<(), AlreadyHasRole>
|
||||||
where
|
where
|
||||||
R: Role<RoleData>,
|
R: Role<RoleData>,
|
||||||
RoleData: Default,
|
RoleData: Default,
|
||||||
|
@ -215,12 +215,12 @@ impl<R: RoleType + Role<SubsurfaceRole> + 'static> SurfaceData<R> {
|
||||||
///
|
///
|
||||||
/// if this surface already has a role, does nothing and fails, otherwise
|
/// if this surface already has a role, does nothing and fails, otherwise
|
||||||
/// its role is now to be a subsurface
|
/// its role is now to be a subsurface
|
||||||
pub fn set_parent(child: &WlSurface, parent: &WlSurface) -> Result<(), ()> {
|
pub fn set_parent(child: &WlSurface, parent: &WlSurface) -> Result<(), AlreadyHasRole> {
|
||||||
debug_assert!(child.as_ref().is_alive());
|
debug_assert!(child.as_ref().is_alive());
|
||||||
debug_assert!(parent.as_ref().is_alive());
|
debug_assert!(parent.as_ref().is_alive());
|
||||||
// ensure the child is not already a parent of the parent
|
// ensure the child is not already a parent of the parent
|
||||||
if Self::is_ancestor(child, parent) {
|
if Self::is_ancestor(child, parent) {
|
||||||
return Err(());
|
return Err(AlreadyHasRole);
|
||||||
}
|
}
|
||||||
|
|
||||||
// change child's parent
|
// change child's parent
|
||||||
|
|
|
@ -44,9 +44,9 @@ pub(crate) fn implement_data_source(src: Main<WlDataSource>) -> WlDataSource {
|
||||||
pub fn with_source_metadata<T, F: FnOnce(&SourceMetadata) -> T>(
|
pub fn with_source_metadata<T, F: FnOnce(&SourceMetadata) -> T>(
|
||||||
source: &WlDataSource,
|
source: &WlDataSource,
|
||||||
f: F,
|
f: F,
|
||||||
) -> Result<T, ()> {
|
) -> Result<T, crate::utils::UnmanagedResource> {
|
||||||
match source.as_ref().user_data().get::<RefCell<SourceMetadata>>() {
|
match source.as_ref().user_data().get::<RefCell<SourceMetadata>>() {
|
||||||
Some(data) => Ok(f(&data.borrow())),
|
Some(data) => Ok(f(&data.borrow())),
|
||||||
None => Err(()),
|
None => Err(crate::utils::UnmanagedResource),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -251,7 +251,7 @@ fn implement_dnd_data_offer(
|
||||||
match req {
|
match req {
|
||||||
Request::Accept { mime_type, .. } => {
|
Request::Accept { mime_type, .. } => {
|
||||||
if let Some(mtype) = mime_type {
|
if let Some(mtype) = mime_type {
|
||||||
if let Err(()) = with_source_metadata(&source, |meta| {
|
if let Err(crate::utils::UnmanagedResource) = with_source_metadata(&source, |meta| {
|
||||||
data.accepted = meta.mime_types.contains(&mtype);
|
data.accepted = meta.mime_types.contains(&mtype);
|
||||||
}) {
|
}) {
|
||||||
data.accepted = false;
|
data.accepted = false;
|
||||||
|
|
|
@ -259,7 +259,7 @@ where
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut buf = Dmabuf::new(
|
let mut buf = Dmabuf::builder(
|
||||||
width as u32,
|
width as u32,
|
||||||
height as u32,
|
height as u32,
|
||||||
format,
|
format,
|
||||||
|
@ -277,7 +277,7 @@ where
|
||||||
None => {
|
None => {
|
||||||
params.as_ref().post_error(
|
params.as_ref().post_error(
|
||||||
ParamError::Incomplete as u32,
|
ParamError::Incomplete as u32,
|
||||||
format!("Provided buffer is incomplete, it has zero planes"),
|
"Provided buffer is incomplete, it has zero planes".to_string(),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -305,6 +305,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::clippy::too_many_arguments)]
|
||||||
fn create_immed<'a>(
|
fn create_immed<'a>(
|
||||||
&mut self,
|
&mut self,
|
||||||
params: &BufferParams,
|
params: &BufferParams,
|
||||||
|
@ -348,7 +349,7 @@ where
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut buf = Dmabuf::new(
|
let mut buf = Dmabuf::builder(
|
||||||
width as u32,
|
width as u32,
|
||||||
height as u32,
|
height as u32,
|
||||||
format,
|
format,
|
||||||
|
@ -366,7 +367,7 @@ where
|
||||||
None => {
|
None => {
|
||||||
params.as_ref().post_error(
|
params.as_ref().post_error(
|
||||||
ParamError::Incomplete as u32,
|
ParamError::Incomplete as u32,
|
||||||
format!("Provided buffer is incomplete, it has zero planes"),
|
"Provided buffer is incomplete, it has zero planes".to_string(),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@
|
||||||
//! the contents of sync_state
|
//! the contents of sync_state
|
||||||
//! */
|
//! */
|
||||||
//! },
|
//! },
|
||||||
//! Err(()) => {
|
//! Err(NoExplicitSync) => {
|
||||||
//! /* This surface is not explicitly synchronized, nothing more to do
|
//! /* This surface is not explicitly synchronized, nothing more to do
|
||||||
//! */
|
//! */
|
||||||
//! }
|
//! }
|
||||||
|
@ -155,6 +155,18 @@ pub enum ExplicitSyncError {
|
||||||
NoBuffer,
|
NoBuffer,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// This surface is not explicitly synchronized
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct NoExplicitSync;
|
||||||
|
|
||||||
|
impl std::fmt::Display for NoExplicitSync {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
f.write_str("The surface is not explicitly synchronized.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::error::Error for NoExplicitSync {}
|
||||||
|
|
||||||
/// Retrieve the explicit synchronization state commited by the client
|
/// Retrieve the explicit synchronization state commited by the client
|
||||||
///
|
///
|
||||||
/// This state can contain an acquire fence and a release object, for synchronization (see module-level docs).
|
/// This state can contain an acquire fence and a release object, for synchronization (see module-level docs).
|
||||||
|
@ -163,12 +175,14 @@ pub enum ExplicitSyncError {
|
||||||
/// should always call it on surface commit to avoid getting out-of-sync with the client.
|
/// should always call it on surface commit to avoid getting out-of-sync with the client.
|
||||||
///
|
///
|
||||||
/// This function returns an error if the client has not setup explicit synchronization for this surface.
|
/// This function returns an error if the client has not setup explicit synchronization for this surface.
|
||||||
pub fn get_explicit_synchronization_state(attrs: &mut SurfaceAttributes) -> Result<ExplicitSyncState, ()> {
|
pub fn get_explicit_synchronization_state(
|
||||||
|
attrs: &mut SurfaceAttributes,
|
||||||
|
) -> Result<ExplicitSyncState, NoExplicitSync> {
|
||||||
attrs
|
attrs
|
||||||
.user_data
|
.user_data
|
||||||
.get::<ESUserData>()
|
.get::<ESUserData>()
|
||||||
.and_then(|s| s.take_state())
|
.and_then(|s| s.take_state())
|
||||||
.ok_or(())
|
.ok_or(NoExplicitSync)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Send a synchronization error to a client
|
/// Send a synchronization error to a client
|
||||||
|
|
|
@ -192,7 +192,7 @@ fn launch<Data: Any>(inner: &Rc<RefCell<Inner<Data>>>) -> std::io::Result<()> {
|
||||||
client.data_map().insert_if_missing(|| idle_inner.clone());
|
client.data_map().insert_if_missing(|| idle_inner.clone());
|
||||||
client.add_destructor(Filter::new(|e: Arc<_>, _, _| client_destroy::<Data>(&e)));
|
client.add_destructor(Filter::new(|e: Arc<_>, _, _| client_destroy::<Data>(&e)));
|
||||||
|
|
||||||
instance.wayland_client = Some(client.clone());
|
instance.wayland_client = Some(client);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue