fix(subscriptions): emit ws event on empty targets

This commit ensures that workspace change events get emitted even when
changing to workspaces with no window containers. Previously these were
failing due to early returns triggered when the workspace focused did
not have a focused container.
This commit is contained in:
LGUG2Z
2024-03-02 11:15:18 -08:00
parent 6781f34930
commit 38b0418c3b
2 changed files with 15 additions and 10 deletions
+8 -4
View File
@@ -1389,10 +1389,14 @@ impl WindowManager {
); );
} }
let stack = BORDER_COLOUR_STACK.load(Ordering::SeqCst); // it is not acceptable to fail here; we need to be able to send the event to
if stack != 0 && self.focused_container()?.windows().len() > 1 { // subscribers
BORDER_COLOUR_CURRENT if self.focused_container().is_ok() {
.store(stack, Ordering::SeqCst); let stack = BORDER_COLOUR_STACK.load(Ordering::SeqCst);
if stack != 0 && self.focused_container()?.windows().len() > 1 {
BORDER_COLOUR_CURRENT
.store(stack, Ordering::SeqCst);
}
} }
let border = Border::from(BORDER_HWND.load(Ordering::SeqCst)); let border = Border::from(BORDER_HWND.load(Ordering::SeqCst));
+7 -6
View File
@@ -852,17 +852,18 @@ impl WindowManager {
} }
} }
// if we passed false for follow_focus // if we passed false for follow_focus and there is a container on the workspace
if !follow_focus if !follow_focus && self.focused_container_mut().is_ok() {
// and we have a stack with >1 windows // and we have a stack with >1 windows
&& self.focused_container_mut()?.windows().len() > 1 if self.focused_container_mut()?.windows().len() > 1
// and we don't have a maxed window // and we don't have a maxed window
&& self.focused_workspace()?.maximized_window().is_none() && self.focused_workspace()?.maximized_window().is_none()
// and we don't have a monocle container // and we don't have a monocle container
&& self.focused_workspace()?.monocle_container().is_none() && self.focused_workspace()?.monocle_container().is_none()
{ {
if let Ok(window) = self.focused_window_mut() { if let Ok(window) = self.focused_window_mut() {
window.focus(self.mouse_follows_focus)?; window.focus(self.mouse_follows_focus)?;
}
} }
}; };