Apply a bunch of clippy suggestions
This commit is contained in:
parent
b41cf9c4c3
commit
4946017c0c
|
@ -114,7 +114,7 @@ impl DrmBackend {
|
|||
|surface| {
|
||||
// create an egl surface from the gbm one
|
||||
debug!(log, "Creating EGLSurface");
|
||||
let egl_surface = context.egl.create_surface(&surface)?;
|
||||
let egl_surface = context.egl.create_surface(surface)?;
|
||||
|
||||
// make it active for the first `crtc::set`
|
||||
// (which is needed before the first page_flip)
|
||||
|
@ -270,7 +270,7 @@ impl DrmBackend {
|
|||
/// Other errors might occur.
|
||||
pub fn use_mode(&mut self, mode: Mode) -> Result<()> {
|
||||
// check the connectors
|
||||
for connector in self.connectors.iter() {
|
||||
for connector in &self.connectors {
|
||||
if !connector::Info::load_from_device(self.graphics.head().head().head(), *connector)
|
||||
.chain_err(|| {
|
||||
ErrorKind::DrmDev(format!("{:?}", self.graphics.head().head().head()))
|
||||
|
@ -318,7 +318,7 @@ impl DrmBackend {
|
|||
|surface| {
|
||||
// create an egl surface from the gbm one
|
||||
debug!(logger_ref, "Creating EGLSurface");
|
||||
let egl_surface = graphics.context.egl.create_surface(&surface)?;
|
||||
let egl_surface = graphics.context.egl.create_surface(surface)?;
|
||||
|
||||
// make it active for the first `crtc::set`
|
||||
// (which is needed before the first page_flip)
|
||||
|
@ -383,13 +383,12 @@ impl Drop for DrmBackend {
|
|||
self.graphics.rent_all_mut(|graphics| {
|
||||
if let Some(fb) = graphics.gbm.surface.rent(|egl| {
|
||||
if let Some(mut next) = egl.buffers.next_buffer.take() {
|
||||
return next.take_userdata();
|
||||
next.take_userdata()
|
||||
} else if let Ok(mut next) = graphics.gbm.surface.head().lock_front_buffer() {
|
||||
next.take_userdata()
|
||||
} else {
|
||||
if let Ok(mut next) = graphics.gbm.surface.head().lock_front_buffer() {
|
||||
return next.take_userdata();
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
}) {
|
||||
// ignore failure at this point
|
||||
let _ = framebuffer::destroy(&*graphics.context.devices.drm, fb.handle());
|
||||
|
|
|
@ -397,7 +397,7 @@ impl<B: From<DrmBackend> + Borrow<DrmBackend> + 'static> DrmDevice<B> {
|
|||
let connectors = connectors.into();
|
||||
|
||||
// check if we have an encoder for every connector and the mode mode
|
||||
for connector in connectors.iter() {
|
||||
for connector in &connectors {
|
||||
let con_info = connector::Info::load_from_device(self.context.head().head(), *connector)
|
||||
.chain_err(|| {
|
||||
ErrorKind::DrmDev(format!("{:?}", self.context.head().head()))
|
||||
|
@ -471,7 +471,7 @@ pub trait DrmHandler<B: Borrow<DrmBackend> + 'static> {
|
|||
fn error(&mut self, evlh: &mut EventLoopHandle, device: &mut DrmDevice<B>, error: DrmError);
|
||||
}
|
||||
|
||||
/// Bind a `DrmDevice` to an EventLoop,
|
||||
/// Bind a `DrmDevice` to an `EventLoop`,
|
||||
///
|
||||
/// This will cause it to recieve events and feed them into an `DrmHandler`
|
||||
pub fn drm_device_bind<B, H>(evlh: &mut EventLoopHandle, device: DrmDevice<B>, handler: H)
|
||||
|
@ -500,8 +500,7 @@ where
|
|||
let events = crtc::receive_events(dev);
|
||||
match events {
|
||||
Ok(events) => for event in events {
|
||||
match event {
|
||||
crtc::Event::PageFlip(event) => {
|
||||
if let crtc::Event::PageFlip(event) = event {
|
||||
let token = dev.backends.get(&event.crtc).cloned();
|
||||
if let Some(token) = token {
|
||||
// we can now unlock the buffer
|
||||
|
@ -511,10 +510,8 @@ where
|
|||
handler.ready(evlh, dev, &token, event.frame, event.duration);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
},
|
||||
Err(err) => return handler.error(evlh, dev, err),
|
||||
Err(err) => handler.error(evlh, dev, err),
|
||||
};
|
||||
},
|
||||
error: |evlh, id, _, error| {
|
||||
|
|
|
@ -640,7 +640,7 @@ impl<'a, T: NativeSurface> EGLContext<'a, T> {
|
|||
|
||||
let mut context_attributes = Vec::with_capacity(10);
|
||||
|
||||
if egl_version >= (1, 5) || extensions.iter().any(|s| s == &"EGL_KHR_create_context") {
|
||||
if egl_version >= (1, 5) || extensions.iter().any(|s| *s == "EGL_KHR_create_context") {
|
||||
trace!(log, "Setting CONTEXT_MAJOR_VERSION to {}", version.0);
|
||||
context_attributes.push(ffi::egl::CONTEXT_MAJOR_VERSION as i32);
|
||||
context_attributes.push(version.0 as i32);
|
||||
|
@ -728,8 +728,8 @@ impl<'a, T: NativeSurface> EGLContext<'a, T> {
|
|||
self.display,
|
||||
self.config_id,
|
||||
match surface {
|
||||
NativeSurfacePtr::X11(ptr) => ptr,
|
||||
NativeSurfacePtr::Wayland(ptr) => ptr,
|
||||
NativeSurfacePtr::X11(ptr) |
|
||||
NativeSurfacePtr::Wayland(ptr) |
|
||||
NativeSurfacePtr::Gbm(ptr) => ptr,
|
||||
},
|
||||
self.surface_attributes.as_ptr(),
|
||||
|
@ -743,7 +743,7 @@ impl<'a, T: NativeSurface> EGLContext<'a, T> {
|
|||
debug!(self.logger, "EGL surface successfully created");
|
||||
|
||||
Ok(EGLSurface {
|
||||
context: &self,
|
||||
context: self,
|
||||
surface: egl_surface,
|
||||
keep,
|
||||
_lifetime_surface: PhantomData,
|
||||
|
@ -894,9 +894,9 @@ impl fmt::Display for SwapBuffersError {
|
|||
|
||||
impl error::Error for SwapBuffersError {
|
||||
fn description(&self) -> &str {
|
||||
match self {
|
||||
&SwapBuffersError::ContextLost => "The context has been lost, it needs to be recreated",
|
||||
&SwapBuffersError::AlreadySwapped => {
|
||||
match *self {
|
||||
SwapBuffersError::ContextLost => "The context has been lost, it needs to be recreated",
|
||||
SwapBuffersError::AlreadySwapped => {
|
||||
"Buffers are already swapped, swap_buffers was called too many times"
|
||||
}
|
||||
}
|
||||
|
@ -987,7 +987,7 @@ pub struct PixelFormat {
|
|||
pub srgb: bool,
|
||||
}
|
||||
|
||||
/// Trait that describes objects that have an OpenGl context
|
||||
/// Trait that describes objects that have an OpenGL context
|
||||
/// and can be used to render upon
|
||||
pub trait EGLGraphicsBackend: GraphicsBackend {
|
||||
/// Swaps buffers at the end of a frame.
|
||||
|
|
|
@ -618,8 +618,8 @@ impl InputBackend for WinitInputBackend {
|
|||
let mut handler = self.handler.as_mut();
|
||||
let logger = &self.logger;
|
||||
|
||||
self.events_loop.poll_events(move |event| match event {
|
||||
Event::WindowEvent { event, .. } => {
|
||||
self.events_loop.poll_events(move |event| {
|
||||
if let Event::WindowEvent { event, .. } = event {
|
||||
match (event, handler.as_mut()) {
|
||||
(WindowEvent::Resized(x, y), _) => {
|
||||
trace!(logger, "Resizing window to {:?}", (x, y));
|
||||
|
@ -816,8 +816,6 @@ impl InputBackend for WinitInputBackend {
|
|||
}
|
||||
*time_counter += 1;
|
||||
}
|
||||
Event::DeviceEvent { .. } => {}
|
||||
_ => {}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ impl<U, R, ID> Clone for SurfaceIData<U, R, ID> {
|
|||
fn clone(&self) -> SurfaceIData<U, R, ID> {
|
||||
SurfaceIData {
|
||||
log: self.log.clone(),
|
||||
implem: self.implem.clone(),
|
||||
implem: self.implem,
|
||||
idata: self.idata.clone(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
//! the details of what it enables you.
|
||||
//!
|
||||
//! The surface metadata is held in the `SurfaceAttributes` struct. In contains double-buffered
|
||||
//! state pending from the client as defined by the protocol for wl_surface, as well as your
|
||||
//! state pending from the client as defined by the protocol for `wl_surface`, as well as your
|
||||
//! user-defined type holding any data you need to have associated with a struct. See its
|
||||
//! documentation for details.
|
||||
//!
|
||||
|
@ -240,7 +240,7 @@ impl Default for RegionAttributes {
|
|||
/// A Compositor global token
|
||||
///
|
||||
/// This token can be cloned at will, and is the entry-point to
|
||||
/// access data associated with the wl_surface and wl_region managed
|
||||
/// access data associated with the `wl_surface` and `wl_region` managed
|
||||
/// by the `CompositorGlobal` that provided it.
|
||||
pub struct CompositorToken<U, R, ID> {
|
||||
_data: ::std::marker::PhantomData<*mut U>,
|
||||
|
@ -524,7 +524,7 @@ impl<U: 'static, R: RoleType + 'static, ID: 'static> CompositorToken<U, R, ID> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Create new wl_compositor and wl_subcompositor globals.
|
||||
/// Create new `wl_compositor` and `wl_subcompositor` globals.
|
||||
///
|
||||
/// The globals are directly registered into the eventloop, and this function
|
||||
/// returns a `CompositorToken` which you'll need access the data associated to
|
||||
|
|
|
@ -102,9 +102,9 @@ pub trait RoleType {
|
|||
fn has_role(&self) -> bool;
|
||||
}
|
||||
|
||||
/// A trait representing the capability of a RoleType to handle a given role
|
||||
/// A trait representing the capability of a `RoleType` to handle a given role
|
||||
///
|
||||
/// This trait allows to interact with the different roles a RoleType can
|
||||
/// This trait allows to interact with the different roles a `RoleType` can
|
||||
/// handle.
|
||||
///
|
||||
/// This trait is meant to be used generically, for example, to retrieve the
|
||||
|
|
|
@ -21,8 +21,8 @@ use wayland_server::protocol::wl_surface;
|
|||
/// have a failure case to forbid this. Note that if any node in such a graph does not
|
||||
/// have a parent, then the graph is a tree and this node is its root.
|
||||
///
|
||||
/// All the methods here are unsafe, because they assume the provided wl_surface object
|
||||
/// is correctly initialized regarding its user_data.
|
||||
/// All the methods here are unsafe, because they assume the provided `wl_surface` object
|
||||
/// is correctly initialized regarding its `user_data`.
|
||||
pub struct SurfaceData<U, R> {
|
||||
parent: Option<wl_surface::WlSurface>,
|
||||
children: Vec<wl_surface::WlSurface>,
|
||||
|
@ -369,13 +369,12 @@ impl<U: 'static, R: 'static> SurfaceData<U, R> {
|
|||
let mut data_guard = data_mutex.lock().unwrap();
|
||||
let data_guard = &mut *data_guard;
|
||||
// call the callback on ourselves
|
||||
match f(
|
||||
if let TraversalAction::DoChildren(t) = f(
|
||||
root,
|
||||
&mut data_guard.attributes,
|
||||
&mut data_guard.role,
|
||||
&initial,
|
||||
) {
|
||||
TraversalAction::DoChildren(t) => {
|
||||
// loop over children
|
||||
if reverse {
|
||||
for c in data_guard.children.iter().rev() {
|
||||
|
@ -391,7 +390,5 @@ impl<U: 'static, R: 'static> SurfaceData<U, R> {
|
|||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -267,7 +267,7 @@ impl Output {
|
|||
|
||||
/// Chech is given wl_output instance is managed by this `Output`.
|
||||
pub fn owns(&self, output: &wl_output::WlOutput) -> bool {
|
||||
self.instances.iter().find(|&o| o.equals(output)).is_some()
|
||||
self.instances.iter().any(|o| o.equals(output))
|
||||
}
|
||||
|
||||
/// Cleanup internal `wl_output` instances list
|
||||
|
|
|
@ -170,7 +170,7 @@ pub enum Error {
|
|||
/// Create a keyboard handler from a set of RMLVO rules
|
||||
pub(crate) fn create_keyboard_handler(rules: &str, model: &str, layout: &str, variant: &str,
|
||||
options: Option<String>, repeat_delay: i32, repeat_rate: i32,
|
||||
logger: ::slog::Logger)
|
||||
logger: &::slog::Logger)
|
||||
-> Result<KeyboardHandle, Error> {
|
||||
let log = logger.new(o!("smithay_module" => "xkbcommon_handler"));
|
||||
info!(log, "Initializing a xkbcommon handler with keymap query";
|
||||
|
|
|
@ -169,7 +169,7 @@ impl Seat {
|
|||
options,
|
||||
repeat_delay,
|
||||
repeat_rate,
|
||||
self.log.clone(),
|
||||
&self.log,
|
||||
)?;
|
||||
if self.keyboard.is_some() {
|
||||
// there is already a keyboard, remove it and notify the clients
|
||||
|
|
|
@ -64,7 +64,7 @@ impl PointerHandle {
|
|||
// do we leave a surface ?
|
||||
let mut leave = true;
|
||||
if let Some(ref focus) = guard.focus {
|
||||
if let Some((ref surface, _, _)) = location {
|
||||
if let Some((surface, _, _)) = location {
|
||||
if focus.equals(surface) {
|
||||
leave = false;
|
||||
}
|
||||
|
|
|
@ -251,7 +251,7 @@ impl PopupState {
|
|||
if let Some(p) = self.parent.clone() {
|
||||
Some(PopupState {
|
||||
parent: p,
|
||||
positioner: self.positioner.clone(),
|
||||
positioner: self.positioner,
|
||||
})
|
||||
} else {
|
||||
// the parent surface does no exist any longer,
|
||||
|
@ -283,15 +283,15 @@ impl<U, R, CID, SID, SD> Clone for ShellSurfaceIData<U, R, CID, SID, SD> {
|
|||
fn clone(&self) -> ShellSurfaceIData<U, R, CID, SID, SD> {
|
||||
ShellSurfaceIData {
|
||||
log: self.log.clone(),
|
||||
compositor_token: self.compositor_token.clone(),
|
||||
implementation: self.implementation.clone(),
|
||||
compositor_token: self.compositor_token,
|
||||
implementation: self.implementation,
|
||||
idata: self.idata.clone(),
|
||||
state_token: self.state_token.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Create new xdg_shell and wl_shell globals.
|
||||
/// Create new `xdg_shell` and `wl_shell` globals.
|
||||
///
|
||||
/// The globals are directly registered into the eventloop, and this function
|
||||
/// returns a `StateToken<_>` which you'll need access the list of shell
|
||||
|
|
|
@ -72,7 +72,7 @@ where
|
|||
pending_configures: Vec::new(),
|
||||
configured: true,
|
||||
};
|
||||
if let Err(_) = idata.compositor_token.give_role_with(surface, role_data) {
|
||||
if idata.compositor_token.give_role_with(surface, role_data).is_err() {
|
||||
shell.post_error(
|
||||
wl_shell::Error::Role as u32,
|
||||
"Surface already has a role.".into(),
|
||||
|
@ -91,7 +91,7 @@ where
|
|||
// register ourselves to the wl_shell for ping handling
|
||||
let mutex = unsafe { &*(shell.get_user_data() as *mut ShellUserData<SD>) };
|
||||
let mut guard = mutex.lock().unwrap();
|
||||
if guard.1.len() == 0 && guard.0.pending_ping != 0 {
|
||||
if guard.1.is_empty() && guard.0.pending_ping != 0 {
|
||||
// there is a pending ping that no surface could receive yet, send it
|
||||
// note this is not possible that it was received and then a wl_shell_surface was
|
||||
// destroyed, because wl_shell_surface has no destructor!
|
||||
|
@ -241,7 +241,7 @@ where
|
|||
min_size: (0, 0),
|
||||
max_size: (0, 0),
|
||||
});
|
||||
return true;
|
||||
true
|
||||
})
|
||||
.expect("xdg_surface exists but surface has not shell_surface role?!");
|
||||
// we need to notify about this new toplevel surface
|
||||
|
@ -419,11 +419,10 @@ where
|
|||
let &(ref surface, _) = unsafe { &*(ptr as *mut ShellSurfaceUserData) };
|
||||
idata
|
||||
.compositor_token
|
||||
.with_role_data(surface, |data| match data.pending_state {
|
||||
ShellSurfacePendingState::Toplevel(ref mut state) => {
|
||||
.with_role_data(surface, |data| {
|
||||
if let ShellSurfacePendingState::Toplevel(ref mut state) = data.pending_state {
|
||||
state.title = title;
|
||||
}
|
||||
_ => {}
|
||||
})
|
||||
.expect("wl_shell_surface exists but wl_surface has wrong role?!");
|
||||
},
|
||||
|
|
|
@ -93,7 +93,7 @@ where
|
|||
pending_configures: Vec::new(),
|
||||
configured: false,
|
||||
};
|
||||
if let Err(_) = idata.compositor_token.give_role_with(wl_surface, role_data) {
|
||||
if idata.compositor_token.give_role_with(wl_surface, role_data).is_err() {
|
||||
shell.post_error(
|
||||
zxdg_shell_v6::Error::Role as u32,
|
||||
"Surface already has a role.".into(),
|
||||
|
@ -315,7 +315,7 @@ where
|
|||
.with_role_data::<ShellSurfaceRole, _, _>(surface, |data| {
|
||||
data.pending_state = ShellSurfacePendingState::Popup(PopupState {
|
||||
parent: unsafe { parent_surface.clone_unchecked() },
|
||||
positioner: positioner_data.clone(),
|
||||
positioner: *positioner_data,
|
||||
});
|
||||
})
|
||||
.expect("xdg_surface exists but surface has not shell_surface role?!");
|
||||
|
|
|
@ -71,7 +71,7 @@ use wayland_server::protocol::{wl_buffer, wl_shm, wl_shm_pool};
|
|||
mod pool;
|
||||
|
||||
#[derive(Clone)]
|
||||
/// Internal data storage of ShmGlobal
|
||||
/// Internal data storage of `ShmGlobal`
|
||||
///
|
||||
/// This type is only visible as type parameter of
|
||||
/// the `Global` handle you are provided.
|
||||
|
@ -104,9 +104,7 @@ where
|
|||
log: log.new(o!("smithay_module" => "shm_handler")),
|
||||
};
|
||||
|
||||
let global = evl.register_global::<wl_shm::WlShm, _>(1, shm_global_bind, data);
|
||||
|
||||
global
|
||||
evl.register_global::<wl_shm::WlShm, _>(1, shm_global_bind, data)
|
||||
}
|
||||
|
||||
/// Error that can occur when accessing an SHM buffer
|
||||
|
@ -125,13 +123,13 @@ pub enum BufferAccessError {
|
|||
|
||||
/// Call given closure with the contents of the given buffer
|
||||
///
|
||||
/// If the buffer is managed by the provided ShmGlobal, its contents are
|
||||
/// If the buffer is managed by the provided `ShmGlobal`, its contents are
|
||||
/// extracted and the closure is extracted with them:
|
||||
///
|
||||
/// - The first argument is a data slice of the contents of the pool
|
||||
/// - The second argument is the specification of this buffer is this pool
|
||||
///
|
||||
/// If the buffer is not managed by the provided ShmGlobal, the closure is not called
|
||||
/// If the buffer is not managed by the provided `ShmGlobal`, the closure is not called
|
||||
/// and this method will return `Err(())` (this will be the case for an EGL buffer for example).
|
||||
pub fn with_buffer_contents<F>(buffer: &wl_buffer::WlBuffer, f: F) -> Result<(), BufferAccessError>
|
||||
where
|
||||
|
|
Loading…
Reference in New Issue