diff --git a/README.md b/README.md index 2b63c945..2e1721c9 100644 --- a/README.md +++ b/README.md @@ -363,6 +363,9 @@ komorebic.exe active-window-border-colour [R G B] --window-kind single # optionally, if you want a different colour for stacks of windows komorebic.exe active-window-border-colour [R G B] --window-kind stack + +# optionally, if you want a different colour for windows in monocle mode +komorebic.exe active-window-border-colour [R G B] --window-kind monocle ``` It is important to note that the active window border will only apply to windows managed by `komorebi`. diff --git a/komorebi-core/src/lib.rs b/komorebi-core/src/lib.rs index 6c7fbd8a..4e0e0962 100644 --- a/komorebi-core/src/lib.rs +++ b/komorebi-core/src/lib.rs @@ -168,6 +168,7 @@ impl FromStr for SocketMessage { pub enum WindowKind { Single, Stack, + Monocle, } #[derive( diff --git a/komorebi.sample.ps1 b/komorebi.sample.ps1 index b4ec08ba..bfc2fbe2 100644 --- a/komorebi.sample.ps1 +++ b/komorebi.sample.ps1 @@ -37,6 +37,7 @@ komorebic invisible-borders 7 0 14 7 # Uncomment the next lines if you want a visual border around the active window # komorebic active-window-border-colour 66 165 245 --window-kind single # komorebic active-window-border-colour 256 165 66 --window-kind stack +# komorebic active-window-border-colour 255 51 153 --window-kind monocle # komorebic active-window-border enable komorebic complete-configuration \ No newline at end of file diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index d7e8b411..089a4b76 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -163,6 +163,7 @@ pub static BORDER_HWND: AtomicIsize = AtomicIsize::new(0); pub static BORDER_HIDDEN: AtomicBool = AtomicBool::new(false); pub static BORDER_COLOUR_SINGLE: AtomicU32 = AtomicU32::new(0); pub static BORDER_COLOUR_STACK: AtomicU32 = AtomicU32::new(0); +pub static BORDER_COLOUR_MONOCLE: AtomicU32 = AtomicU32::new(0); pub static BORDER_COLOUR_CURRENT: AtomicU32 = AtomicU32::new(0); pub static BORDER_WIDTH: AtomicI32 = AtomicI32::new(20); // 0 0 0 aka pure black, I doubt anyone will want this as a border colour diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index f4f8ea5b..73bcb025 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -44,6 +44,7 @@ use crate::Notification; use crate::NotificationEvent; use crate::ALT_FOCUS_HACK; use crate::BORDER_COLOUR_CURRENT; +use crate::BORDER_COLOUR_MONOCLE; use crate::BORDER_COLOUR_SINGLE; use crate::BORDER_COLOUR_STACK; use crate::BORDER_ENABLED; @@ -1027,6 +1028,9 @@ impl WindowManager { WindowKind::Stack => { BORDER_COLOUR_STACK.store(r | (g << 8) | (b << 16), Ordering::SeqCst); } + WindowKind::Monocle => { + BORDER_COLOUR_MONOCLE.store(r | (g << 8) | (b << 16), Ordering::SeqCst); + } } WindowsApi::invalidate_border_rect()?; @@ -1075,9 +1079,30 @@ impl WindowManager { }; match message { + SocketMessage::ToggleMonocle => { + let current = BORDER_COLOUR_CURRENT.load(Ordering::SeqCst); + let monocle = BORDER_COLOUR_MONOCLE.load(Ordering::SeqCst); + + if monocle != 0 { + if current == monocle { + BORDER_COLOUR_CURRENT.store( + BORDER_COLOUR_SINGLE.load(Ordering::SeqCst), + Ordering::SeqCst, + ); + } else { + BORDER_COLOUR_CURRENT.store( + BORDER_COLOUR_MONOCLE.load(Ordering::SeqCst), + Ordering::SeqCst, + ); + } + } + } SocketMessage::StackWindow(_) => { - BORDER_COLOUR_CURRENT - .store(BORDER_COLOUR_STACK.load(Ordering::SeqCst), Ordering::SeqCst); + let stack = BORDER_COLOUR_STACK.load(Ordering::SeqCst); + if stack != 0 { + BORDER_COLOUR_CURRENT + .store(BORDER_COLOUR_STACK.load(Ordering::SeqCst), Ordering::SeqCst); + } } SocketMessage::UnstackWindow => { BORDER_COLOUR_CURRENT.store( diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index 89562a49..cc9fa441 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -21,6 +21,7 @@ use crate::windows_api::WindowsApi; use crate::Notification; use crate::NotificationEvent; use crate::BORDER_COLOUR_CURRENT; +use crate::BORDER_COLOUR_MONOCLE; use crate::BORDER_COLOUR_SINGLE; use crate::BORDER_COLOUR_STACK; use crate::BORDER_ENABLED; @@ -510,6 +511,7 @@ impl WindowManager { | WindowManagerEvent::Minimize(_, window) => { let border = Border::from(BORDER_HWND.load(Ordering::SeqCst)); let mut target_window = None; + let mut target_window_is_monocle = false; if self .focused_workspace()? .floating_windows() @@ -523,6 +525,7 @@ impl WindowManager { if let Some(monocle_container) = self.focused_workspace()?.monocle_container() { if let Some(window) = monocle_container.focused_window() { target_window = Option::from(*window); + target_window_is_monocle = true; } } @@ -539,7 +542,12 @@ impl WindowManager { let container_size = self.focused_container()?.windows().len(); target_window = Option::from(*self.focused_window()?); - if container_size > 1 { + if target_window_is_monocle { + BORDER_COLOUR_CURRENT.store( + BORDER_COLOUR_MONOCLE.load(Ordering::SeqCst), + Ordering::SeqCst, + ); + } else if container_size > 1 { BORDER_COLOUR_CURRENT.store( BORDER_COLOUR_STACK.load(Ordering::SeqCst), Ordering::SeqCst,