Skip to content

Commit

Permalink
fix(wm): allow resize-axis on custom layout rule
Browse files Browse the repository at this point in the history
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
  • Loading branch information
LGUG2Z committed Jun 14, 2022
1 parent 005a95b commit b08eb0d
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions komorebi/src/process_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b08eb0d

Please sign in to comment.