clippy fixes
This commit is contained in:
parent
e329adcbd8
commit
36bf5618ed
|
@ -1,3 +1,5 @@
|
|||
#![allow(clippy::too_many_arguments)]
|
||||
|
||||
use std::{
|
||||
cell::RefCell,
|
||||
rc::Rc,
|
||||
|
|
|
@ -290,7 +290,7 @@ fn process_keyboard_shortcut(modifiers: ModifiersState, keysym: Keysym) -> KeyAc
|
|||
// ctrl+alt+backspace = quit
|
||||
// logo + q = quit
|
||||
KeyAction::Quit
|
||||
} else if keysym >= xkb::KEY_XF86Switch_VT_1 && keysym <= xkb::KEY_XF86Switch_VT_12 {
|
||||
} else if (xkb::KEY_XF86Switch_VT_1..=xkb::KEY_XF86Switch_VT_12).contains(&keysym) {
|
||||
// VTSwicth
|
||||
KeyAction::VtSwitch((keysym - xkb::KEY_XF86Switch_VT_1 + 1) as i32)
|
||||
} else if modifiers.logo && keysym == xkb::KEY_Return {
|
||||
|
|
|
@ -436,7 +436,7 @@ impl<Data: 'static> UdevHandlerImpl<Data> {
|
|||
self.logger.clone(),
|
||||
),
|
||||
GbmDevice::new(
|
||||
fd.clone()
|
||||
fd
|
||||
),
|
||||
)
|
||||
}
|
||||
|
@ -513,7 +513,7 @@ impl<Data: 'static> UdevHandlerImpl<Data> {
|
|||
window_map: self.window_map.clone(),
|
||||
output_map: self.output_map.clone(),
|
||||
pointer_location: self.pointer_location.clone(),
|
||||
pointer_image: pointer_image,
|
||||
pointer_image,
|
||||
cursor_status: self.cursor_status.clone(),
|
||||
dnd_icon: self.dnd_icon.clone(),
|
||||
logger: self.logger.clone(),
|
||||
|
@ -694,14 +694,12 @@ impl DrmRenderer {
|
|||
match err {
|
||||
SwapBuffersError::AlreadySwapped => false,
|
||||
SwapBuffersError::TemporaryFailure(err) => {
|
||||
match err.downcast_ref::<DrmError>() {
|
||||
Some(&DrmError::DeviceInactive) => false,
|
||||
!matches!(err.downcast_ref::<DrmError>(),
|
||||
Some(&DrmError::DeviceInactive) |
|
||||
Some(&DrmError::Access {
|
||||
source: drm::SystemError::PermissionDenied,
|
||||
..
|
||||
}) => false,
|
||||
_ => true,
|
||||
}
|
||||
}))
|
||||
}
|
||||
SwapBuffersError::ContextLost(err) => panic!("Rendering loop lost: {}", err),
|
||||
};
|
||||
|
@ -751,6 +749,7 @@ impl DrmRenderer {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn render_surface(
|
||||
surface: &mut RenderSurface,
|
||||
texture_destruction_callback: &mpsc::Sender<Gles2Texture>,
|
||||
|
@ -795,7 +794,7 @@ impl DrmRenderer {
|
|||
width: width as i32,
|
||||
height: height as i32,
|
||||
}),
|
||||
compositor_token.clone(),
|
||||
*compositor_token,
|
||||
logger,
|
||||
)?;
|
||||
|
||||
|
@ -810,7 +809,7 @@ impl DrmRenderer {
|
|||
{
|
||||
if let Some(ref wl_surface) = dnd_icon.as_ref() {
|
||||
if wl_surface.as_ref().is_alive() {
|
||||
draw_dnd_icon(surface, device_id, texture_destruction_callback, buffer_utils, wl_surface, (ptr_x, ptr_y), compositor_token.clone(), logger)?;
|
||||
draw_dnd_icon(surface, device_id, texture_destruction_callback, buffer_utils, wl_surface, (ptr_x, ptr_y), *compositor_token, logger)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -833,7 +832,7 @@ impl DrmRenderer {
|
|||
buffer_utils,
|
||||
wl_surface,
|
||||
(ptr_x, ptr_y),
|
||||
compositor_token.clone(),
|
||||
*compositor_token,
|
||||
logger,
|
||||
)?;
|
||||
} else {
|
||||
|
|
|
@ -116,7 +116,7 @@ impl Dmabuf {
|
|||
|
||||
impl WeakDmabuf {
|
||||
pub fn upgrade(&self) -> Option<Dmabuf> {
|
||||
self.0.upgrade().map(|internal| Dmabuf(internal))
|
||||
self.0.upgrade().map(Dmabuf)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,14 +54,16 @@ impl<T> std::convert::TryFrom<GbmBuffer<T>> for Dmabuf {
|
|||
//TODO switch to gbm_bo_get_plane_fd when it lands
|
||||
let mut iter = (0i32..planes).map(|i| buf.handle_for_plane(i));
|
||||
let first = iter.next().expect("Encountered a buffer with zero planes");
|
||||
if iter.try_fold(first, |first, next| {
|
||||
// check that all handles are the same
|
||||
let handle = iter.try_fold(first, |first, next| {
|
||||
if let (Ok(next), Ok(first)) = (next, first) {
|
||||
if unsafe { next.u64_ == first.u64_ } {
|
||||
return Some(Ok(first));
|
||||
}
|
||||
}
|
||||
None
|
||||
}).is_none() {
|
||||
});
|
||||
if handle.is_none() {
|
||||
// GBM is lacking a function to get a FD for a given plane. Instead,
|
||||
// check all planes have the same handle. We can't use
|
||||
// drmPrimeHandleToFD because that messes up handle ref'counting in
|
||||
|
|
|
@ -103,7 +103,7 @@ where
|
|||
}
|
||||
|
||||
pub fn acquire(&mut self) -> Result<Option<Slot<D, U>>, SwapchainError<E1, E2>> {
|
||||
if let Some(free_slot) = self.slots.iter_mut().filter(|s| !s.acquired.load(Ordering::SeqCst)).next() {
|
||||
if let Some(free_slot) = self.slots.iter_mut().find(|s| !s.acquired.load(Ordering::SeqCst)) {
|
||||
if free_slot.buffer.is_none() {
|
||||
free_slot.buffer = Arc::new(Some(
|
||||
self.allocator
|
||||
|
|
|
@ -60,22 +60,21 @@ pub enum Error {
|
|||
TestFailed(crtc::Handle),
|
||||
}
|
||||
|
||||
impl Into<SwapBuffersError> for Error {
|
||||
fn into(self) -> SwapBuffersError {
|
||||
match self {
|
||||
impl From<Error> for SwapBuffersError {
|
||||
fn from(err: Error) -> SwapBuffersError {
|
||||
match err {
|
||||
x @ Error::DeviceInactive => SwapBuffersError::TemporaryFailure(Box::new(x)),
|
||||
Error::Access {
|
||||
errmsg, dev, source, ..
|
||||
} if match source {
|
||||
drm::SystemError::PermissionDenied => true,
|
||||
} if matches!(source,
|
||||
drm::SystemError::PermissionDenied |
|
||||
drm::SystemError::Unknown {
|
||||
errno: nix::errno::Errno::EBUSY,
|
||||
} => true,
|
||||
} |
|
||||
drm::SystemError::Unknown {
|
||||
errno: nix::errno::Errno::EINTR,
|
||||
} => true,
|
||||
_ => false,
|
||||
} =>
|
||||
}
|
||||
) =>
|
||||
{
|
||||
SwapBuffersError::TemporaryFailure(Box::new(Error::Access { errmsg, dev, source }))
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ where
|
|||
E2: std::error::Error + 'static,
|
||||
E3: std::error::Error + 'static,
|
||||
{
|
||||
#[allow(clippy::type_complexity)]
|
||||
pub fn new<L: Into<Option<::slog::Logger>>>(drm: DrmSurface<D>, allocator: A, renderer: R, log: L) -> Result<DrmRenderSurface<D, A, R, B>, Error<E1, E2, E3>>
|
||||
{
|
||||
// we cannot simply pick the first supported format of the intersection of *all* formats, because:
|
||||
|
@ -102,6 +103,7 @@ where
|
|||
DrmRenderSurface::new_internal(drm, allocator, renderer, iter, logger)
|
||||
}
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
fn new_internal(drm: Arc<DrmSurface<D>>, allocator: A, mut renderer: R, mut formats: impl Iterator<Item=Format>, logger: ::slog::Logger) -> Result<DrmRenderSurface<D, A, R, B>, Error<E1, E2, E3>>
|
||||
{
|
||||
let format = formats.next().ok_or(Error::NoSupportedPlaneFormat)?;
|
||||
|
|
|
@ -34,6 +34,7 @@ pub struct AtomicDrmSurface<A: AsRawFd + 'static> {
|
|||
}
|
||||
|
||||
impl<A: AsRawFd + 'static> AtomicDrmSurface<A> {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
fd: Arc<DrmDeviceInternal<A>>,
|
||||
active: Arc<AtomicBool>,
|
||||
|
|
|
@ -280,9 +280,6 @@ pub struct PixelFormatRequirements {
|
|||
/// Contains the minimum number of samples per pixel in the color, depth and stencil buffers.
|
||||
/// `None` means "don't care". Default is `None`. A value of `Some(0)` indicates that multisampling must not be enabled.
|
||||
pub multisampling: Option<u16>,
|
||||
/// If `true`, only stereoscopic formats will be considered. If `false`, only non-stereoscopic formats.
|
||||
/// The default is `false`.
|
||||
pub stereoscopy: bool,
|
||||
}
|
||||
|
||||
impl Default for PixelFormatRequirements {
|
||||
|
@ -296,14 +293,13 @@ impl Default for PixelFormatRequirements {
|
|||
stencil_bits: Some(8),
|
||||
double_buffer: Some(true),
|
||||
multisampling: None,
|
||||
stereoscopy: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl PixelFormatRequirements {
|
||||
/// Append the requirements to the given attribute list
|
||||
pub fn create_attributes(&self, out: &mut Vec<c_int>, logger: &slog::Logger) -> Result<(), ()> {
|
||||
pub fn create_attributes(&self, out: &mut Vec<c_int>, logger: &slog::Logger) {
|
||||
if let Some(hardware_accelerated) = self.hardware_accelerated {
|
||||
out.push(ffi::egl::CONFIG_CAVEAT as c_int);
|
||||
out.push(if hardware_accelerated {
|
||||
|
@ -358,12 +354,5 @@ impl PixelFormatRequirements {
|
|||
out.push(ffi::egl::SAMPLES as c_int);
|
||||
out.push(multisampling as c_int);
|
||||
}
|
||||
|
||||
if self.stereoscopy {
|
||||
error!(logger, "Stereoscopy is currently unsupported (sorry!)");
|
||||
return Err(());
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -217,9 +217,7 @@ impl EGLDisplay {
|
|||
}
|
||||
};
|
||||
|
||||
reqs.create_attributes(&mut out, &self.logger)
|
||||
.map_err(|()| Error::NoAvailablePixelFormat)?;
|
||||
|
||||
reqs.create_attributes(&mut out, &self.logger);
|
||||
out.push(ffi::egl::NONE as c_int);
|
||||
out
|
||||
};
|
||||
|
@ -363,10 +361,8 @@ impl EGLDisplay {
|
|||
return Err(Error::EglExtensionNotSupported(&["EGL_KHR_image_base", "EGL_EXT_image_dma_buf_import"]));
|
||||
}
|
||||
|
||||
if dmabuf.has_modifier() {
|
||||
if !self.extensions.iter().any(|s| s == "EGL_EXT_image_dma_buf_import_modifiers") {
|
||||
if dmabuf.has_modifier() && !self.extensions.iter().any(|s| s == "EGL_EXT_image_dma_buf_import_modifiers") {
|
||||
return Err(Error::EglExtensionNotSupported(&["EGL_EXT_image_dma_buf_import_modifiers"]));
|
||||
}
|
||||
};
|
||||
|
||||
let mut out: Vec<c_int> = Vec::with_capacity(50);
|
||||
|
@ -515,11 +511,11 @@ fn get_dmabuf_formats(display: &ffi::egl::types::EGLDisplay, extensions: &[Strin
|
|||
if num == 0 {
|
||||
texture_formats.insert(DrmFormat {
|
||||
code: fourcc,
|
||||
modifier: Modifier::Invalid.into()
|
||||
modifier: Modifier::Invalid
|
||||
});
|
||||
render_formats.insert(DrmFormat {
|
||||
code: fourcc,
|
||||
modifier: Modifier::Invalid.into()
|
||||
modifier: Modifier::Invalid
|
||||
});
|
||||
} else {
|
||||
let mut mods: Vec<u64> = Vec::with_capacity(num as usize);
|
||||
|
@ -650,10 +646,11 @@ impl EGLBufferReader {
|
|||
|
||||
let mut images = Vec::with_capacity(format.num_planes());
|
||||
for i in 0..format.num_planes() {
|
||||
let mut out = Vec::with_capacity(3);
|
||||
out.push(ffi::egl::WAYLAND_PLANE_WL as i32);
|
||||
out.push(i as i32);
|
||||
out.push(ffi::egl::NONE as i32);
|
||||
let out = [
|
||||
ffi::egl::WAYLAND_PLANE_WL as i32,
|
||||
i as i32,
|
||||
ffi::egl::NONE as i32,
|
||||
];
|
||||
|
||||
images.push({
|
||||
wrap_egl_call(|| unsafe {
|
||||
|
|
|
@ -559,11 +559,11 @@ impl Renderer for Gles2Renderer {
|
|||
Ok(texture)
|
||||
}
|
||||
|
||||
fn destroy_texture(&mut self, mut texture: Self::TextureId) -> Result<(), Self::Error> {
|
||||
fn destroy_texture(&mut self, texture: Self::TextureId) -> Result<(), Self::Error> {
|
||||
self.make_current()?;
|
||||
|
||||
unsafe {
|
||||
self.gl.DeleteTextures(1, &mut texture.texture);
|
||||
self.gl.DeleteTextures(1, &texture.texture);
|
||||
}
|
||||
self.egl.unbind()?;
|
||||
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
#![warn(missing_docs, rust_2018_idioms)]
|
||||
// Allow acronyms like EGL
|
||||
#![allow(clippy::upper_case_acronyms)]
|
||||
|
||||
//! **Smithay: the Wayland compositor smithy**
|
||||
//!
|
||||
//! Most entry points in the modules can take an optional [`slog::Logger`](::slog::Logger) as argument
|
||||
|
@ -7,9 +10,6 @@
|
|||
//! `log` crate. If not, the logs will discarded. This cargo feature is part of the default set of
|
||||
//! features of Smithay.
|
||||
|
||||
// `error_chain!` can recurse deeply
|
||||
#![recursion_limit = "1024"]
|
||||
|
||||
#[cfg_attr(feature = "backend_session", macro_use)]
|
||||
#[doc(hidden)]
|
||||
pub extern crate nix;
|
||||
|
|
Loading…
Reference in New Issue