Fix Clippy

This commit is contained in:
Poly 2021-07-30 17:55:32 +02:00 committed by Victor Berger
parent 88dc5c182f
commit df9be985ca
19 changed files with 49 additions and 63 deletions

View File

@ -195,7 +195,7 @@ impl<A: AsRawFd + 'static> AtomicDrmDevice<A> {
let prop = self let prop = self
.prop_mapping .prop_mapping
.0 .0
.get(&conn) .get(conn)
.expect("Unknown handle") .expect("Unknown handle")
.get("CRTC_ID") .get("CRTC_ID")
.expect("Unknown property CRTC_ID"); .expect("Unknown property CRTC_ID");
@ -206,7 +206,7 @@ impl<A: AsRawFd + 'static> AtomicDrmDevice<A> {
let prop = self let prop = self
.prop_mapping .prop_mapping
.3 .3
.get(&plane) .get(plane)
.expect("Unknown handle") .expect("Unknown handle")
.get("CRTC_ID") .get("CRTC_ID")
.expect("Unknown property CRTC_ID"); .expect("Unknown property CRTC_ID");
@ -215,7 +215,7 @@ impl<A: AsRawFd + 'static> AtomicDrmDevice<A> {
let prop = self let prop = self
.prop_mapping .prop_mapping
.3 .3
.get(&plane) .get(plane)
.expect("Unknown handle") .expect("Unknown handle")
.get("FB_ID") .get("FB_ID")
.expect("Unknown property FB_ID"); .expect("Unknown property FB_ID");
@ -227,14 +227,14 @@ impl<A: AsRawFd + 'static> AtomicDrmDevice<A> {
let mode_prop = self let mode_prop = self
.prop_mapping .prop_mapping
.1 .1
.get(&crtc) .get(crtc)
.expect("Unknown handle") .expect("Unknown handle")
.get("MODE_ID") .get("MODE_ID")
.expect("Unknown property MODE_ID"); .expect("Unknown property MODE_ID");
let active_prop = self let active_prop = self
.prop_mapping .prop_mapping
.1 .1
.get(&crtc) .get(crtc)
.expect("Unknown handle") .expect("Unknown handle")
.get("ACTIVE") .get("ACTIVE")
.expect("Unknown property ACTIVE"); .expect("Unknown property ACTIVE");

View File

