From d8d087e6211900bf72616b11416fb3e6613115dc Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 13 Apr 2024 10:56:35 -0700 Subject: [PATCH] fix(wm): ensure borders are drawn w/ stackbar This commit fixes a small regression and ensures that the active window border, when enabled, will be drawn as expected when a container stack has a stackbar active. --- komorebi/src/process_event.rs | 12 +++++++++++- komorebi/src/window.rs | 7 ++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index d3c744002..63be96c20 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -71,10 +71,20 @@ impl WindowManager { if BORDER_ENABLED.load(Ordering::SeqCst) { if let WindowManagerEvent::FocusChange(_, window) = event { let border_window = Border::from(BORDER_HWND.load(Ordering::SeqCst)); + if should_manage { border_window.set_position(*window, true)?; } else { - border_window.hide()?; + let mut stackbar = false; + if let Ok(class) = window.class() { + if class == "komorebi_stackbar" { + stackbar = true; + } + } + + if !stackbar { + border_window.hide()?; + } } } } diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index 3d3c3be41..c18317b59 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -400,7 +400,12 @@ impl Window { // If not allowing cloaked windows, we need to ensure the window is not cloaked (false, false) => { if let (Ok(title), Ok(exe_name), Ok(class), Ok(path)) = (self.title(), self.exe(), self.class(), self.path()) { - return Ok(window_is_eligible(&title, &exe_name, &class, &path, &self.style()?, &self.ex_style()?, event)); + // calls for styles can fail quite often for events with windows that aren't really "windows" + // since we have moved up calls of should_manage to the beginning of the process_event handler, + // we should handle failures here gracefully to be able to continue the execution of process_event + if let (Ok(style), Ok(ex_style)) = (&self.style(), &self.ex_style()) { + return Ok(window_is_eligible(&title, &exe_name, &class, &path, style, ex_style, event)); + } } } _ => {}