git.lucas.co / cce-compositor
Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git

commita884fe3da52c4216990d3b123569a41d8999bb01
parent494bda37ea
authorLucas Galante <[email protected]>
date2026-06-15 14:44
Cascade mode improvements and layout-specific border widths

 src/server/tiling.rs         | 18 +++++-------------
 src/server/window_manager.rs | 11 ++++++++++-
 2 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/src/server/tiling.rs b/src/server/tiling.rs
index f538e84..339e06f 100644
--- a/src/server/tiling.rs
+++ b/src/server/tiling.rs
@@ -45,11 +45,13 @@ pub fn tile_cascade(
     idx: i32,
 ) -> (i32, i32, i32, i32) {
     let dec_h = std::cmp::max(bw, 16);
-    let width = screen_w - gap_left - gap_right - bw * 2 - cascade_offset * (n_cascade - 1);
-    let height = screen_h - bar_height - gap_top - gap_bottom - (dec_h + bw) - cascade_offset * (n_cascade - 1);
+    let max_offsets = 5;
+    let eff_cascade = n_cascade.min(max_offsets);
+    let width = screen_w - gap_left - gap_right - bw * 2 - cascade_offset * (eff_cascade - 1);
+    let height = screen_h - bar_height - gap_top - gap_bottom - (dec_h + bw) - cascade_offset * (eff_cascade - 1);
     let width = if width < 1 { 1 } else { width };
     let height = if height < 1 { 1 } else { height };
-    let pos_idx = n_cascade - 1 - idx;
+    let pos_idx = idx.min(max_offsets - 1);
     let x = gap_left + bw + pos_idx * cascade_offset;
     let y = bar_height + gap_top + dec_h + pos_idx * cascade_offset;
     (x, y, width, height)
@@ -105,13 +107,3 @@ pub fn interp_channel(fp_channel: u32, factor: f64, depth: i32) -> u32 {
     val as u32 * 0x01010101
 }
 
-/// Compute a "#RRGGBB" hex color string for a given cascade depth.
-pub fn cascade_hex_color(r: u32, g: u32, b: u32, depth: i32) -> String {
-    let ri = interp_channel(r, CASCADE_DEPTH_FACTOR, depth);
-    let gi = interp_channel(g, CASCADE_DEPTH_FACTOR, depth);
-    let bi = interp_channel(b, CASCADE_DEPTH_FACTOR, depth);
-    let rv = ri & 0xFF;
-    let gv = gi & 0xFF;
-    let bv = bi & 0xFF;
-    format!("#{:02x}{:02x}{:02x}", rv, gv, bv)
-}
diff --git a/src/server/window_manager.rs b/src/server/window_manager.rs
index 44fff9a..5aff2be 100644
--- a/src/server/window_manager.rs
+++ b/src/server/window_manager.rs
@@ -743,12 +743,21 @@ impl WindowManager {
                 self.global_layout
             };
 
+            if current_layout == crate::tiling::TilingMode::Cascade {
+                tiled_windows.sort_by_key(|&w| stack_order.iter().position(|&x| x == w).unwrap_or(usize::MAX));
+            }
+
             let gap = self.layout.gap;
             let gap_top = self.layout.gap_top;
             let gap_left = self.layout.gap_left;
             let gap_right = self.layout.gap_right;
             let gap_bottom = self.layout.gap_bottom;
-            let bw = self.layout.border_width;
+            let bw = match current_layout {
+                crate::tiling::TilingMode::Cascade => self.layout.cascade_border_width,
+                crate::tiling::TilingMode::Grid => self.layout.grid_border_width,
+                crate::tiling::TilingMode::Fullscreen => self.layout.fullscreen_border_width,
+                _ => self.layout.border_width,
+            };
             let cascade_offset = self.layout.cascade_offset;
             let bar_height = self.layout.bar_height;