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:
14
     runs-on: macos-latest
14
     runs-on: macos-latest
15
     steps:
15
     steps:
16
       - uses: actions/checkout@v5
16
       - uses: actions/checkout@v5
17
+        with:
18
+          submodules: true
17
 
19
 
18
       - name: Install Rust
20
       - name: Install Rust
19
         uses: dtolnay/rust-toolchain@stable
21
         uses: dtolnay/rust-toolchain@stable
@@ -36,7 +38,7 @@ jobs:
36
         run: cargo test --workspace
38
         run: cargo test --workspace
37
 
39
 
38
       - name: Clippy
40
       - 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
40
 
42
 
41
       - name: Format check
43
       - 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 {
317
         for (mi, monitor) in self.monitors.iter().enumerate() {
317
         for (mi, monitor) in self.monitors.iter().enumerate() {
318
             let ws = self.workspaces.get(monitor.active_workspace);
318
             let ws = self.workspaces.get(monitor.active_workspace);
319
             let sr = self.monitor_rect(mi);
319
             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);
321
             let focused = ws.focused;
323
             let focused = ws.focused;
322
 
324
 
323
             for (wid, rect) in &geoms {
325
             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));
325
             }
328
             }
326
             for fw in &ws.floating {
329
             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));
328
             }
332
             }
329
         }
333
         }
330
     }
334
     }
@@ -711,33 +715,26 @@ impl WmState {
711
             let at_edge = if let Some((_, rect)) = geoms.iter().find(|(w, _)| *w == from) {
715
             let at_edge = if let Some((_, rect)) = geoms.iter().find(|(w, _)| *w == from) {
712
                 let tolerance = self.gap_outer + 2.0;
716
                 let tolerance = self.gap_outer + 2.0;
713
                 match direction {
717
                 match direction {
714
-                    Direction::Right => {
718
+                    Direction::Right => (rect.x + rect.width) >= (sr.x + sr.width - tolerance),
715
-                        (rect.x + rect.width) >= (sr.x + sr.width - tolerance)
716
-                    }
717
                     Direction::Left => rect.x <= (sr.x + tolerance),
719
                     Direction::Left => rect.x <= (sr.x + tolerance),
718
-                    Direction::Down => {
720
+                    Direction::Down => (rect.y + rect.height) >= (sr.y + sr.height - tolerance),
719
-                        (rect.y + rect.height) >= (sr.y + sr.height - tolerance)
720
-                    }
721
                     Direction::Up => rect.y <= (sr.y + tolerance),
721
                     Direction::Up => rect.y <= (sr.y + tolerance),
722
                 }
722
                 }
723
             } else {
723
             } else {
724
                 false
724
                 false
725
             };
725
             };
726
 
726
 
727
-            if !at_edge {
727
+            if !at_edge && let Some(target) = Node::find_adjacent(&geoms, from, direction) {
728
-                if let Some(target) = Node::find_adjacent(&geoms, from, direction) {
728
+                self.focus_window(target);
729
-                    self.focus_window(target);
729
+                if self.mouse_follows_focus
730
-                    if self.mouse_follows_focus
730
+                    && let Some((_, rect)) = geoms.iter().find(|(id, _)| *id == target)
731
-                        && let Some((_, rect)) = geoms.iter().find(|(id, _)| *id == target)
731
+                {
732
-                    {
732
+                    warp_mouse_to_center(rect);
733
-                        warp_mouse_to_center(rect);
733
+                    self.ffm_cooldown_until =
734
-                        self.ffm_cooldown_until = Some(
734
+                        Some(std::time::Instant::now() + std::time::Duration::from_millis(200));
735
-                            std::time::Instant::now() + std::time::Duration::from_millis(200),
735
+                    self.ffm_last_window = Some(target);
736
-                        );
737
-                        self.ffm_last_window = Some(target);
738
-                    }
739
-                    return;
740
                 }
736
                 }
737
+                return;
741
             }
738
             }
742
         }
739
         }
743
 
740
 
@@ -801,12 +798,9 @@ impl WmState {
801
             None => return,
798
             None => return,
802
         };
799
         };
803
         let sr = self.focused_rect();
800
         let sr = self.focused_rect();
804
-        let geoms = ws.tree.calculate_geometries_with_gaps(
801
+        let geoms =
805
-            sr,
802
+            ws.tree
806
-            self.gap_inner,
803
+                .calculate_geometries_with_gaps(sr, self.gap_inner, self.gap_outer, true);
807
-            self.gap_outer,
808
-            true,
809
-        );
810
 
