From eab7a6425039b809df6f09ce4a09ae49080c40ab Mon Sep 17 00:00:00 2001 From: Javier Portillo <17260001+javierportillo@users.noreply.github.com> Date: Sat, 24 Feb 2024 23:05:47 -0600 Subject: [PATCH] fix(grid): enables flip_layout and make it behave correctly --- komorebi-core/src/arrangement.rs | 22 +++++++++++++++++++--- komorebi/src/window_manager.rs | 5 ----- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/komorebi-core/src/arrangement.rs b/komorebi-core/src/arrangement.rs index 0c9e31a6..facc6165 100644 --- a/komorebi-core/src/arrangement.rs +++ b/komorebi-core/src/arrangement.rs @@ -156,11 +156,27 @@ impl Arrangement for DefaultLayout { for row in 0..num_rows_in_this_col { if let Some((_idx, win)) = iter.next() { + let mut left = area.left + win_width * col; + let mut top = area.top + win_height * row; + + match layout_flip { + Some(Axis::Horizontal) => { + left = area.right - win_width * (col + 1) + area.left; + } + Some(Axis::Vertical) => { + top = area.bottom - win_height * (row + 1) + area.top; + } + Some(Axis::HorizontalAndVertical) => { + left = area.right - win_width * (col + 1) + area.left; + top = area.bottom - win_height * (row + 1) + area.top; + } + None => {} // No flip + } + win.bottom = win_height; win.right = win_width; - - win.left = area.left + win_width * col; - win.top = area.top + win_height * row; + win.left = left; + win.top = top; } } } diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index b9ef6f7d..c1b76e12 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -1658,11 +1658,6 @@ impl WindowManager { pub fn flip_layout(&mut self, layout_flip: Axis) -> Result<()> { let workspace = self.focused_workspace_mut()?; - if matches!(workspace.layout(), Layout::Default(DefaultLayout::Grid)) { - tracing::debug!("ignoring flip layout command for grid layout"); - return Ok(()) - } - tracing::info!("flipping layout"); #[allow(clippy::match_same_arms)]