Skip to content

Commit

Permalink
chore: clippy
Browse files Browse the repository at this point in the history
Signed-off-by: Enrico Stemmer <enrico@h3rmt.zip>
  • Loading branch information
H3rmt committed Feb 13, 2025
1 parent 6a753fa commit 078d8f6
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 61 deletions.
12 changes: 6 additions & 6 deletions src/config/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rand::Rng;
use std::path::PathBuf;
use tracing::{span, trace, Level};

pub fn create_binds_and_submaps<'a>(binds: &Vec<Bind>) -> anyhow::Result<Vec<(&'a str, String)>> {
pub fn create_binds_and_submaps<'a>(binds: &[Bind]) -> anyhow::Result<Vec<(&'a str, String)>> {
let _span = span!(Level::DEBUG, "create_binds_and_submaps").entered();
let workspaces_per_row = global::OPTS
.get()
Expand All @@ -25,7 +25,7 @@ pub fn create_binds_and_submaps<'a>(binds: &Vec<Bind>) -> anyhow::Result<Vec<(&'
keyword_list.push(("layerrule", "noanim, hyprswitch_launcher".to_string()));
keyword_list.push(("layerrule", "noanim, hyprswitch".to_string()));

for (i, bind) in binds.into_iter().enumerate() {
for (i, bind) in binds.iter().enumerate() {
let submap_name = format!("hyprswitch-{rand_id}-{i}");
trace!("submap_name: {}", submap_name);
match bind {
Expand Down Expand Up @@ -147,7 +147,7 @@ fn generate_overview(
"{}, {}, exec, {}",
press.open.modifier,
press.open.key.to_key(),
generate_open_string_press(submap_name.clone(), &press)?,
generate_open_string_press(submap_name.clone(), press)?,
),
));

Expand Down Expand Up @@ -264,7 +264,7 @@ fn generate_switch(
"{}, {}, exec, {} && {}",
hold.open.modifier,
hold.navigate.forward,
generate_open_string_hold(submap_name.clone(), &hold)?,
generate_open_string_hold(submap_name.clone(), hold)?,
generate_dispatch(false, 1, false)?,
),
));
Expand All @@ -276,7 +276,7 @@ fn generate_switch(
"{}, {}, exec, {} && {}",
hold.open.modifier,
key,
generate_open_string_hold(submap_name.clone(), &hold)?,
generate_open_string_hold(submap_name.clone(), hold)?,
generate_dispatch(false, 1, false)?,
),
)),
Expand All @@ -287,7 +287,7 @@ fn generate_switch(
hold.open.modifier,
modk,
hold.navigate.forward,
generate_open_string_hold(submap_name.clone(), &hold)?,
generate_open_string_hold(submap_name.clone(), hold)?,
generate_dispatch(false, 1, false)?,
),
)),
Expand Down
8 changes: 5 additions & 3 deletions src/daemon/gui/launcher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ pub(super) fn create_launcher(
Ok(())
}