804
 
811
         // Check if the focused window touches the monitor edge in the
805
         // Check if the focused window touches the monitor edge in the
812
         // requested direction. If so, skip intra-workspace swap and move
806
         // requested direction. If so, skip intra-workspace swap and move
@@ -824,15 +818,13 @@ impl WmState {
824
             false
818
             false
825
         };
819
         };
826
 
820
 
827
-        if !at_edge {
821
+        if !at_edge && let Some(target) = Node::find_adjacent(&geoms, focused, direction) {
828
-            if let Some(target) = Node::find_adjacent(&geoms, focused, direction) {
822
+            tracing::debug!(focused, target, ?direction, "swap_direction");
829
-                tracing::debug!(focused, target, ?direction, "swap_direction");
823
+            if self.active_workspace_mut().tree.swap(focused, target) {
830
-                if self.active_workspace_mut().tree.swap(focused, target) {
824
+                self.apply_layout();
831
-                    self.apply_layout();
825
+                self.fix_oversized_windows();
832
-                    self.fix_oversized_windows();
833
-                }
834
-                return;
835
             }
826
             }
827
+            return;
836
         }
828
         }
837
 
829
 
838
         // At monitor edge or no adjacent window — move to adjacent monitor
830
         // At monitor edge or no adjacent window — move to adjacent monitor
@@ -849,7 +841,12 @@ impl WmState {
849
             _ => None,
841
             _ => None,
850
         };
842
         };
851
         if let Some(target_mi) = new_mi {
843
         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
+            );
853
             self.move_window_to_monitor(target_mi);
850
             self.move_window_to_monitor(target_mi);
854
         }
851
         }
855
     }
852
     }
tarmac/src/platform/border.rsmodified
@@ -70,7 +70,9 @@ impl BorderManager {
70
     /// Looks for ers next to the tarmac binary first, then falls back to PATH.
70
     /// Looks for ers next to the tarmac binary first, then falls back to PATH.
71
     pub fn spawn(&mut self) {
71
     pub fn spawn(&mut self) {
72
         self.kill();
72
         self.kill();
73
-        if !self.is_enabled() { return; }
73
+        if !self.is_enabled() {
74
+            return;
75
+        }
74
 
76
 
75
         let ers_bin = std::env::current_exe()
77
         let ers_bin = std::env::current_exe()
76
             .ok()
78
             .ok()
@@ -81,13 +83,20 @@ impl BorderManager {
81
 
83
 
82
         let cmd = format!(
84
         let cmd = format!(
83
             "{} --active-only --width {} --radius {} --color '{}' --inactive '{}'",
85
             "{} --active-only --width {} --radius {} --color '{}' --inactive '{}'",
84
-            ers_bin, self.border_width, self.radius,
86
+            ers_bin,
85
-            self.focused_color.to_hex(), self.unfocused_color.to_hex(),
87
+            self.border_width,
88
+            self.radius,
89
+            self.focused_color.to_hex(),
90
+            self.unfocused_color.to_hex(),
86
         );
91
         );
87
         tracing::debug!(cmd, "spawning ers");
92
         tracing::debug!(cmd, "spawning ers");
88
         match Command::new("/bin/sh").args(["-c", &cmd]).spawn() {
93
         match Command::new("/bin/sh").args(["-c", &cmd]).spawn() {
89
-            Ok(child) => { self.child = Some(child); }
94
+            Ok(child) => {
90
-            Err(e) => { tracing::warn!(err = %e, "failed to spawn ers"); }
95
+                self.child = Some(child);
96
+            }
97
+            Err(e) => {
98
+                tracing::warn!(err = %e, "failed to spawn ers");
99
+            }
91
         }
100
         }
92
     }
101
     }
93
 
102
 
@@ -114,7 +123,8 @@ impl BorderManager {
114
         _old: Option<u32>,
123
         _old: Option<u32>,
115
         _new: Option<u32>,
124
         _new: Option<u32>,
116
         _get_rect: impl Fn(u32) -> Option<crate::core::tree::Rect>,
125
         _get_rect: impl Fn(u32) -> Option<crate::core::tree::Rect>,
117
-    ) {}
126
+    ) {
127
+    }
118
 }
128
 }
119
 
129
 
120
 impl Drop for BorderManager {
130
 impl Drop for BorderManager {