Skip to content

Commit

Permalink
fix(wm): cycle stack focus w/ mff disabled
Browse files Browse the repository at this point in the history
This commit ensures that the focus changes to the appropriate window
when a container stack is being cycled through by a user who has
disabled the mouse_follows_focus feature.

fix #680
  • Loading branch information
LGUG2Z committed Feb 24, 2024
1 parent 0160e8e commit a6deeef
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
14 changes: 14 additions & 0 deletions komorebi/src/window_manager.rs
Expand Up @@ -866,6 +866,20 @@ impl WindowManager {
}
}

// if we passed false for follow_focus
if !follow_focus
// and we have a stack with >1 windows
&& 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)?;
}
};

Ok(())
}

Expand Down
18 changes: 9 additions & 9 deletions komorebi/src/windows_callbacks.rs
Expand Up @@ -239,9 +239,9 @@ pub extern "system" fn hidden_window(
match message {
WM_DISPLAYCHANGE => {
let event_type = WindowManagerEvent::DisplayChange(Window { hwnd: window.0 });
winevent_listener::event_tx()
.send(event_type)
.expect("could not send message on winevent_listener::event_tx");
winevent_listener::event_tx()
.send(event_type)
.expect("could not send message on winevent_listener::event_tx");

LRESULT(0)
}
Expand All @@ -252,9 +252,9 @@ pub extern "system" fn hidden_window(
|| wparam.0 as u32 == SPI_ICONVERTICALSPACING.0
{
let event_type = WindowManagerEvent::DisplayChange(Window { hwnd: window.0 });
winevent_listener::event_tx()
.send(event_type)
.expect("could not send message on winevent_listener::event_tx");
winevent_listener::event_tx()
.send(event_type)
.expect("could not send message on winevent_listener::event_tx");
}
LRESULT(0)
}
Expand All @@ -263,9 +263,9 @@ pub extern "system" fn hidden_window(
#[allow(clippy::cast_possible_truncation)]
if wparam.0 as u32 == DBT_DEVNODES_CHANGED {
let event_type = WindowManagerEvent::DisplayChange(Window { hwnd: window.0 });
winevent_listener::event_tx()
.send(event_type)
.expect("could not send message on winevent_listener::event_tx");
winevent_listener::event_tx()
.send(event_type)
.expect("could not send message on winevent_listener::event_tx");
}
LRESULT(0)
}
Expand Down

0 comments on commit a6deeef

Please sign in to comment.