mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-05-17 09:17:02 +02:00
refactor(clippy): apply lints
This commit is contained in:
@@ -26,7 +26,7 @@ pub trait Arrangement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Arrangement for DefaultLayout {
|
impl Arrangement for DefaultLayout {
|
||||||
#[allow(clippy::too_many_lines)]
|
#[allow(clippy::too_many_lines, clippy::cognitive_complexity)]
|
||||||
fn calculate(
|
fn calculate(
|
||||||
&self,
|
&self,
|
||||||
area: &Rect,
|
area: &Rect,
|
||||||
@@ -58,12 +58,13 @@ impl Arrangement for DefaultLayout {
|
|||||||
layout.right += adjustment.right;
|
layout.right += adjustment.right;
|
||||||
});
|
});
|
||||||
|
|
||||||
match layout_flip {
|
if matches!(
|
||||||
Some(Axis::Horizontal | Axis::HorizontalAndVertical) => match len {
|
layout_flip,
|
||||||
2.. => columns_reverse(&mut layouts),
|
Some(Axis::Horizontal | Axis::HorizontalAndVertical)
|
||||||
_ => {}
|
) {
|
||||||
},
|
if let 2.. = len {
|
||||||
_ => {}
|
columns_reverse(&mut layouts);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
layouts
|
layouts
|
||||||
@@ -82,12 +83,13 @@ impl Arrangement for DefaultLayout {
|
|||||||
layout.right += adjustment.right;
|
layout.right += adjustment.right;
|
||||||
});
|
});
|
||||||
|
|
||||||
match layout_flip {
|
if matches!(
|
||||||
Some(Axis::Vertical | Axis::HorizontalAndVertical) => match len {
|
layout_flip,
|
||||||
2.. => rows_reverse(&mut layouts),
|
Some(Axis::Vertical | Axis::HorizontalAndVertical)
|
||||||
_ => {}
|
) {
|
||||||
},
|
if let 2.. = len {
|
||||||
_ => {}
|
rows_reverse(&mut layouts);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
layouts
|
layouts
|
||||||
@@ -135,28 +137,28 @@ impl Arrangement for DefaultLayout {
|
|||||||
layout.right += adjustment.right;
|
layout.right += adjustment.right;
|
||||||
});
|
});
|
||||||
|
|
||||||
match layout_flip {
|
if matches!(
|
||||||
Some(Axis::Horizontal | Axis::HorizontalAndVertical) => match len {
|
layout_flip,
|
||||||
2.. => {
|
Some(Axis::Horizontal | Axis::HorizontalAndVertical)
|
||||||
let (primary, rest) = layouts.split_at_mut(1);
|
) {
|
||||||
let primary = &mut primary[0];
|
if let 2.. = len {
|
||||||
|
let (primary, rest) = layouts.split_at_mut(1);
|
||||||
|
let primary = &mut primary[0];
|
||||||
|
|
||||||
for rect in rest.iter_mut() {
|
for rect in rest.iter_mut() {
|
||||||
rect.left = primary.left;
|
rect.left = primary.left;
|
||||||
}
|
|
||||||
primary.left = rest[0].left + rest[0].right;
|
|
||||||
}
|
}
|
||||||
_ => {}
|
primary.left = rest[0].left + rest[0].right;
|
||||||
},
|
}
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match layout_flip {
|
if matches!(
|
||||||
Some(Axis::Vertical | Axis::HorizontalAndVertical) => match len {
|
layout_flip,
|
||||||
3.. => rows_reverse(&mut layouts[1..]),
|
Some(Axis::Vertical | Axis::HorizontalAndVertical)
|
||||||
_ => {}
|
) {
|
||||||
},
|
if let 3.. = len {
|
||||||
_ => {}
|
rows_reverse(&mut layouts[1..]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
layouts
|
layouts
|
||||||
@@ -207,28 +209,28 @@ impl Arrangement for DefaultLayout {
|
|||||||
layout.right += adjustment.right;
|
layout.right += adjustment.right;
|
||||||
});
|
});
|
||||||
|
|
||||||
match layout_flip {
|
if matches!(
|
||||||
Some(Axis::Horizontal | Axis::HorizontalAndVertical) => match len {
|
layout_flip,
|
||||||
2.. => {
|
Some(Axis::Horizontal | Axis::HorizontalAndVertical)
|
||||||
let (primary, rest) = layouts.split_at_mut(1);
|
) {
|
||||||
let primary = &mut primary[0];
|
if let 2.. = len {
|
||||||
|
let (primary, rest) = layouts.split_at_mut(1);
|
||||||
|
let primary = &mut primary[0];
|
||||||
|
|
||||||
primary.left = rest[0].left;
|
primary.left = rest[0].left;
|
||||||
for rect in rest.iter_mut() {
|
for rect in rest.iter_mut() {
|
||||||
rect.left = primary.left + primary.right;
|
rect.left = primary.left + primary.right;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_ => {}
|
}
|
||||||
},
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match layout_flip {
|
if matches!(
|
||||||
Some(Axis::Vertical | Axis::HorizontalAndVertical) => match len {
|
layout_flip,
|
||||||
3.. => rows_reverse(&mut layouts[1..]),
|
Some(Axis::Vertical | Axis::HorizontalAndVertical)
|
||||||
_ => {}
|
) {
|
||||||
},
|
if let 3.. = len {
|
||||||
_ => {}
|
rows_reverse(&mut layouts[1..]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
layouts
|
layouts
|
||||||
@@ -276,28 +278,28 @@ impl Arrangement for DefaultLayout {
|
|||||||
layout.right += adjustment.right;
|
layout.right += adjustment.right;
|
||||||
});
|
});
|
||||||
|
|
||||||
match layout_flip {
|
if matches!(
|
||||||
Some(Axis::Vertical | Axis::HorizontalAndVertical) => match len {
|
layout_flip,
|
||||||
2.. => {
|
Some(Axis::Vertical | Axis::HorizontalAndVertical)
|
||||||
let (primary, rest) = layouts.split_at_mut(1);
|
) {
|
||||||
let primary = &mut primary[0];
|
if let 2.. = len {
|
||||||
|
let (primary, rest) = layouts.split_at_mut(1);
|
||||||
|
let primary = &mut primary[0];
|
||||||
|
|
||||||
for rect in rest.iter_mut() {
|
for rect in rest.iter_mut() {
|
||||||
rect.top = primary.top;
|
rect.top = primary.top;
|
||||||
}
|
|
||||||
primary.top = rest[0].top + rest[0].bottom;
|
|
||||||
}
|
}
|
||||||
_ => {}
|
primary.top = rest[0].top + rest[0].bottom;
|
||||||
},
|
}
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match layout_flip {
|
if matches!(
|
||||||
Some(Axis::Horizontal | Axis::HorizontalAndVertical) => match len {
|
layout_flip,
|
||||||
3.. => columns_reverse(&mut layouts[1..]),
|
Some(Axis::Horizontal | Axis::HorizontalAndVertical)
|
||||||
_ => {}
|
) {
|
||||||
},
|
if let 3.. = len {
|
||||||
_ => {}
|
columns_reverse(&mut layouts[1..]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
layouts
|
layouts
|
||||||
@@ -374,8 +376,11 @@ impl Arrangement for DefaultLayout {
|
|||||||
layout.right += adjustment.right;
|
layout.right += adjustment.right;
|
||||||
});
|
});
|
||||||
|
|
||||||
match layout_flip {
|
if matches!(
|
||||||
Some(Axis::Horizontal | Axis::HorizontalAndVertical) => match len {
|
layout_flip,
|
||||||
|
Some(Axis::Horizontal | Axis::HorizontalAndVertical)
|
||||||
|
) {
|
||||||
|
match len {
|
||||||
2 => {
|
2 => {
|
||||||
let (primary, secondary) = layouts.split_at_mut(1);
|
let (primary, secondary) = layouts.split_at_mut(1);
|
||||||
let primary = &mut primary[0];
|
let primary = &mut primary[0];
|
||||||
@@ -397,20 +402,20 @@ impl Arrangement for DefaultLayout {
|
|||||||
secondary.left = primary.left + primary.right;
|
secondary.left = primary.left + primary.right;
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
}
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match layout_flip {
|
if matches!(
|
||||||
Some(Axis::Vertical | Axis::HorizontalAndVertical) => match len {
|
layout_flip,
|
||||||
4.. => rows_reverse(&mut layouts[2..]),
|
Some(Axis::Vertical | Axis::HorizontalAndVertical)
|
||||||
_ => {}
|
) {
|
||||||
},
|
if let 4.. = len {
|
||||||
_ => {}
|
rows_reverse(&mut layouts[2..]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
layouts
|
layouts
|
||||||
},
|
}
|
||||||
#[allow(
|
#[allow(
|
||||||
clippy::cast_precision_loss,
|
clippy::cast_precision_loss,
|
||||||
clippy::cast_possible_truncation,
|
clippy::cast_possible_truncation,
|
||||||
|
|||||||
@@ -206,11 +206,9 @@ pub fn listen_for_notifications(wm: Arc<Mutex<WindowManager>>) {
|
|||||||
|
|
||||||
let mut to_remove = vec![];
|
let mut to_remove = vec![];
|
||||||
for (id, border) in borders.iter() {
|
for (id, border) in borders.iter() {
|
||||||
if borders_monitors.get(id).copied().unwrap_or_default() == monitor_idx {
|
if borders_monitors.get(id).copied().unwrap_or_default() == monitor_idx && !container_ids.contains(id) {
|
||||||
if !container_ids.contains(id) {
|
border.destroy()?;
|
||||||
border.destroy()?;
|
to_remove.push(id.clone());
|
||||||
to_remove.push(id.clone());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,12 +266,10 @@ pub fn listen_for_notifications(wm: Arc<Mutex<WindowManager>>) {
|
|||||||
|| monitor_idx != focused_monitor_idx
|
|| monitor_idx != focused_monitor_idx
|
||||||
{
|
{
|
||||||
WindowKind::Unfocused
|
WindowKind::Unfocused
|
||||||
|
} else if c.windows().len() > 1 {
|
||||||
|
WindowKind::Stack
|
||||||
} else {
|
} else {
|
||||||
if c.windows().len() > 1 {
|
WindowKind::Single
|
||||||
WindowKind::Stack
|
|
||||||
} else {
|
|
||||||
WindowKind::Single
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -302,9 +298,9 @@ pub enum ZOrder {
|
|||||||
TopMost,
|
TopMost,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<isize> for ZOrder {
|
impl From<ZOrder> for isize {
|
||||||
fn into(self) -> isize {
|
fn from(val: ZOrder) -> Self {
|
||||||
match self {
|
match val {
|
||||||
ZOrder::Top => 0,
|
ZOrder::Top => 0,
|
||||||
ZOrder::NoTopMost => -2,
|
ZOrder::NoTopMost => -2,
|
||||||
ZOrder::Bottom => 1,
|
ZOrder::Bottom => 1,
|
||||||
|
|||||||
@@ -270,17 +270,15 @@ impl WindowManager {
|
|||||||
|
|
||||||
for (i, monitors) in self.monitors().iter().enumerate() {
|
for (i, monitors) in self.monitors().iter().enumerate() {
|
||||||
for (j, workspace) in monitors.workspaces().iter().enumerate() {
|
for (j, workspace) in monitors.workspaces().iter().enumerate() {
|
||||||
if workspace.contains_window(window.hwnd) {
|
if workspace.contains_window(window.hwnd) && focused_pair != (i, j) {
|
||||||
if focused_pair != (i, j) {
|
workspace_reconciliator::event_tx().send(
|
||||||
workspace_reconciliator::event_tx().send(
|
workspace_reconciliator::Notification {
|
||||||
workspace_reconciliator::Notification {
|
monitor_idx: i,
|
||||||
monitor_idx: i,
|
workspace_idx: j,
|
||||||
workspace_idx: j,
|
},
|
||||||
},
|
)?;
|
||||||
)?;
|
|
||||||
|
|
||||||
needs_reconciliation = true;
|
needs_reconciliation = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user