mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-03-18 07:23:57 +01:00
fix(wm): track programmatically hidden hwnds
Introducing another global Vec to keep track of HWNDs that have been hidden by komorebi, so that when responding to ObjectHide WinEvents, we don't stop managing windows that we have hidden when cycling through container stacks.
This commit is contained in:
@@ -39,6 +39,7 @@ lazy_static! {
|
||||
static ref FLOAT_CLASSES: Arc<Mutex<Vec<String>>> = Arc::new(Mutex::new(vec![]));
|
||||
static ref FLOAT_EXES: Arc<Mutex<Vec<String>>> = Arc::new(Mutex::new(vec![]));
|
||||
static ref FLOAT_TITLES: Arc<Mutex<Vec<String>>> = Arc::new(Mutex::new(vec![]));
|
||||
static ref HIDDEN_HWNDS: Arc<Mutex<Vec<isize>>> = Arc::new(Mutex::new(vec![]));
|
||||
static ref LAYERED_EXE_WHITELIST: Arc<Mutex<Vec<String>>> =
|
||||
Arc::new(Mutex::new(vec!["steam.exe".to_string()]));
|
||||
static ref MULTI_WINDOW_EXES: Arc<Mutex<Vec<String>>> = Arc::new(Mutex::new(vec![
|
||||
|
||||
@@ -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)?;
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user