From b08eb0d50c32d388d2b2c6ec46c8ac272cb3cd50 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 14 Jun 2022 16:54:05 -0700 Subject: [PATCH] fix(wm): allow resize-axis on custom layout rule This commit ensures that a custom layout that is set by a layout rule will correctly have the width of the primary column increased or decreased when resize-axis is called with Axis::Horizontal. re #154 --- komorebi/src/process_command.rs | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 064d571b..fdddc3bc 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -378,15 +378,40 @@ impl WindowManager { SocketMessage::ResizeWindowAxis(axis, sizing) => { // If the user has a custom layout, allow for the resizing of the primary column // with this signal - if let Layout::Custom(ref mut custom) = self.focused_workspace_mut()?.layout_mut() { + let workspace = self.focused_workspace_mut()?; + let container_len = workspace.containers().len(); + let has_layout_rules = workspace.layout_rules().is_empty(); + + if let Layout::Custom(ref mut custom) = workspace.layout_mut() { if matches!(axis, Axis::Horizontal) { let percentage = custom .primary_width_percentage() .unwrap_or(100 / custom.len()); - match sizing { - Sizing::Increase => custom.set_primary_width_percentage(percentage + 5), - Sizing::Decrease => custom.set_primary_width_percentage(percentage - 5), + if has_layout_rules { + match sizing { + Sizing::Increase => { + custom.set_primary_width_percentage(percentage + 5); + } + Sizing::Decrease => { + custom.set_primary_width_percentage(percentage - 5); + } + } + } else { + for rule in workspace.layout_rules_mut() { + if container_len >= rule.0 { + if let Layout::Custom(ref mut custom) = rule.1 { + match sizing { + Sizing::Increase => { + custom.set_primary_width_percentage(percentage + 5); + } + Sizing::Decrease => { + custom.set_primary_width_percentage(percentage - 5); + } + } + } + } + } } } // Otherwise proceed with the resizing logic for individual window containers in the