mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-07-01 18:51:36 +02:00
fix(wm): always focus desktop on empty ws
This commit ensures that when switching to a workspace, if that workspace is empty, the desktop window will be focused (and focus will be removed from the last focused window on the previous workspace) regardless of the value of follow_focus.
This commit is contained in:
@@ -825,28 +825,37 @@ impl WindowManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
if self.focused_workspace()?.containers().is_empty() {
|
||||||
|
let desktop_window = Window::from(WindowsApi::desktop_window()?);
|
||||||
|
|
||||||
// if we passed false for follow_focus and there is a container on the workspace
|
match WindowsApi::raise_and_focus_window(desktop_window.hwnd) {
|
||||||
if !follow_focus && self.focused_container_mut().is_ok() {
|
Ok(()) => {}
|
||||||
// and we have a stack with >1 windows
|
Err(error) => {
|
||||||
if self.focused_container_mut()?.windows().len() > 1
|
tracing::warn!("{} {}:{}", error, file!(), line!());
|
||||||
// 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() {
|
|
||||||
if trigger_focus {
|
|
||||||
window.focus(self.mouse_follows_focus)?;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// This is to correctly restore and focus when switching to a workspace which
|
// if we passed false for follow_focus and there is a container on the workspace
|
||||||
// contains a managed maximized window
|
if self.focused_container_mut().is_ok() {
|
||||||
if !follow_focus {
|
// and we have a stack with >1 windows
|
||||||
|
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() {
|
||||||
|
if trigger_focus {
|
||||||
|
window.focus(self.mouse_follows_focus)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is to correctly restore and focus when switching to a workspace which
|
||||||
|
// contains a managed maximized window
|
||||||
if let Some(window) = self.focused_workspace()?.maximized_window() {
|
if let Some(window) = self.focused_workspace()?.maximized_window() {
|
||||||
window.restore();
|
window.restore();
|
||||||
if trigger_focus {
|
if trigger_focus {
|
||||||
|
|||||||
Reference in New Issue
Block a user