feat(wm): focus to last container across monitors

This commit ensures that when focusing across a monitor boundary, the
focus will go to the last focused window container on the focused
workspace on the other side of a given window boundary.

re #145
This commit is contained in:
LGUG2Z
2022-06-21 07:54:27 -07:00
committed by جاد
parent 336a4e358f
commit 85f9c381e5

View File

@@ -940,19 +940,19 @@ impl WindowManager {
let new_idx = workspace.new_idx_for_direction(direction);
// if there is no container in that direction for this workspace
if new_idx.is_none() {
// check if there is a monitor in that direction
let monitor_idx = self
.monitor_index_in_direction(direction)
.ok_or_else(|| anyhow!("there is no container or monitor in this direction"))?;
self.focus_monitor(monitor_idx)?;
}
match new_idx {
None => {
let monitor_idx = self
.monitor_index_in_direction(direction)
.ok_or_else(|| anyhow!("there is no container or monitor in this direction"))?;
let workspace = self.focused_workspace_mut()?;
workspace.focus_container(new_idx.unwrap_or_else(|| match direction {
OperationDirection::Right | OperationDirection::Down => 0,
OperationDirection::Left | OperationDirection::Up => workspace.containers().len() - 1,
}));
self.focus_monitor(monitor_idx)?;
}
Some(idx) => {
let workspace = self.focused_workspace_mut()?;
workspace.focus_container(idx);
}
}
self.focused_window_mut()?.focus(self.mouse_follows_focus)?;