Skip to content

Commit

Permalink
fix(subscriptions): emit ws event on empty targets
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
LGUG2Z committed Mar 2, 2024
1 parent 6781f34 commit 38b0418
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
12 changes: 8 additions & 4 deletions komorebi/src/process_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1389,10 +1389,14 @@ impl WindowManager {
);
}

let stack = BORDER_COLOUR_STACK.load(Ordering::SeqCst);
if stack != 0 && self.focused_container()?.windows().len() > 1 {
BORDER_COLOUR_CURRENT
.store(stack, Ordering::SeqCst);
// it is not acceptable to fail here; we need to be able to send the event to
// subscribers
if self.focused_container().is_ok() {
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));
Expand Down
13 changes: 7 additions & 6 deletions komorebi/src/window_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -852,17 +852,18 @@ impl WindowManager {
}
}

// if we passed false for follow_focus
if !follow_focus
// if we passed false for follow_focus and there is a container on the workspace
if !follow_focus && self.focused_container_mut().is_ok() {
// 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
&& self.focused_workspace()?.maximized_window().is_none()
// and we don't have a monocle container
&& self.focused_workspace()?.monocle_container().is_none()
{
if let Ok(window) = self.focused_window_mut() {
window.focus(self.mouse_follows_focus)?;
{
if let Ok(window) = self.focused_window_mut() {
window.focus(self.mouse_follows_focus)?;
}
}
};

Expand Down

0 comments on commit 38b0418

Please sign in to comment.