mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-04-25 01:58:51 +02:00
fix(wm): valid directions all require count > 1
This is a mixture of refactoring and a fix, updating the Direction::is_valid_direction trait impl for Default layout to return early with false if the count is < 2. fix #851
This commit is contained in:
@@ -90,9 +90,13 @@ impl Direction for DefaultLayout {
|
|||||||
idx: usize,
|
idx: usize,
|
||||||
count: usize,
|
count: usize,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
|
if count < 2 {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
match op_direction {
|
match op_direction {
|
||||||
OperationDirection::Up => match self {
|
OperationDirection::Up => match self {
|
||||||
Self::BSP => count > 2 && idx != 0 && idx != 1,
|
Self::BSP => idx != 0 && idx != 1,
|
||||||
Self::Columns => false,
|
Self::Columns => false,
|
||||||
Self::Rows | Self::HorizontalStack => idx != 0,
|
Self::Rows | Self::HorizontalStack => idx != 0,
|
||||||
Self::VerticalStack | Self::RightMainVerticalStack => idx != 0 && idx != 1,
|
Self::VerticalStack | Self::RightMainVerticalStack => idx != 0 && idx != 1,
|
||||||
@@ -100,7 +104,7 @@ impl Direction for DefaultLayout {
|
|||||||
Self::Grid => !is_grid_edge(op_direction, idx, count),
|
Self::Grid => !is_grid_edge(op_direction, idx, count),
|
||||||
},
|
},
|
||||||
OperationDirection::Down => match self {
|
OperationDirection::Down => match self {
|
||||||
Self::BSP => count > 2 && idx != count - 1 && idx % 2 != 0,
|
Self::BSP => idx != count - 1 && idx % 2 != 0,
|
||||||
Self::Columns => false,
|
Self::Columns => false,
|
||||||
Self::Rows => idx != count - 1,
|
Self::Rows => idx != count - 1,
|
||||||
Self::VerticalStack | Self::RightMainVerticalStack => idx != 0 && idx != count - 1,
|
Self::VerticalStack | Self::RightMainVerticalStack => idx != 0 && idx != count - 1,
|
||||||
@@ -109,23 +113,22 @@ impl Direction for DefaultLayout {
|
|||||||
Self::Grid => !is_grid_edge(op_direction, idx, count),
|
Self::Grid => !is_grid_edge(op_direction, idx, count),
|
||||||
},
|
},
|
||||||
OperationDirection::Left => match self {
|
OperationDirection::Left => match self {
|
||||||
Self::BSP => count > 1 && idx != 0,
|
Self::BSP => idx != 0,
|
||||||
Self::Columns | Self::VerticalStack => idx != 0,
|
Self::Columns | Self::VerticalStack => idx != 0,
|
||||||
Self::RightMainVerticalStack => idx == 0,
|
Self::RightMainVerticalStack => idx == 0,
|
||||||
Self::Rows => false,
|
Self::Rows => false,
|
||||||
Self::HorizontalStack => idx != 0 && idx != 1,
|
Self::HorizontalStack => idx != 0 && idx != 1,
|
||||||
Self::UltrawideVerticalStack => count > 1 && idx != 1,
|
Self::UltrawideVerticalStack => idx != 1,
|
||||||
Self::Grid => !is_grid_edge(op_direction, idx, count),
|
Self::Grid => !is_grid_edge(op_direction, idx, count),
|
||||||
},
|
},
|
||||||
OperationDirection::Right => match self {
|
OperationDirection::Right => match self {
|
||||||
Self::BSP => count > 1 && idx % 2 == 0 && idx != count - 1,
|
Self::BSP => idx % 2 == 0 && idx != count - 1,
|
||||||
Self::Columns => idx != count - 1,
|
Self::Columns => idx != count - 1,
|
||||||
Self::Rows => false,
|
Self::Rows => false,
|
||||||
Self::VerticalStack => idx == 0,
|
Self::VerticalStack => idx == 0,
|
||||||
Self::RightMainVerticalStack => idx != 0,
|
Self::RightMainVerticalStack => idx != 0,
|
||||||
Self::HorizontalStack => idx != 0 && idx != count - 1,
|
Self::HorizontalStack => idx != 0 && idx != count - 1,
|
||||||
Self::UltrawideVerticalStack => match count {
|
Self::UltrawideVerticalStack => match count {
|
||||||
0 | 1 => false,
|
|
||||||
2 => idx != 0,
|
2 => idx != 0,
|
||||||
_ => idx < 2,
|
_ => idx < 2,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user