diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index 1c2615551..ebedf23a4 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -4,7 +4,6 @@ use std::sync::Arc; use color_eyre::eyre::anyhow; use color_eyre::Result; -use crossbeam_channel::select; use parking_lot::Mutex; use komorebi_core::OperationDirection; @@ -42,14 +41,10 @@ pub fn listen_for_events(wm: Arc>) { std::thread::spawn(move || { tracing::info!("listening"); loop { - select! { - recv(receiver) -> mut maybe_event => { - if let Ok(event) = maybe_event.as_mut() { - match wm.lock().process_event(event) { - Ok(()) => {}, - Err(error) => tracing::error!("{}", error) - } - } + if let Ok(event) = receiver.recv() { + match wm.lock().process_event(event) { + Ok(()) => {} + Err(error) => tracing::error!("{}", error), } } } @@ -59,13 +54,13 @@ pub fn listen_for_events(wm: Arc>) { impl WindowManager { #[allow(clippy::too_many_lines, clippy::cognitive_complexity)] #[tracing::instrument(skip(self))] - pub fn process_event(&mut self, event: &mut WindowManagerEvent) -> Result<()> { + pub fn process_event(&mut self, event: WindowManagerEvent) -> Result<()> { if self.is_paused { tracing::trace!("ignoring while paused"); return Ok(()); } - let should_manage = event.window().should_manage(Some(*event))?; + let should_manage = event.window().should_manage(Some(event))?; // Hide or reposition the window based on whether the target is managed. if BORDER_ENABLED.load(Ordering::SeqCst) { @@ -73,7 +68,7 @@ impl WindowManager { let border_window = Border::from(BORDER_HWND.load(Ordering::SeqCst)); if should_manage { - border_window.set_position(*window, true)?; + border_window.set_position(window, true)?; } else { let mut stackbar = false; if let Ok(class) = window.class() { @@ -122,7 +117,7 @@ impl WindowManager { | WindowManagerEvent::MoveResizeEnd(_, window) => { self.reconcile_monitors()?; - let monitor_idx = self.monitor_idx_from_window(*window) + let monitor_idx = self.monitor_idx_from_window(window) .ok_or_else(|| anyhow!("there is no monitor associated with this window, it may have already been destroyed"))?; // This is a hidden window apparently associated with COM support mechanisms (based @@ -329,14 +324,14 @@ impl WindowManager { if !workspace.contains_window(window.hwnd) { match behaviour { WindowContainerBehaviour::Create => { - workspace.new_container_for_window(*window); + workspace.new_container_for_window(window); self.update_focused_workspace(false)?; } WindowContainerBehaviour::Append => { workspace .focused_container_mut() .ok_or_else(|| anyhow!("there is no focused container"))? - .add_window(*window); + .add_window(window); self.update_focused_workspace(true)?; } } @@ -607,7 +602,7 @@ impl WindowManager { .iter() .any(|w| w.hwnd == window.hwnd) { - target_window = Option::from(*window); + target_window = Option::from(window); WindowsApi::raise_window(border.hwnd())?; }; @@ -700,7 +695,7 @@ impl WindowManager { serde_json::to_writer_pretty(&file, &known_hwnds)?; notify_subscribers(&serde_json::to_string(&Notification { - event: NotificationEvent::WindowManager(*event), + event: NotificationEvent::WindowManager(event), state: self.as_ref().into(), })?)?; diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index 019aa0c56..eb2e98d98 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -125,7 +125,7 @@ impl Window { HWND(self.hwnd) } - pub fn center(&mut self, work_area: &Rect) -> Result<()> { + pub fn center(&self, work_area: &Rect) -> Result<()> { let half_width = work_area.right / 2; let half_weight = work_area.bottom / 2; @@ -140,7 +140,7 @@ impl Window { ) } - pub fn set_position(&mut self, layout: &Rect, top: bool) -> Result<()> { + pub fn set_position(&self, layout: &Rect, top: bool) -> Result<()> { let rect = *layout; WindowsApi::position_window(self.hwnd(), &rect, top) }