diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index a11c1231..dbb3b91c 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -39,6 +39,7 @@ lazy_static! { static ref FLOAT_CLASSES: Arc>> = Arc::new(Mutex::new(vec![])); static ref FLOAT_EXES: Arc>> = Arc::new(Mutex::new(vec![])); static ref FLOAT_TITLES: Arc>> = Arc::new(Mutex::new(vec![])); + static ref HIDDEN_HWNDS: Arc>> = Arc::new(Mutex::new(vec![])); static ref LAYERED_EXE_WHITELIST: Arc>> = Arc::new(Mutex::new(vec!["steam.exe".to_string()])); static ref MULTI_WINDOW_EXES: Arc>> = Arc::new(Mutex::new(vec![ diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index 48830e8a..3a1d964d 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -9,6 +9,7 @@ use crossbeam_channel::select; use crate::window_manager::WindowManager; use crate::window_manager_event::WindowManagerEvent; +use crate::HIDDEN_HWNDS; use crate::MULTI_WINDOW_EXES; #[tracing::instrument] @@ -88,7 +89,10 @@ impl WindowManager { // Some major applications unfortunately send the HIDE signal when they are being // minimized or destroyed. Will have to keep updating this list. let common_multi_window_exes = MULTI_WINDOW_EXES.lock().unwrap(); - if !window.is_window() || common_multi_window_exes.contains(&window.exe()?) { + let programmatically_hidden_hwnds = HIDDEN_HWNDS.lock().unwrap(); + if (!window.is_window() || common_multi_window_exes.contains(&window.exe()?)) + && !programmatically_hidden_hwnds.contains(&window.hwnd) + { self.focused_workspace_mut()?.remove_window(window.hwnd)?; self.update_focused_workspace(false)?; } diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index 98c50ce1..8195126a 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -18,6 +18,7 @@ use crate::windows_api::WindowsApi; use crate::FLOAT_CLASSES; use crate::FLOAT_EXES; use crate::FLOAT_TITLES; +use crate::HIDDEN_HWNDS; use crate::LAYERED_EXE_WHITELIST; #[derive(Debug, Clone, Copy)] @@ -109,10 +110,23 @@ impl Window { } pub fn hide(self) { + let mut programmatically_hidden_hwnds = HIDDEN_HWNDS.lock().unwrap(); + if !programmatically_hidden_hwnds.contains(&self.hwnd) { + programmatically_hidden_hwnds.push(self.hwnd); + } + WindowsApi::hide_window(self.hwnd()); } pub fn restore(self) { + let mut programmatically_hidden_hwnds = HIDDEN_HWNDS.lock().unwrap(); + if let Some(idx) = programmatically_hidden_hwnds + .iter() + .position(|&hwnd| hwnd == self.hwnd) + { + programmatically_hidden_hwnds.remove(idx); + } + WindowsApi::restore_window(self.hwnd()); }