Skip to content

Commit

Permalink
feat: allow empty workspaces to be focused in focus_in_direction
Browse files Browse the repository at this point in the history
  • Loading branch information
lars-berger committed Jul 31, 2024
1 parent 27c86db commit 89d8952
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions packages/wm/src/containers/commands/focus_in_direction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,18 @@ fn workspace_focus_target(
) -> anyhow::Result<Option<Container>> {
let monitor = origin_container.monitor().context("No monitor.")?;

let focus_target = state
let target_workspace = state
.monitor_in_direction(&monitor, direction)?
.and_then(|monitor| monitor.displayed_workspace())
.and_then(|monitor| monitor.displayed_workspace());

let focus_target = target_workspace
.as_ref()
.and_then(|workspace| {
workspace.descendant_in_direction(&direction.inverse())
});
workspace
.descendant_in_direction(&direction.inverse())
.map(Into::into)
})
.or(target_workspace.map(Into::into));

Ok(focus_target.map(Into::into))
Ok(focus_target)
}

0 comments on commit 89d8952

Please sign in to comment.