Skip to content

Commit

Permalink
feat(wm): allow cycling for max & monacle windows
Browse files Browse the repository at this point in the history
This commit introduces focus cycling behaviour for a workspace when
either a maximized window or a monocle window exists.

Now, the container in the cycle direction relative to the current window
container will take the maximized or monocle window container space
whenever the cycle-focus command is called.

resolve #97
  • Loading branch information
LGUG2Z committed Mar 29, 2022
1 parent 75234ca commit a4e8286
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions komorebi/src/window_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -908,14 +908,34 @@ impl WindowManager {
#[tracing::instrument(skip(self))]
pub fn focus_container_in_cycle_direction(&mut self, direction: CycleDirection) -> Result<()> {
tracing::info!("focusing container");
let mut maximize_next = false;
let mut monocle_next = false;

if self.focused_workspace_mut()?.maximized_window().is_some() {
maximize_next = true;
self.unmaximize_window()?;
}

if self.focused_workspace_mut()?.monocle_container().is_some() {
monocle_next = true;
self.monocle_off()?;
}

let workspace = self.focused_workspace_mut()?;

let new_idx = workspace
.new_idx_for_cycle_direction(direction)
.ok_or_else(|| anyhow!("this is not a valid direction from the current position"))?;

workspace.focus_container(new_idx);
self.focused_window_mut()?.focus(self.mouse_follows_focus)?;

if maximize_next {
self.toggle_maximize()?;
} else if monocle_next {
self.toggle_monocle()?;
} else {
self.focused_window_mut()?.focus(self.mouse_follows_focus)?;
}

Ok(())
}
Expand Down Expand Up @@ -1084,7 +1104,7 @@ impl WindowManager {
Some(_) => self.monocle_off()?,
}

self.update_focused_workspace(false)
self.update_focused_workspace(true)
}

#[tracing::instrument(skip(self))]
Expand Down Expand Up @@ -1112,7 +1132,7 @@ impl WindowManager {
Some(_) => self.unmaximize_window()?,
}

self.update_focused_workspace(false)
self.update_focused_workspace(true)
}

#[tracing::instrument(skip(self))]
Expand Down

0 comments on commit a4e8286

Please sign in to comment.