Skip to content

Commit

Permalink
Fix clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
elkowar committed Feb 17, 2024
1 parent 7c64e6b commit 6f3d010
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 41 deletions.
1 change: 0 additions & 1 deletion crates/eww/src/config/eww_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ impl EwwConfig {
let magic_globals: Vec<_> = inbuilt::INBUILT_VAR_NAMES
.iter()
.chain(inbuilt::MAGIC_CONSTANT_NAMES)
.into_iter()
.map(|x| VarName::from(*x))
.collect();
yuck::config::validate::validate(&config, magic_globals)?;
Expand Down
2 changes: 1 addition & 1 deletion crates/eww/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ pub mod system_stats;
pub mod window_definition;

Check failure on line 6 in crates/eww/src/config/mod.rs

View workflow job for this annotation

GitHub Actions / build

Diff in /home/runner/work/eww/eww/crates/eww/src/config/mod.rs
pub use eww_config::*;
pub use script_var::*;
pub use window_definition::*;

4 changes: 2 additions & 2 deletions crates/eww/src/display_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ mod platform_x11 {
let strut_list: Vec<u8> = match strut_def.side {
Side::Left => vec![dist + mon_x, 0, 0, 0, mon_x, mon_end_y, 0, 0, 0, 0, 0, 0],
Side::Right => vec![0, root_window_geometry.width as u32 - mon_end_x + dist, 0, 0, 0, 0, mon_x, mon_end_y, 0, 0, 0, 0],
Side::Top => vec![0, 0, dist + mon_y as u32, 0, 0, 0, 0, 0, mon_x, mon_end_x, 0, 0],
Side::Bottom => vec![0, 0, 0, root_window_geometry.height as u32 - mon_end_y + dist, 0, 0, 0, 0, 0, 0, mon_x as u32, mon_end_x],
Side::Top => vec![0, 0, dist + mon_y, 0, 0, 0, 0, 0, mon_x, mon_end_x, 0, 0],
Side::Bottom => vec![0, 0, 0, root_window_geometry.height as u32 - mon_end_y + dist, 0, 0, 0, 0, 0, 0, mon_x, mon_end_x],
// This should never happen but if it does the window will be anchored on the
// right of the screen
}.iter().flat_map(|x| x.to_le_bytes().to_vec()).collect();
Expand Down
15 changes: 0 additions & 15 deletions crates/eww/src/geometry.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use derive_more::*;
pub trait Rectangular {
fn get_rect(&self) -> Rect;
}

#[derive(Debug, Copy, Clone, Eq, PartialEq, Display)]
#[display(fmt = ".x*.y:.width*.height")]
Expand All @@ -11,15 +8,3 @@ pub struct Rect {
pub width: i32,
pub height: i32,
}

impl Rectangular for Rect {
fn get_rect(&self) -> Rect {
*self
}
}

impl Rectangular for gdk::Rectangle {
fn get_rect(&self) -> Rect {
Rect { x: self.x(), y: self.y(), width: self.width(), height: self.height() }
}
}
2 changes: 1 addition & 1 deletion crates/eww/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ fn listen_for_daemon_response(mut recv: DaemonResponseReceiver) {
/// attempt to send a command to the daemon and send it the given action repeatedly.
fn handle_server_command(paths: &EwwPaths, action: &ActionWithServer, connect_attempts: usize) -> Result<Option<DaemonResponse>> {
log::debug!("Trying to find server process at socket {}", paths.get_ipc_socket_file().display());
let mut stream = attempt_connect(&paths.get_ipc_socket_file(), connect_attempts).context("Failed to connect to daemon")?;
let mut stream = attempt_connect(paths.get_ipc_socket_file(), connect_attempts).context("Failed to connect to daemon")?;
log::debug!("Connected to Eww server ({}).", &paths.get_ipc_socket_file().display());
client::do_server_call(&mut stream, action).context("Error while forwarding command to server")
}
Expand Down
2 changes: 1 addition & 1 deletion crates/eww/src/script_var_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ impl ListenVarHandler {
crate::try_logging_errors!(format!("Executing listen var-command {}", &var.command) => {
let mut handle = unsafe {
tokio::process::Command::new("sh")
.args(&["-c", &var.command])
.args(["-c", &var.command])
.stdout(std::process::Stdio::piped())
.stderr(std::process::Stdio::piped())
.stdin(std::process::Stdio::null())
Expand Down
4 changes: 2 additions & 2 deletions crates/eww/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub fn initialize_server<B: DisplayBackend>(
) -> Result<ForkResult> {
let (ui_send, mut ui_recv) = tokio::sync::mpsc::unbounded_channel();

std::env::set_current_dir(&paths.get_config_dir())
std::env::set_current_dir(paths.get_config_dir())
.with_context(|| format!("Failed to change working directory to {}", paths.get_config_dir().display()))?;

log::info!("Loading paths: {}", &paths);
Expand All @@ -42,7 +42,7 @@ pub fn initialize_server<B: DisplayBackend>(
};

if should_daemonize {
let fork_result = do_detach(&paths.get_log_file())?;
let fork_result = do_detach(paths.get_log_file())?;

if fork_result == ForkResult::Parent {
return Ok(ForkResult::Parent);
Expand Down
12 changes: 6 additions & 6 deletions crates/eww/src/widgets/circular_progressbar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,27 +156,27 @@ impl WidgetImpl for CircProgPriv {
fn draw(&self, cr: &cairo::Context) -> Inhibit {
let res: Result<()> = try {
let value = *self.value.borrow();
let start_at = *self.start_at.borrow() as f64;
let thickness = *self.thickness.borrow() as f64;
let clockwise = *self.clockwise.borrow() as bool;
let start_at = *self.start_at.borrow();
let thickness = *self.thickness.borrow();
let clockwise = *self.clockwise.borrow();

let styles = self.obj().style_context();
let margin = styles.margin(gtk::StateFlags::NORMAL);
// Padding is not supported yet

Check failure on line 165 in crates/eww/src/widgets/circular_progressbar.rs

View workflow job for this annotation

GitHub Actions / build

Diff in /home/runner/work/eww/eww/crates/eww/src/widgets/circular_progressbar.rs
let fg_color: gdk::RGBA = styles.color(gtk::StateFlags::NORMAL);
let bg_color: gdk::RGBA = styles.style_property_for_state("background-color", gtk::StateFlags::NORMAL).get()?;
let (start_angle, end_angle) = if clockwise {
(0.0, perc_to_rad(value as f64))
(0.0, perc_to_rad(value))
} else {
(perc_to_rad(100.0 - value as f64), 2f64 * std::f64::consts::PI)
(perc_to_rad(100.0 - value), 2f64 * std::f64::consts::PI)
};

let total_width = self.obj().allocated_width() as f64;
let total_height = self.obj().allocated_height() as f64;
let center = (total_width / 2.0, total_height / 2.0);

let circle_width = total_width - margin.left as f64 - margin.right as f64;
let circle_height = total_height as f64 - margin.top as f64 - margin.bottom as f64;
let circle_height = total_height - margin.top as f64 - margin.bottom as f64;
let outer_ring = f64::min(circle_width, circle_height) / 2.0;
let inner_ring = (f64::min(circle_width, circle_height) / 2.0) - thickness;

Expand Down
2 changes: 1 addition & 1 deletion crates/eww/src/widgets/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ impl WidgetImpl for GraphPriv {
let (min, max) = {
let mut max = *self.max.borrow();
let min = *self.min.borrow();
let dynamic = *self.dynamic.borrow() as bool;
let dynamic = *self.dynamic.borrow();
if dynamic {
// Check for points higher than max
for (_, value) in history {
Expand Down
2 changes: 1 addition & 1 deletion crates/eww/src/widgets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub mod widget_definitions;
/// This command may use placeholders which will be replaced by the values of the arguments given.

Check failure on line 11 in crates/eww/src/widgets/mod.rs

View workflow job for this annotation

GitHub Actions / build

Diff in /home/runner/work/eww/eww/crates/eww/src/widgets/mod.rs
/// This can either be the placeholder `{}`, which will be replaced by the first argument,
/// Or a placeholder like `{0}`, `{1}`, etc, which will refer to the respective argument.
pub(self) fn run_command<T>(timeout: std::time::Duration, cmd: &str, args: &[T])
fn run_command<T>(timeout: std::time::Duration, cmd: &str, args: &[T])
where
T: 'static + std::fmt::Display + Send + Sync + Clone,
{
Expand Down
18 changes: 9 additions & 9 deletions crates/eww/src/widgets/widget_definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub const BUILTIN_WIDGET_NAMES: &[&str] = &[
WIDGET_NAME_STACK,
];

//// widget definitions
/// widget definitions
pub(super) fn widget_use_to_gtk_widget(bargs: &mut BuilderArgs) -> Result<gtk::Widget> {
let gtk_widget = match bargs.widget_use.name.as_str() {
WIDGET_NAME_BOX => build_gtk_box(bargs)?.upcast(),
Expand Down Expand Up @@ -1050,7 +1050,7 @@ fn build_circular_progress_bar(bargs: &mut BuilderArgs) -> Result<CircProg> {
// @prop thickness - the thickness of the circle
prop(thickness: as_f64) { w.set_property("thickness", thickness); },
// @prop clockwise - wether the progress bar spins clockwise or counter clockwise
prop(clockwise: as_bool) { w.set_property("clockwise", &clockwise); },
prop(clockwise: as_bool) { w.set_property("clockwise", clockwise); },
});
Ok(w)
}
Expand All @@ -1062,11 +1062,11 @@ fn build_graph(bargs: &mut BuilderArgs) -> Result<super::graph::Graph> {
let w = super::graph::Graph::new();
def_widget!(bargs, _g, w, {
// @prop value - the value, between 0 - 100
prop(value: as_f64) { w.set_property("value", &value); },
prop(value: as_f64) { w.set_property("value", value); },
// @prop thickness - the thickness of the line
prop(thickness: as_f64) { w.set_property("thickness", &thickness); },
prop(thickness: as_f64) { w.set_property("thickness", thickness); },
// @prop time-range - the range of time to show
prop(time_range: as_duration) { w.set_property("time-range", &(time_range.as_millis() as u64)); },
prop(time_range: as_duration) { w.set_property("time-range", time_range.as_millis() as u64); },
// @prop min - the minimum value to show (defaults to 0 if value_max is provided)
// @prop max - the maximum value to show
prop(min: as_f64 = 0, max: as_f64 = 100) {
Expand All @@ -1075,14 +1075,14 @@ fn build_graph(bargs: &mut BuilderArgs) -> Result<super::graph::Graph> {
format!("Graph's min ({min}) should never be higher than max ({max})")
)).into());
}
w.set_property("min", &min);
w.set_property("max", &max);
w.set_property("min", min);
w.set_property("max", max);
},
// @prop dynamic - whether the y range should dynamically change based on value
prop(dynamic: as_bool) { w.set_property("dynamic", &dynamic); },
prop(dynamic: as_bool) { w.set_property("dynamic", dynamic); },
// @prop line-style - changes the look of the edges in the graph. Values: "miter" (default), "round",
// "bevel"
prop(line_style: as_string) { w.set_property("line-style", &line_style); },
prop(line_style: as_string) { w.set_property("line-style", line_style); },
});
Ok(w)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/eww/src/window_arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl WindowArguments {
}

if local_variables.len() != window_def.expected_args.len() {
let unexpected_vars: Vec<_> = local_variables.keys().cloned().filter(|n| !expected_args.contains(&n.0)).collect();
let unexpected_vars: Vec<_> = local_variables.keys().filter(|&n| !expected_args.contains(&n.0)).cloned().collect();
bail!(
"variables {} unexpectedly defined when creating window with id '{}'",
unexpected_vars.join(", "),
Expand Down

0 comments on commit 6f3d010

Please sign in to comment.