#[allow(clippy::too_many_arguments)]
pub(super) fn update_launcher(
share: Share,
text: &str,
Expand Down Expand Up @@ -158,7 +159,7 @@ pub(super) fn update_launcher(
let mut matches: Vec<_> = matches.into_values().collect();
matches.sort_by(|(a_t, a), (b_t, b)| {
if a_t != b_t {
return a_t.cmp(&b_t);
a_t.cmp(b_t)
} else {
let a_e = runs.get(&a.desktop_file);
let b_e = runs.get(&b.desktop_file);
Expand Down Expand Up @@ -189,7 +190,7 @@ pub(super) fn update_launcher(
share.clone(),
&entry.name,
&entry.icon,
&*entry.exec,
&entry.exec,
index,
&match reverse_key {
ReverseKey::Mod(m) => match i {
Expand Down Expand Up @@ -229,6 +230,7 @@ pub(super) fn update_launcher(
execs
}

#[allow(clippy::too_many_arguments)]
fn create_launch_widget(
share: Share,
name: &str,
Expand Down Expand Up @@ -312,7 +314,7 @@ fn create_launch_widget(
.unwrap_or_default()
)
} else {
format!("{}", exec) // show full exec instead of only last part of /path/to/exec
exec.to_string() // show full exec instead of only last part of /path/to/exec
},
)
.build();
Expand Down
2 changes: 1 addition & 1 deletion src/daemon/gui/maps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub fn init_icon_map() {
let mut dirs: Vec<_> = read_dir(&path).unwrap().flatten().collect();
while let Some(d) = dirs.pop() {
if d.file_type().unwrap().is_dir() {
dirs.extend(read_dir(&d.path()).unwrap().flatten());
dirs.extend(read_dir(d.path()).unwrap().flatten());
} else {
let name = d.file_name();
let name = name.to_string_lossy();
Expand Down
1 change: 1 addition & 0 deletions src/daemon/gui/windows/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ fn scale(value: i16, size_factor: f64) -> i32 {
(value as f64 / 30.0 * size_factor) as i32
}

#[allow(clippy::too_many_arguments)]
pub fn init_windows(
share: Share,
workspaces_p: &[(WorkspaceId, WorkspaceData)],
Expand Down
2 changes: 1 addition & 1 deletion src/daemon/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub fn start_config_applier(binds: Vec<config::Bind>) {
.warn("Failed to start config reload event listener");
}

fn apply_config(binds: &Vec<config::Bind>) {
fn apply_config(binds: &[config::Bind]) {
if let Some(list) =
config::create_binds_and_submaps(binds).warn("Failed to create binds and submaps")
{
Expand Down
91 changes: 41 additions & 50 deletions src/handle/next.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ macro_rules! find_next {
}
} else {
if index < 0 {
index += filtered.len() as i8 * (((index as i8) * -1 / filtered.len() as i8) + 1);
index += filtered.len() as i8 * ((-(index as i8) / filtered.len() as i8) + 1);
}
index %= filtered.len() as i8;
}
Expand Down Expand Up @@ -84,32 +84,30 @@ pub fn find_next(
Some(id),
gui_navigation
)
} else {
if let Some(id2) = active.workspace {
let mut clients = hypr_data.clients.iter().filter(|(_, c)| c.workspace == id2);
if reverse {
clients.last()
} else {
clients.next()
}
.context("Workspace not found")?
} else if let Some(id2) = active.monitor {
let mut clients = hypr_data.clients.iter().filter(|(_, c)| c.monitor == id2);
if reverse {
clients.last()
} else {
clients.next()
}
.context("Monitor not found")?
} else if let Some(id2) = active.workspace {
let mut clients = hypr_data.clients.iter().filter(|(_, c)| c.workspace == id2);
if reverse {
clients.last()
} else {
find_next!(
reverse,
offset as i8,
&hypr_data.clients,
None::<ClientId>,
gui_navigation
)
clients.next()
}
.context("Workspace not found")?
} else if let Some(id2) = active.monitor {
let mut clients = hypr_data.clients.iter().filter(|(_, c)| c.monitor == id2);
if reverse {
clients.last()
} else {
clients.next()
}
.context("Monitor not found")?
} else {
find_next!(
reverse,
offset as i8,
&hypr_data.clients,
None::<ClientId>,
gui_navigation
)
};
info!("Next client: {:?}", id);
Ok(Active {
Expand All @@ -128,27 +126,25 @@ pub fn find_next(
Some(id),
gui_navigation
)
} else {
if let Some(id2) = active.monitor {
let mut workspaces = hypr_data
.workspaces
.iter()
.filter(|(_, c)| c.monitor == id2);
if reverse {
workspaces.last()
} else {
workspaces.next()
}
.context("Monitor not found")?
} else if let Some(id2) = active.monitor {
let mut workspaces = hypr_data
.workspaces
.iter()
.filter(|(_, c)| c.monitor == id2);
if reverse {
workspaces.last()
} else {
find_next!(
reverse,
offset as i8,
&hypr_data.workspaces,
None::<WorkspaceId>,
gui_navigation
)
workspaces.next()
}
.context("Monitor not found")?
} else {
find_next!(
reverse,
offset as i8,
&hypr_data.workspaces,
None::<WorkspaceId>,
gui_navigation
)
};
info!("Next workspace: {:?}", id);
Ok(Active {
Expand All @@ -158,16 +154,11 @@ pub fn find_next(
})
}
(false, SwitchType::Monitor) => {
let active_id = if let Some(id) = active.monitor {
Some(id)
} else {
None
};
let (id, _) = find_next!(
reverse,
offset as i8,
&hypr_data.monitors,
active_id,
active.monitor,
gui_navigation
);
info!("Next monitor: {:?}", id);
Expand Down

0 comments on commit 078d8f6

Please sign in to comment.