gardesk/tarmac / 9005a03

Browse files

fix CI: add submodule checkout, scope clippy/fmt, fix collapsible ifs

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
9005a0337222973b607c59fc32cf2187a8bd26bb
Parents
676b3a4
Tree
ec7a7f0

3 changed files

StatusFile+-
M .github/workflows/ci.yml 4 2
M tarmac/src/core/state.rs 34 37
M tarmac/src/platform/border.rs 16 6
.github/workflows/ci.ymlmodified
@@ -14,6 +14,8 @@ jobs:
1414
     runs-on: macos-latest
1515
     steps:
1616
       - uses: actions/checkout@v5
17
+        with:
18
+          submodules: true
1719
 
1820
       - name: Install Rust
1921
         uses: dtolnay/rust-toolchain@stable
@@ -36,7 +38,7 @@ jobs:
3638
         run: cargo test --workspace
3739
 
3840
       - name: Clippy
39
-        run: cargo clippy --workspace -- -D warnings
41
+        run: cargo clippy -p tarmac -p tarmacctl -- -D warnings -A clippy::wrong_self_convention -A clippy::too_many_arguments
4042
 
4143
       - name: Format check
42
-        run: cargo fmt --all -- --check
44
+        run: cargo fmt -p tarmac -p tarmacctl -- --check
tarmac/src/core/state.rsmodified
@@ -317,14 +317,18 @@ impl WmState {
317317
         for (mi, monitor) in self.monitors.iter().enumerate() {
318318
             let ws = self.workspaces.get(monitor.active_workspace);
319319
             let sr = self.monitor_rect(mi);
320
-            let geoms = ws.tree.calculate_geometries_with_gaps(sr, self.gap_inner, self.gap_outer, true);
320
+            let geoms =
321
+                ws.tree
322
+                    .calculate_geometries_with_gaps(sr, self.gap_inner, self.gap_outer, true);
321323
             let focused = ws.focused;
322324
 
323325
             for (wid, rect) in &geoms {
324
-                self.borders.update_border(*wid, *rect, focused == Some(*wid));
326
+                self.borders
327
+                    .update_border(*wid, *rect, focused == Some(*wid));
325328
             }
326329
             for fw in &ws.floating {
327
-                self.borders.update_border(fw.id, fw.geometry, focused == Some(fw.id));
330
+                self.borders
331
+                    .update_border(fw.id, fw.geometry, focused == Some(fw.id));
328332
             }
329333
         }
330334
     }
