chore: apply recommendations from clippy

This commit is contained in:
Cheong Lau 2025-10-04 10:51:18 +10:00 • committed by GitHub
parent cec55dafd7
commit 8e0f1c4a09
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
56 changed files with 720 additions and 824 deletions

View file

@ -179,7 +179,7 @@ impl ActivationHandler for AppData {
fn new_token(&mut self, token: String, data: &ExecRequestData) {
let _ = self.tx.unbounded_send(WaylandUpdate::ActivationToken {
token: Some(token),
app_id: data.app_id().map(|x| x.to_owned()),
app_id: data.app_id().map(String::from),
exec: data.exec.clone(),
gpu_idx: data.gpu_idx,
terminal: data.terminal,
@ -313,7 +313,10 @@ impl Session {
self.condvar.notify_all();
}
fn wait_while<F: FnMut(&SessionInner) -> bool>(&self, mut f: F) -> MutexGuard<SessionInner> {
fn wait_while<F: FnMut(&SessionInner) -> bool>(
&self,
mut f: F,
) -> MutexGuard<'_, SessionInner> {
self.condvar
.wait_while(self.inner.lock().unwrap(), |data| f(data))
.unwrap()
@ -337,7 +340,7 @@ impl Dispatch<wl_shm_pool::WlShmPool, ()> for AppData {
_app_data: &mut Self,
_buffer: &wl_shm_pool::WlShmPool,
_event: wl_shm_pool::Event,
_: &(),
(): &(),
_: &Connection,
_qh: &QueueHandle<Self>,
) {
@ -349,7 +352,7 @@ impl Dispatch<wl_buffer::WlBuffer, ()> for AppData {
_app_data: &mut Self,
_buffer: &wl_buffer::WlBuffer,
_event: wl_buffer::Event,
_: &(),
(): &(),
_: &Connection,
_qh: &QueueHandle<Self>,
) {
@ -387,7 +390,7 @@ impl CaptureData {
&self.qh,
SessionData {
session: session.clone(),
session_data: Default::default(),
session_data: ScreencopySessionData::default(),
},
)
.unwrap();
@ -405,22 +408,19 @@ impl CaptureData {
}
// XXX
if !formats
.shm_formats
.contains(&wl_shm::Format::Abgr8888.into())
{
if !formats.shm_formats.contains(&wl_shm::Format::Abgr8888) {
tracing::error!("No suitable buffer format found");
tracing::warn!("Available formats: {:#?}", formats);
return None;
};
}
let buf_len = width * height * 4;
if let Some(len) = len {
if len != buf_len {
return None;
}
} else if let Err(_err) = rustix::fs::ftruncate(&fd, buf_len as _) {
};
} else if let Err(_err) = rustix::fs::ftruncate(&fd, buf_len.into()) {
}
let pool = self
.wl_shm
.create_pool(fd.as_fd(), buf_len as i32, &self.qh, ());
@ -439,7 +439,7 @@ impl CaptureData {
&[],
&self.qh,
FrameData {
frame_data: Default::default(),
frame_data: ScreencopyFrameData::default(),
session: capture_session.clone(),
},
);
@ -484,7 +484,7 @@ impl AppData {
handle: &ExtForeignToplevelHandleV1,
) -> Option<ZcosmicToplevelHandleV1> {
self.toplevel_info_state
.info(&handle)?
.info(handle)?
.cosmic_toplevel
.clone()
}
@ -498,8 +498,7 @@ impl AppData {
capturer: self.screencopy_state.capturer().clone(),
};
std::thread::spawn(move || {
use std::ffi::CStr;
let name = unsafe { CStr::from_bytes_with_nul_unchecked(b"app-list-screencopy\0") };
let name = c"app-list-screencopy";
let Ok(fd) = rustix::fs::memfd_create(name, rustix::fs::MemfdFlags::CLOEXEC) else {
tracing::error!("Failed to get fd for capture");
return;
@ -535,7 +534,7 @@ impl AppData {
tx.unbounded_send(WaylandUpdate::Image(handle, WaylandImage::new(img)))
{
tracing::error!("Failed to send image event to subscription {err:?}");
};
}
} else {
tracing::error!("Failed to capture image");
}
@ -624,7 +623,7 @@ pub(crate) fn wayland_handler(
.expect("Failed to insert wayland source.");
if handle
.insert_source(rx, |event, _, state| match event {
.insert_source(rx, |event, (), state| match event {
calloop::channel::Event::Msg(req) => match req {
WaylandRequest::Screencopy(handle) => {
state.send_image(handle.clone());