diff --git a/crates/eww/src/config/eww_config.rs b/crates/eww/src/config/eww_config.rs index 59229c800..46caebf70 100644 --- a/crates/eww/src/config/eww_config.rs +++ b/crates/eww/src/config/eww_config.rs @@ -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)?; diff --git a/crates/eww/src/config/mod.rs b/crates/eww/src/config/mod.rs index 21dab5c05..237c8fe53 100644 --- a/crates/eww/src/config/mod.rs +++ b/crates/eww/src/config/mod.rs @@ -6,4 +6,4 @@ pub mod system_stats; pub mod window_definition; pub use eww_config::*; pub use script_var::*; -pub use window_definition::*; + diff --git a/crates/eww/src/display_backend.rs b/crates/eww/src/display_backend.rs index e653123ee..74a6033e2 100644 --- a/crates/eww/src/display_backend.rs +++ b/crates/eww/src/display_backend.rs @@ -197,8 +197,8 @@ mod platform_x11 { let strut_list: Vec = 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(); diff --git a/crates/eww/src/geometry.rs b/crates/eww/src/geometry.rs index 1b845a5d5..bde5180fc 100644 --- a/crates/eww/src/geometry.rs +++ b/crates/eww/src/geometry.rs @@ -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")] @@ -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() } - } -} diff --git a/crates/eww/src/main.rs b/crates/eww/src/main.rs index 1364bf1eb..f142c0e4f 100644 --- a/crates/eww/src/main.rs +++ b/crates/eww/src/main.rs @@ -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> { 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") } diff --git a/crates/eww/src/script_var_handler.rs b/crates/eww/src/script_var_handler.rs index 0847b72be..91aa2010c 100644 --- a/crates/eww/src/script_var_handler.rs +++ b/crates/eww/src/script_var_handler.rs @@ -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()) diff --git a/crates/eww/src/server.rs b/crates/eww/src/server.rs index 5a7ecc873..66cb4f640 100644 --- a/crates/eww/src/server.rs +++ b/crates/eww/src/server.rs @@ -26,7 +26,7 @@ pub fn initialize_server( ) -> Result { 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); @@ -42,7 +42,7 @@ pub fn initialize_server( }; 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); diff --git a/crates/eww/src/widgets/circular_progressbar.rs b/crates/eww/src/widgets/circular_progressbar.rs index 02d015511..5593c8c51 100644 --- a/crates/eww/src/widgets/circular_progressbar.rs +++ b/crates/eww/src/widgets/circular_progressbar.rs @@ -156,9 +156,9 @@ 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); @@ -166,9 +166,9 @@ impl WidgetImpl for CircProgPriv { 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; @@ -176,7 +176,7 @@ impl WidgetImpl for CircProgPriv { 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; diff --git a/crates/eww/src/widgets/graph.rs b/crates/eww/src/widgets/graph.rs index 60814d993..463c8bcd8 100644 --- a/crates/eww/src/widgets/graph.rs +++ b/crates/eww/src/widgets/graph.rs @@ -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 { diff --git a/crates/eww/src/widgets/mod.rs b/crates/eww/src/widgets/mod.rs index e5e25b7c6..82980e96c 100644 --- a/crates/eww/src/widgets/mod.rs +++ b/crates/eww/src/widgets/mod.rs @@ -11,7 +11,7 @@ pub mod widget_definitions; /// This command may use placeholders which will be replaced by the values of the arguments given. /// 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(timeout: std::time::Duration, cmd: &str, args: &[T]) + fn run_command(timeout: std::time::Duration, cmd: &str, args: &[T]) where T: 'static + std::fmt::Display + Send + Sync + Clone, { diff --git a/crates/eww/src/widgets/widget_definitions.rs b/crates/eww/src/widgets/widget_definitions.rs index 20b1f9ab4..01b5056c6 100644 --- a/crates/eww/src/widgets/widget_definitions.rs +++ b/crates/eww/src/widgets/widget_definitions.rs @@ -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 { let gtk_widget = match bargs.widget_use.name.as_str() { WIDGET_NAME_BOX => build_gtk_box(bargs)?.upcast(), @@ -1050,7 +1050,7 @@ fn build_circular_progress_bar(bargs: &mut BuilderArgs) -> Result { // @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) } @@ -1062,11 +1062,11 @@ fn build_graph(bargs: &mut BuilderArgs) -> Result { 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) { @@ -1075,14 +1075,14 @@ fn build_graph(bargs: &mut BuilderArgs) -> Result { 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) } diff --git a/crates/eww/src/window_arguments.rs b/crates/eww/src/window_arguments.rs index 8833bac91..44681e9e0 100644 --- a/crates/eww/src/window_arguments.rs +++ b/crates/eww/src/window_arguments.rs @@ -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(", "),