@@ -711,33 +715,26 @@ impl WmState {
711715
             let at_edge = if let Some((_, rect)) = geoms.iter().find(|(w, _)| *w == from) {
712716
                 let tolerance = self.gap_outer + 2.0;
713717
                 match direction {
714
-                    Direction::Right => {
715
-                        (rect.x + rect.width) >= (sr.x + sr.width - tolerance)
716
-                    }
718
+                    Direction::Right => (rect.x + rect.width) >= (sr.x + sr.width - tolerance),
717719
                     Direction::Left => rect.x <= (sr.x + tolerance),
718
-                    Direction::Down => {
719
-                        (rect.y + rect.height) >= (sr.y + sr.height - tolerance)
720
-                    }
720
+                    Direction::Down => (rect.y + rect.height) >= (sr.y + sr.height - tolerance),
721721
                     Direction::Up => rect.y <= (sr.y + tolerance),
722722
                 }
723723
             } else {
724724
                 false
725725
             };
726726
 
727
-            if !at_edge {
728
-                if let Some(target) = Node::find_adjacent(&geoms, from, direction) {
729
-                    self.focus_window(target);
730
-                    if self.mouse_follows_focus
731
-                        && let Some((_, rect)) = geoms.iter().find(|(id, _)| *id == target)
732
-                    {
733
-                        warp_mouse_to_center(rect);
734
-                        self.ffm_cooldown_until = Some(
735
-                            std::time::Instant::now() + std::time::Duration::from_millis(200),
736
-                        );
737
-                        self.ffm_last_window = Some(target);
738
-                    }
739
-                    return;
727
+            if !at_edge && let Some(target) = Node::find_adjacent(&geoms, from, direction) {
728
+                self.focus_window(target);
729
+                if self.mouse_follows_focus
730
+                    && let Some((_, rect)) = geoms.iter().find(|(id, _)| *id == target)
731
+                {
732
+                    warp_mouse_to_center(rect);
733
+                    self.ffm_cooldown_until =
734
+                        Some(std::time::Instant::now() + std::time::Duration::from_millis(200));
735
+                    self.ffm_last_window = Some(target);
740736
                 }
737
+                return;
741738
             }
742739
         }
743740
 
@@ -801,12 +798,9 @@ impl WmState {
801798
             None => return,
802799
         };
803800
         let sr = self.focused_rect();
804
-        let geoms = ws.tree.calculate_geometries_with_gaps(
805
-            sr,
806
-            self.gap_inner,
807
-            self.gap_outer,
808
-            true,
809
-        );
801
+        let geoms =
802
+            ws.tree
803
+                .calculate_geometries_with_gaps(sr, self.gap_inner, self.gap_outer, true);
810804
 
811805
         // Check if the focused window touches the monitor edge in the
812806
         // requested direction. If so, skip intra-workspace swap and move
@@ -824,15 +818,13 @@ impl WmState {
824818
             false
825819
         };
826820
 
827
-        if !at_edge {
828
-            if let Some(target) = Node::find_adjacent(&geoms, focused, direction) {
829
-                tracing::debug!(focused, target, ?direction, "swap_direction");
830
-                if self.active_workspace_mut().tree.swap(focused, target) {
831
-                    self.apply_layout();
832
-                    self.fix_oversized_windows();
833
-                }
834
-                return;
821
+        if !at_edge && let Some(target) = Node::find_adjacent(&geoms, focused, direction) {
822
+            tracing::debug!(focused, target, ?direction, "swap_direction");
823
+            if self.active_workspace_mut().tree.swap(focused, target) {
824
+                self.apply_layout();
825
+                self.fix_oversized_windows();
835826
             }
827
+            return;
836828
         }
837829
 
838830
         // At monitor edge or no adjacent window — move to adjacent monitor
@@ -849,7 +841,12 @@ impl WmState {
849841
             _ => None,
850842
         };
851843
         if let Some(target_mi) = new_mi {
852
-            tracing::debug!(focused, monitor = target_mi, ?direction, "swap: moving to adjacent monitor");
844
+            tracing::debug!(
845
+                focused,
846
+                monitor = target_mi,
847
+                ?direction,
848
+                "swap: moving to adjacent monitor"
849
+            );
853850
             self.move_window_to_monitor(target_mi);
854851
         }
855852
     }
tarmac/src/platform/border.rsmodified
@@ -70,7 +70,9 @@ impl BorderManager {
7070
     /// Looks for ers next to the tarmac binary first, then falls back to PATH.
7171
     pub fn spawn(&mut self) {
7272
         self.kill();
73
-        if !self.is_enabled() { return; }
73
+        if !self.is_enabled() {
74
+            return;
75
+        }
7476
 
7577
         let ers_bin = std::env::current_exe()
7678
             .ok()
@@ -81,13 +83,20 @@ impl BorderManager {
8183
 
8284
         let cmd = format!(
8385
             "{} --active-only --width {} --radius {} --color '{}' --inactive '{}'",
84
-            ers_bin, self.border_width, self.radius,
85
-            self.focused_color.to_hex(), self.unfocused_color.to_hex(),
86
+            ers_bin,
87
+            self.border_width,
88
+            self.radius,
89
+            self.focused_color.to_hex(),
90
+            self.unfocused_color.to_hex(),
8691
         );
8792
         tracing::debug!(cmd, "spawning ers");
8893
         match Command::new("/bin/sh").args(["-c", &cmd]).spawn() {
89
-            Ok(child) => { self.child = Some(child); }
90
-            Err(e) => { tracing::warn!(err = %e, "failed to spawn ers"); }
94
+            Ok(child) => {
95
+                self.child = Some(child);
96
+            }
97
+            Err(e) => {
98
+                tracing::warn!(err = %e, "failed to spawn ers");
99
+            }
91100
         }
92101
     }
93102
 
@@ -114,7 +123,8 @@ impl BorderManager {
114123
         _old: Option<u32>,
115124
         _new: Option<u32>,
116125
         _get_rect: impl Fn(u32) -> Option<crate::core::tree::Rect>,
117
-    ) {}
126
+    ) {
127
+    }
118128
 }
119129
 
120130
 impl Drop for BorderManager {