@ -66,7 +66,7 @@ impl State {
for conn in res_handles.connectors() { for conn in res_handles.connectors() {
let crtc_prop = prop_mapping let crtc_prop = prop_mapping
.0 .0
.get(&conn) .get(conn)
.expect("Unknown handle") .expect("Unknown handle")
.get("CRTC_ID") .get("CRTC_ID")
.ok_or_else(|| Error::UnknownProperty { .ok_or_else(|| Error::UnknownProperty {
@ -1006,7 +1006,7 @@ impl<A: AsRawFd + 'static> Drop for AtomicDrmSurface<A> {
let prop = self let prop = self
.prop_mapping .prop_mapping
.0 .0
.get(&conn) .get(conn)
.expect("Unknown Handle") .expect("Unknown Handle")
.get("CRTC_ID") .get("CRTC_ID")
.expect("Unknown property CRTC_ID"); .expect("Unknown property CRTC_ID");

View File

@ -175,14 +175,14 @@ where
impl backend::TabletToolButtonEvent<LibinputInputBackend> for tablet_tool::TabletToolButtonEvent { impl backend::TabletToolButtonEvent<LibinputInputBackend> for tablet_tool::TabletToolButtonEvent {
fn button(&self) -> u32 { fn button(&self) -> u32 {
tablet_tool::TabletToolButtonEvent::button(&self) tablet_tool::TabletToolButtonEvent::button(self)
} }
fn seat_button_count(&self) -> u32 { fn seat_button_count(&self) -> u32 {
tablet_tool::TabletToolButtonEvent::seat_button_count(&self) tablet_tool::TabletToolButtonEvent::seat_button_count(self)
} }
fn button_state(&self) -> backend::ButtonState { fn button_state(&self) -> backend::ButtonState {
tablet_tool::TabletToolButtonEvent::button_state(&self).into() tablet_tool::TabletToolButtonEvent::button_state(self).into()
} }
} }

View File

@ -385,7 +385,7 @@ unsafe fn link_program(
} }
unsafe fn texture_program(gl: &ffi::Gles2, frag: &'static str) -> Result<Gles2Program, Gles2Error> { unsafe fn texture_program(gl: &ffi::Gles2, frag: &'static str) -> Result<Gles2Program, Gles2Error> {
let program = link_program(&gl, shaders::VERTEX_SHADER, frag)?; let program = link_program(gl, shaders::VERTEX_SHADER, frag)?;
let position = CStr::from_bytes_with_nul(b"position\0").expect("NULL terminated"); let position = CStr::from_bytes_with_nul(b"position\0").expect("NULL terminated");
let tex_coords = CStr::from_bytes_with_nul(b"tex_coords\0").expect("NULL terminated"); let tex_coords = CStr::from_bytes_with_nul(b"tex_coords\0").expect("NULL terminated");
@ -557,7 +557,7 @@ impl ImportShm for Gles2Renderer {
) -> Result<Gles2Texture, Gles2Error> { ) -> Result<Gles2Texture, Gles2Error> {
use crate::wayland::shm::with_buffer_contents; use crate::wayland::shm::with_buffer_contents;
with_buffer_contents(&buffer, |slice, data| { with_buffer_contents(buffer, |slice, data| {
self.make_current()?; self.make_current()?;
let offset = data.offset as i32; let offset = data.offset as i32;
@ -711,7 +711,7 @@ impl ImportEgl for Gles2Renderer {
.egl_reader .egl_reader
.as_ref() .as_ref()
.unwrap() .unwrap()
.egl_buffer_contents(&buffer) .egl_buffer_contents(buffer)
.map_err(Gles2Error::EGLBufferAccessError)?; .map_err(Gles2Error::EGLBufferAccessError)?;
let tex = self.import_egl_image(egl.image(0).unwrap(), egl.format == EGLFormat::External, None)?; let tex = self.import_egl_image(egl.image(0).unwrap(), egl.format == EGLFormat::External, None)?;
@ -743,14 +743,14 @@ impl ImportDma for Gles2Renderer {
return Err(Gles2Error::GLExtensionNotSupported(&["GL_OES_EGL_image"])); return Err(Gles2Error::GLExtensionNotSupported(&["GL_OES_EGL_image"]));
} }
self.existing_dmabuf_texture(&buffer)?.map(Ok).unwrap_or_else(|| { self.existing_dmabuf_texture(buffer)?.map(Ok).unwrap_or_else(|| {
let is_external = !self.egl.dmabuf_render_formats().contains(&buffer.format()); let is_external = !self.egl.dmabuf_render_formats().contains(&buffer.format());
self.make_current()?; self.make_current()?;
let image = self let image = self
.egl .egl
.display .display
.create_image_from_dmabuf(&buffer) .create_image_from_dmabuf(buffer)
.map_err(Gles2Error::BindBufferEGLError)?; .map_err(Gles2Error::BindBufferEGLError)?;
let tex = self.import_egl_image(image, is_external, None)?; let tex = self.import_egl_image(image, is_external, None)?;

View File

@ -510,13 +510,13 @@ pub fn buffer_type(buffer: &wl_buffer::WlBuffer) -> Option<BufferType> {
.unwrap() .unwrap()
.as_ref() .as_ref()
.and_then(|x| x.upgrade()) .and_then(|x| x.upgrade())
.and_then(|x| x.egl_buffer_dimensions(&buffer)) .and_then(|x| x.egl_buffer_dimensions(buffer))
.is_some() .is_some()
{ {
return Some(BufferType::Egl); return Some(BufferType::Egl);
} }
if crate::wayland::shm::with_buffer_contents(&buffer, |_, _| ()).is_ok() { if crate::wayland::shm::with_buffer_contents(buffer, |_, _| ()).is_ok() {
return Some(BufferType::Shm); return Some(BufferType::Shm);
} }
@ -540,10 +540,10 @@ pub fn buffer_dimensions(buffer: &wl_buffer::WlBuffer) -> Option<Size<i32, Physi
.unwrap() .unwrap()
.as_ref() .as_ref()
.and_then(|x| x.upgrade()) .and_then(|x| x.upgrade())
.and_then(|x| x.egl_buffer_dimensions(&buffer)) .and_then(|x| x.egl_buffer_dimensions(buffer))
{ {
return Some(dim); return Some(dim);
} }
crate::wayland::shm::with_buffer_contents(&buffer, |_, data| (data.width, data.height).into()).ok() crate::wayland::shm::with_buffer_contents(buffer, |_, data| (data.width, data.height).into()).ok()
} }

View File

@ -424,6 +424,6 @@ fn destroy_subsurface(subsurface: &wl_subsurface::WlSubsurface) {
.get::<wl_surface::WlSurface>() .get::<wl_surface::WlSurface>()
.unwrap(); .unwrap();
if surface.as_ref().is_alive() { if surface.as_ref().is_alive() {
PrivateSurfaceData::unset_parent(&surface); PrivateSurfaceData::unset_parent(surface);
} }
} }

View File

@ -69,9 +69,9 @@ impl PointerGrab for DnDGrab {
// focus changed, we need to make a leave if appropriate // focus changed, we need to make a leave if appropriate
if let Some(surface) = self.current_focus.take() { if let Some(surface) = self.current_focus.take() {
// only leave if there is a data source or we are on the original client // only leave if there is a data source or we are on the original client
if self.data_source.is_some() || self.origin.as_ref().same_client_as(&surface.as_ref()) { if self.data_source.is_some() || self.origin.as_ref().same_client_as(surface.as_ref()) {
for device in &seat_data.known_devices { for device in &seat_data.known_devices {
if device.as_ref().same_client_as(&surface.as_ref()) { if device.as_ref().same_client_as(surface.as_ref()) {
device.leave(); device.leave();
} }
} }
@ -102,7 +102,7 @@ impl PointerGrab for DnDGrab {
for device in seat_data for device in seat_data
.known_devices .known_devices
.iter() .iter()
.filter(|d| d.as_ref().same_client_as(&surface.as_ref())) .filter(|d| d.as_ref().same_client_as(surface.as_ref()))
{ {
let action_choice = device let action_choice = device
.as_ref() .as_ref()
@ -138,9 +138,9 @@ impl PointerGrab for DnDGrab {
self.offer_data = Some(offer_data); self.offer_data = Some(offer_data);
} else { } else {
// only send if we are on a surface of the same client // only send if we are on a surface of the same client
if self.origin.as_ref().same_client_as(&surface.as_ref()) { if self.origin.as_ref().same_client_as(surface.as_ref()) {
for device in &seat_data.known_devices { for device in &seat_data.known_devices {
if device.as_ref().same_client_as(&surface.as_ref()) { if device.as_ref().same_client_as(surface.as_ref()) {
device.enter(serial.into(), &surface, x, y, None); device.enter(serial.into(), &surface, x, y, None);
} }
} }
@ -149,9 +149,9 @@ impl PointerGrab for DnDGrab {
self.current_focus = Some(surface); self.current_focus = Some(surface);
} else { } else {
// make a move // make a move
if self.data_source.is_some() || self.origin.as_ref().same_client_as(&surface.as_ref()) { if self.data_source.is_some() || self.origin.as_ref().same_client_as(surface.as_ref()) {
for device in &seat_data.known_devices { for device in &seat_data.known_devices {
if device.as_ref().same_client_as(&surface.as_ref()) { if device.as_ref().same_client_as(surface.as_ref()) {
device.motion(time, x, y); device.motion(time, x, y);
} }
} }
@ -183,7 +183,7 @@ impl PointerGrab for DnDGrab {
false false
}; };
if let Some(ref surface) = self.current_focus { if let Some(ref surface) = self.current_focus {
if self.data_source.is_some() || self.origin.as_ref().same_client_as(&surface.as_ref()) { if self.data_source.is_some() || self.origin.as_ref().same_client_as(surface.as_ref()) {
for device in &seat_data.known_devices { for device in &seat_data.known_devices {
if device.as_ref().same_client_as(surface.as_ref()) { if device.as_ref().same_client_as(surface.as_ref()) {
if validated { if validated {

View File

@ -491,7 +491,7 @@ where
.unwrap() .unwrap()
.borrow_mut() .borrow_mut()
.known_devices .known_devices
.retain(|ndd| ndd.as_ref().is_alive() && (!ndd.as_ref().equals(&dd.as_ref()))) .retain(|ndd| ndd.as_ref().is_alive() && (!ndd.as_ref().equals(dd.as_ref())))
} }
_ => unreachable!(), _ => unreachable!(),
}); });

View File

@ -92,7 +92,7 @@ where
// focus changed, we need to make a leave if appropriate // focus changed, we need to make a leave if appropriate
if let Some(surface) = self.current_focus.take() { if let Some(surface) = self.current_focus.take() {
for device in &seat_data.known_devices { for device in &seat_data.known_devices {
if device.as_ref().same_client_as(&surface.as_ref()) { if device.as_ref().same_client_as(surface.as_ref()) {
device.leave(); device.leave();
} }
} }
@ -121,7 +121,7 @@ where
for device in seat_data for device in seat_data
.known_devices .known_devices
.iter() .iter()
.filter(|d| d.as_ref().same_client_as(&surface.as_ref())) .filter(|d| d.as_ref().same_client_as(surface.as_ref()))
{ {
let action_choice = device let action_choice = device
.as_ref() .as_ref()
@ -157,7 +157,7 @@ where
} else { } else {
// make a move // make a move
for device in &seat_data.known_devices { for device in &seat_data.known_devices {
if device.as_ref().same_client_as(&surface.as_ref()) { if device.as_ref().same_client_as(surface.as_ref()) {
device.motion(time, x, y); device.motion(time, x, y);
} }
} }

View File

@ -249,14 +249,7 @@ where
} }
}; };
if !buffer_basic_checks( if !buffer_basic_checks(&self.formats, &self.pending_planes, params, format, width, height) {
&self.formats,
&self.pending_planes,
&params,
format,
width,
height,
) {
trace!(self.log, "Killing client providing bogus dmabuf buffer params."); trace!(self.log, "Killing client providing bogus dmabuf buffer params.");
return; return;
} }
@ -338,14 +331,7 @@ where
} }
}; };
if !buffer_basic_checks( if !buffer_basic_checks(&self.formats, &self.pending_planes, params, format, width, height) {
&self.formats,
&self.pending_planes,
&params,
format,
width,
height,
) {
trace!(self.log, "Killing client providing bogus dmabuf buffer params."); trace!(self.log, "Killing client providing bogus dmabuf buffer params.");
return; return;
} }

View File

@ -159,7 +159,7 @@ impl std::error::Error for NoExplicitSync {}
/// the client associated with this `SurfaceAttributes` will be killed as a result of calling this /// the client associated with this `SurfaceAttributes` will be killed as a result of calling this
/// function. /// function.
pub fn send_explicit_synchronization_error(attrs: &SurfaceData, error: ExplicitSyncError) { pub fn send_explicit_synchronization_error(attrs: &SurfaceData, error: ExplicitSyncError) {
if let Some(ref data) = attrs.data_map.get::<ESUserData>() { if let Some(data) = attrs.data_map.get::<ESUserData>() {
if let Some(sync_resource) = data.state.borrow().deref() { if let Some(sync_resource) = data.state.borrow().deref() {
match error { match error {
ExplicitSyncError::InvalidFence => sync_resource.as_ref().post_error( ExplicitSyncError::InvalidFence => sync_resource.as_ref().post_error(

View File

@ -215,7 +215,7 @@ impl Output {
.lock() .lock()
.unwrap() .unwrap()
.instances .instances
.retain(|o| !o.as_ref().equals(&output.as_ref())); .retain(|o| !o.as_ref().equals(output.as_ref()));
})); }));
output.as_ref().user_data().set_threadsafe({ output.as_ref().user_data().set_threadsafe({
let inner = inner.clone(); let inner = inner.clone();

View File

@ -92,7 +92,7 @@ impl XdgOutput {
.lock() .lock()
.unwrap() .unwrap()
.instances .instances
.retain(|o| !o.as_ref().equals(&xdg_output.as_ref())); .retain(|o| !o.as_ref().equals(xdg_output.as_ref()));
})); }));
xdg_output.as_ref().user_data().set_threadsafe({ xdg_output.as_ref().user_data().set_threadsafe({
let xdg_output = self.clone(); let xdg_output = self.clone();

View File

@ -377,7 +377,7 @@ impl KeyboardHandle {
if !same { if !same {
// unset old focus // unset old focus
guard.with_focused_kbds(|kbd, s| { guard.with_focused_kbds(|kbd, s| {
kbd.leave(serial.into(), &s); kbd.leave(serial.into(), s);
}); });
// set new focus // set new focus
@ -385,7 +385,7 @@ impl KeyboardHandle {
let (dep, la, lo, gr) = guard.serialize_modifiers(); let (dep, la, lo, gr) = guard.serialize_modifiers();
let keys = guard.serialize_pressed_keys(); let keys = guard.serialize_pressed_keys();
guard.with_focused_kbds(|kbd, surface| { guard.with_focused_kbds(|kbd, surface| {
kbd.enter(serial.into(), &surface, keys.clone()); kbd.enter(serial.into(), surface, keys.clone());
// Modifiers must be send after enter event. // Modifiers must be send after enter event.
kbd.modifiers(serial.into(), dep, la, lo, gr); kbd.modifiers(serial.into(), dep, la, lo, gr);
}); });
@ -481,7 +481,7 @@ pub(crate) fn implement_keyboard(keyboard: Main<WlKeyboard>, handle: Option<&Key
arc.internal arc.internal
.borrow_mut() .borrow_mut()
.known_kbds .known_kbds
.retain(|k| !k.as_ref().equals(&keyboard.as_ref())) .retain(|k| !k.as_ref().equals(keyboard.as_ref()))
})); }));
} }

View File

@ -360,7 +360,7 @@ fn implement_seat(seat: Main<wl_seat::WlSeat>, arc: Rc<SeatRc>) -> wl_seat::WlSe
.inner .inner
.borrow_mut() .borrow_mut()
.known_seats .known_seats
.retain(|s| !s.as_ref().equals(&seat.as_ref())); .retain(|s| !s.as_ref().equals(seat.as_ref()));
})); }));
seat.as_ref().user_data().set(move || arc); seat.as_ref().user_data().set(move || arc);

View File

@ -377,7 +377,7 @@ impl<'a> PointerInnerHandle<'a> {
} }
if leave { if leave {
self.inner.with_focused_pointers(|pointer, surface| { self.inner.with_focused_pointers(|pointer, surface| {
pointer.leave(serial.into(), &surface); pointer.leave(serial.into(), surface);
if pointer.as_ref().version() >= 5 { if pointer.as_ref().version() >= 5 {
pointer.frame(); pointer.frame();
} }
@ -395,7 +395,7 @@ impl<'a> PointerInnerHandle<'a> {
let (x, y) = (location - surface_location.to_f64()).into(); let (x, y) = (location - surface_location.to_f64()).into();
if entered { if entered {
self.inner.with_focused_pointers(|pointer, surface| { self.inner.with_focused_pointers(|pointer, surface| {
pointer.enter(serial.into(), &surface, x, y); pointer.enter(serial.into(), surface, x, y);
if pointer.as_ref().version() >= 5 { if pointer.as_ref().version() >= 5 {
pointer.frame(); pointer.frame();
} }
@ -588,7 +588,7 @@ pub(crate) fn implement_pointer(pointer: Main<WlPointer>, handle: Option<&Pointe
.. ..
} = *guard; } = *guard;
if let Some((ref focus, _)) = *focus { if let Some((ref focus, _)) = *focus {
if focus.as_ref().same_client_as(&pointer.as_ref()) { if focus.as_ref().same_client_as(pointer.as_ref()) {
match surface { match surface {
Some(surface) => { Some(surface) => {
// tolerate re-using the same surface // tolerate re-using the same surface
@ -640,7 +640,7 @@ pub(crate) fn implement_pointer(pointer: Main<WlPointer>, handle: Option<&Pointe
inner inner
.borrow_mut() .borrow_mut()
.known_pointers .known_pointers
.retain(|p| !p.as_ref().equals(&pointer.as_ref())) .retain(|p| !p.as_ref().equals(pointer.as_ref()))
})) }))
} }

View File

@ -57,7 +57,7 @@ impl TabletHandle {
inner inner
.borrow_mut() .borrow_mut()
.instances .instances
.retain(|i| !i.as_ref().equals(&instance.as_ref())); .retain(|i| !i.as_ref().equals(instance.as_ref()));
})); }));
seat.tablet_added(&wl_tablet); seat.tablet_added(&wl_tablet);

View File

@ -75,7 +75,7 @@ impl TabletSeatHandle {
inner inner
.borrow_mut() .borrow_mut()
.instances .instances
.retain(|i| !i.as_ref().equals(&seat.as_ref())); .retain(|i| !i.as_ref().equals(seat.as_ref()));
})); }));
} }

View File

@ -257,7 +257,7 @@ impl TabletToolHandle {
let inner = inner.borrow(); let inner = inner.borrow();
if let Some(ref focus) = inner.focus { if let Some(ref focus) = inner.focus {
if focus.as_ref().same_client_as(&tool.as_ref()) { if focus.as_ref().same_client_as(tool.as_ref()) {
if let Some(surface) = surface { if let Some(surface) = surface {
// tolerate re-using the same surface // tolerate re-using the same surface
if compositor::give_role(&surface, CURSOR_IMAGE_ROLE).is_err() if compositor::give_role(&surface, CURSOR_IMAGE_ROLE).is_err()
@ -305,7 +305,7 @@ impl TabletToolHandle {
inner inner
.borrow_mut() .borrow_mut()
.instances .instances
.retain(|i| !i.as_ref().equals(&instance.as_ref())); .retain(|i| !i.as_ref().equals(instance.as_ref()));
})); }));
seat.tool_added(&wl_tool); seat.tool_added(&wl_tool);