From 3f3c2815da5bf1f83a627c79915a4a4cff5c7ce9 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Thu, 21 Oct 2021 14:30:38 -0700 Subject: [PATCH] feature(wm): manage linux gui apps by default This commit introduces an allow_wsl2_gui override in Window.should_manage() which ensures that Linux GUI apps being run through WSLg, VcXsrv or X410 will be automatically tiled. For now the exes that trigger this override are kept in a static Vec in the codebase, but this could be made configurable in the future if there is a specific feature request. resolve #52, resolve #53 --- komorebi/src/main.rs | 5 +++++ komorebi/src/window.rs | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index c9f80cef..4d4917b9 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -74,6 +74,11 @@ lazy_static! { static ref MANAGE_IDENTIFIERS: Arc>> = Arc::new(Mutex::new(vec![])); static ref FLOAT_IDENTIFIERS: Arc>> = Arc::new(Mutex::new(vec![])); static ref BORDER_OVERFLOW_IDENTIFIERS: Arc>> = Arc::new(Mutex::new(vec![])); + static ref WSL2_UI_PROCESSES: Arc>> = Arc::new(Mutex::new(vec![ + "X410.exe".to_string(), + "mstsc.exe".to_string(), + "vcxsrv.exe".to_string(), + ])); } pub static CUSTOM_FFM: AtomicBool = AtomicBool::new(false); diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index ffef4240..165cd6cf 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -20,6 +20,7 @@ use crate::FLOAT_IDENTIFIERS; use crate::HIDDEN_HWNDS; use crate::LAYERED_EXE_WHITELIST; use crate::MANAGE_IDENTIFIERS; +use crate::WSL2_UI_PROCESSES; #[derive(Debug, Clone, Copy)] pub struct Window { @@ -271,11 +272,15 @@ impl Window { layered_exe_whitelist.contains(&exe_name) }; + let allow_wsl2_gui = { + let wsl2_ui_processes = WSL2_UI_PROCESSES.lock(); + wsl2_ui_processes.contains(&exe_name) + }; + let style = self.style()?; let ex_style = self.ex_style()?; - if style.contains(GwlStyle::CAPTION) - && ex_style.contains(GwlExStyle::WINDOWEDGE) + if (allow_wsl2_gui || style.contains(GwlStyle::CAPTION) && ex_style.contains(GwlExStyle::WINDOWEDGE)) && !ex_style.contains(GwlExStyle::DLGMODALFRAME) // Get a lot of dupe events coming through that make the redrawing go crazy // on FocusChange events if I don't filter out this one. But, if we are