chore: apply recommendations from clippy
This commit is contained in:
parent
cec55dafd7
commit
8e0f1c4a09
56 changed files with 720 additions and 824 deletions
|
|
@ -88,25 +88,23 @@ impl Minimize {
|
|||
fn find_new_desktop_entry(&mut self, appid: &str) -> fde::DesktopEntry {
|
||||
let unicase_appid = fde::unicase::Ascii::new(appid);
|
||||
|
||||
let de = match fde::find_app_by_id(&self.desktop_entries, unicase_appid) {
|
||||
Some(de) => de,
|
||||
None => {
|
||||
// Update desktop entries in case it was not found.
|
||||
self.update_desktop_entries();
|
||||
match fde::find_app_by_id(&self.desktop_entries, unicase_appid) {
|
||||
Some(appid) => appid,
|
||||
None => {
|
||||
tracing::warn!(appid, "could not find desktop entry for app");
|
||||
let mut entry = fde::DesktopEntry {
|
||||
appid: appid.to_owned(),
|
||||
groups: Default::default(),
|
||||
path: Default::default(),
|
||||
ubuntu_gettext_domain: None,
|
||||
};
|
||||
entry.add_desktop_entry("Name".to_string(), appid.to_owned());
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
let de = if let Some(de) = fde::find_app_by_id(&self.desktop_entries, unicase_appid) {
|
||||
de
|
||||
} else {
|
||||
// Update desktop entries in case it was not found.
|
||||
self.update_desktop_entries();
|
||||
if let Some(appid) = fde::find_app_by_id(&self.desktop_entries, unicase_appid) {
|
||||
appid
|
||||
} else {
|
||||
tracing::warn!(appid, "could not find desktop entry for app");
|
||||
let mut entry = fde::DesktopEntry {
|
||||
appid: appid.to_owned(),
|
||||
groups: Default::default(),
|
||||
path: Default::default(),
|
||||
ubuntu_gettext_domain: None,
|
||||
};
|
||||
entry.add_desktop_entry("Name".to_string(), appid.to_owned());
|
||||
return entry;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -186,7 +184,7 @@ impl cosmic::Application for Minimize {
|
|||
.desktop_entry
|
||||
.icon()
|
||||
.unwrap_or(&apps[pos].desktop_entry.appid),
|
||||
)
|
||||
);
|
||||
}
|
||||
apps[pos].toplevel_info = toplevel_info;
|
||||
} else {
|
||||
|
|
@ -278,7 +276,7 @@ impl cosmic::Application for Minimize {
|
|||
cosmic::app::Action::Surface(a),
|
||||
));
|
||||
}
|
||||
};
|
||||
}
|
||||
Task::none()
|
||||
}
|
||||
|
||||
|
|
@ -286,17 +284,14 @@ impl cosmic::Application for Minimize {
|
|||
wayland_subscription::wayland_subscription().map(Message::Wayland)
|
||||
}
|
||||
|
||||
fn view(&self) -> Element<Self::Message> {
|
||||
let max_icon_count = self
|
||||
.max_icon_count()
|
||||
.map(|n| {
|
||||
if n < self.apps.len() {
|
||||
n - 1
|
||||
} else {
|
||||
self.apps.len()
|
||||
}
|
||||
})
|
||||
.unwrap_or(self.apps.len());
|
||||
fn view(&self) -> Element<'_, Self::Message> {
|
||||
let max_icon_count = self.max_icon_count().map_or(self.apps.len(), |n| {
|
||||
if n < self.apps.len() {
|
||||
n - 1
|
||||
} else {
|
||||
self.apps.len()
|
||||
}
|
||||
});
|
||||
let (width, _) = self.core.applet.suggested_size(false);
|
||||
let padding = self.core.applet.suggested_padding(false);
|
||||
let theme = self.core.system_theme().cosmic();
|
||||
|
|
@ -339,7 +334,7 @@ impl cosmic::Application for Minimize {
|
|||
|
||||
// TODO optional dividers on ends if detects app list neighbor
|
||||
// not sure the best way to tell if there is an adjacent app-list
|
||||
let icon_buttons = icon_buttons.chain(overflow_btn.into_iter());
|
||||
let icon_buttons = icon_buttons.chain(overflow_btn);
|
||||
let content: Element<_> = if matches!(
|
||||
self.core.applet.anchor,
|
||||
PanelAnchor::Top | PanelAnchor::Bottom
|
||||
|
|
@ -384,17 +379,14 @@ impl cosmic::Application for Minimize {
|
|||
.into()
|
||||
}
|
||||
|
||||
fn view_window(&self, _id: window::Id) -> Element<Self::Message> {
|
||||
let max_icon_count = self
|
||||
.max_icon_count()
|
||||
.map(|n| {
|
||||
if n < self.apps.len() {
|
||||
n - 1
|
||||
} else {
|
||||
self.apps.len()
|
||||
}
|
||||
})
|
||||
.unwrap_or(self.apps.len());
|
||||
fn view_window(&self, _id: window::Id) -> Element<'_, Self::Message> {
|
||||
let max_icon_count = self.max_icon_count().map_or(self.apps.len(), |n| {
|
||||
if n < self.apps.len() {
|
||||
n - 1
|
||||
} else {
|
||||
self.apps.len()
|
||||
}
|
||||
});
|
||||
let (width, _) = self.core.applet.suggested_size(false);
|
||||
let padding = self.core.applet.suggested_padding(false);
|
||||
let theme = self.core.system_theme().cosmic();
|
||||
|
|
|
|||
|
|
@ -43,6 +43,6 @@ pub fn localize() {
|
|||
let requested_languages = i18n_embed::DesktopLanguageRequester::requested_languages();
|
||||
|
||||
if let Err(error) = localizer.select(&requested_languages) {
|
||||
eprintln!("Error while loading language for Minimize {}", error);
|
||||
eprintln!("Error while loading language for Minimize {error}");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,7 +88,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()
|
||||
|
|
@ -150,7 +153,7 @@ impl CaptureData {
|
|||
&self.qh,
|
||||
SessionData {
|
||||
session: session.clone(),
|
||||
session_data: Default::default(),
|
||||
session_data: ScreencopySessionData::default(),
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
|
@ -168,22 +171,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, ());
|
||||
|
|
@ -202,7 +202,7 @@ impl CaptureData {
|
|||
&[],
|
||||
&self.qh,
|
||||
FrameData {
|
||||
frame_data: Default::default(),
|
||||
frame_data: ScreencopyFrameData::default(),
|
||||
session: capture_session.clone(),
|
||||
},
|
||||
);
|
||||
|
|
@ -237,7 +237,7 @@ impl<T: AsFd> ShmImage<T> {
|
|||
pub fn image(&self) -> anyhow::Result<image::RgbaImage> {
|
||||
let mmap = unsafe { memmap2::Mmap::map(&self.fd.as_fd())? };
|
||||
image::RgbaImage::from_raw(self.width, self.height, mmap.to_vec())
|
||||
.ok_or_else(|| anyhow::anyhow!("ShmImage had incorrect size"))
|
||||
.ok_or(anyhow::anyhow!("ShmImage had incorrect size"))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -297,7 +297,7 @@ impl AppData {
|
|||
handle: &ExtForeignToplevelHandleV1,
|
||||
) -> Option<ZcosmicToplevelHandleV1> {
|
||||
self.toplevel_info_state
|
||||
.info(&handle)?
|
||||
.info(handle)?
|
||||
.cosmic_toplevel
|
||||
.clone()
|
||||
}
|
||||
|
|
@ -311,9 +311,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"minimize-applet-screencopy\0") };
|
||||
let name = c"minimize-applet-screencopy";
|
||||
let Ok(fd) = rustix::fs::memfd_create(name, rustix::fs::MemfdFlags::CLOEXEC) else {
|
||||
tracing::error!("Failed to get fd for capture");
|
||||
return;
|
||||
|
|
@ -347,7 +345,7 @@ impl AppData {
|
|||
tx.send(WaylandUpdate::Image(handle, WaylandImage::new(img))),
|
||||
) {
|
||||
tracing::error!("Failed to send image event to subscription {err:?}");
|
||||
};
|
||||
}
|
||||
} else {
|
||||
tracing::error!("Failed to capture image");
|
||||
}
|
||||
|
|
@ -448,7 +446,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::Toplevel(req) => match req {
|
||||
ToplevelRequest::Activate(handle) => {
|
||||
|
|
@ -552,7 +550,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>,
|
||||
) {
|
||||
|
|
@ -564,7 +562,7 @@ impl Dispatch<wl_buffer::WlBuffer, ()> for AppData {
|
|||
_app_data: &mut Self,
|
||||
_buffer: &wl_buffer::WlBuffer,
|
||||
_event: wl_buffer::Event,
|
||||
_: &(),
|
||||
(): &(),
|
||||
_: &Connection,
|
||||
_qh: &QueueHandle<Self>,
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ pub struct WindowImage<'a, Msg> {
|
|||
icon: Element<'a, Msg>,
|
||||
}
|
||||
|
||||
impl<'a, Msg> WindowImage<'a, Msg>
|
||||
impl<Msg> WindowImage<'_, Msg>
|
||||
where
|
||||
Msg: 'static + Clone,
|
||||
{
|
||||
|
|
@ -81,13 +81,13 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, Msg> Widget<Msg, cosmic::Theme, cosmic::Renderer> for WindowImage<'a, Msg> {
|
||||
impl<Msg> Widget<Msg, cosmic::Theme, cosmic::Renderer> for WindowImage<'_, Msg> {
|
||||
fn children(&self) -> Vec<cosmic::iced_core::widget::Tree> {
|
||||
vec![Tree::new(&self.image_button), Tree::new(&self.icon)]
|
||||
}
|
||||
|
||||
fn diff(&mut self, tree: &mut cosmic::iced_core::widget::Tree) {
|
||||
tree.diff_children(&mut [&mut self.image_button, &mut self.icon])
|
||||
tree.diff_children(&mut [&mut self.image_button, &mut self.icon]);
|
||||
}
|
||||
|
||||
fn overlay<'b>(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue