diff --git a/komorebi/src/container.rs b/komorebi/src/container.rs index 206136bb2..74d780e9b 100644 --- a/komorebi/src/container.rs +++ b/komorebi/src/container.rs @@ -159,26 +159,33 @@ impl Container { } pub fn set_stackbar_mode(&mut self, mode: StackbarMode) { - self.stackbar = match mode { - StackbarMode::Always => Stackbar::create().ok(), - StackbarMode::Never => None, + match mode { + StackbarMode::Always => { + if self.stackbar.is_none() { + self.stackbar = Stackbar::create().ok(); + } + } + StackbarMode::Never => { + if self.stackbar.is_some() { + self.stackbar = None + } + } StackbarMode::OnStack => { if self.windows().len() > 1 && self.stackbar().is_none() { - Stackbar::create().ok() - } else { - None + self.stackbar = Stackbar::create().ok(); + } + + if self.windows().len() == 1 && self.stackbar.is_some() { + self.stackbar = None; } } - }; + } } pub fn renew_stackbar(&mut self) { - match &self.stackbar { - None => {} - Some(stackbar) => { - if !WindowsApi::is_window(stackbar.hwnd()) { - self.stackbar = Stackbar::create().ok() - } + if let Some(stackbar) = &self.stackbar { + if !WindowsApi::is_window(stackbar.hwnd()) { + self.stackbar = Stackbar::create().ok() } } } diff --git a/komorebi/src/stackbar.rs b/komorebi/src/stackbar.rs index de7facb7a..bca18500f 100644 --- a/komorebi/src/stackbar.rs +++ b/komorebi/src/stackbar.rs @@ -74,6 +74,7 @@ pub struct Stackbar { impl Drop for Stackbar { fn drop(&mut self) { if !self.is_cloned { + tracing::debug!("dropping and calling close_window on stackbar"); let _ = WindowsApi::close_window(self.hwnd()); } } @@ -87,6 +88,7 @@ impl Clone for Stackbar { } } } + impl Stackbar { unsafe extern "system" fn window_proc( hwnd: HWND,