From fc3c39bded78d8edf2358f580ce7531ff2560b1e Mon Sep 17 00:00:00 2001 From: atagen Date: Tue, 7 Apr 2026 12:05:13 +1000 Subject: [PATCH] container: expand title bars to fit window size when gapped w/o title gaps --- src/tree/container.rs | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/src/tree/container.rs b/src/tree/container.rs index 395f6d8c..efb766d2 100644 --- a/src/tree/container.rs +++ b/src/tree/container.rs @@ -909,13 +909,15 @@ impl ContainerNode { let abs_x = self.abs_x1.get(); let abs_y = self.abs_y1.get(); let gap = self.state.theme.sizes.gap.get(); + let floating_titles = self.state.theme.floating_titles.get(); + let title_bw = if gap != 0 && !floating_titles { bw } else { 0 }; for (i, child) in self.children.iter().enumerate() { let rect = child.title_rect.get(); if self.toplevel_data.visible.get() && !mono && split != ContainerSplit::Horizontal { self.state.damage(Rect::new_sized_saturating( - abs_x, + abs_x - title_bw, abs_y + rect.y1(), - cwidth, + cwidth + 2 * title_bw, rect.height() + tuh, )); } @@ -929,8 +931,7 @@ impl ContainerNode { } else { Rect::new_sized_saturating(0, rect.y1() - bw, cwidth, bw) }; - let floating = self.state.theme.floating_titles.get(); - if gap == 0 || (mono && !floating) { + if gap == 0 || (mono && !floating_titles) { rd.border_rects.push(sep); } } @@ -943,7 +944,7 @@ impl ContainerNode { } else { rd.title_rects.push(rect); } - if !mono && (!self.state.theme.floating_titles.get() || gap == 0) { + if !mono && (!floating_titles || gap == 0) { let rect = Rect::new_sized_saturating(rect.x1(), rect.y2(), rect.width(), 1); rd.underline_rects.push(rect); } @@ -955,7 +956,7 @@ impl ContainerNode { } } } - if mono && (!self.state.theme.floating_titles.get() || gap == 0) { + if mono && (!floating_titles || gap == 0) { rd.underline_rects .push(Rect::new_sized_saturating(0, th, cwidth, tuh)); } @@ -963,9 +964,31 @@ impl ContainerNode { rd.underline_rects .push(Rect::new_sized_saturating(0, 0, cwidth, tuh)); } + if title_bw > 0 { + let extend = |r: Rect| { + let x1 = if r.x1() == 0 { -title_bw } else { r.x1() }; + let x2 = if r.x2() == cwidth { r.x2() + title_bw } else { r.x2() }; + Rect::new_sized_saturating(x1, r.y1(), x2 - x1, r.height()) + }; + for r in &mut rd.title_rects { + *r = extend(*r); + } + for r in &mut rd.active_title_rects { + *r = extend(*r); + } + for r in &mut rd.attention_title_rects { + *r = extend(*r); + } + if let Some(r) = &mut rd.last_active_rect { + *r = extend(*r); + } + for r in &mut rd.underline_rects { + *r = extend(*r); + } + } if self.toplevel_data.visible.get() && (mono || split == ContainerSplit::Horizontal) { self.state - .damage(Rect::new_sized_saturating(abs_x, abs_y, cwidth, tpuh)); + .damage(Rect::new_sized_saturating(abs_x - title_bw, abs_y, cwidth + 2 * title_bw, tpuh)); } rd.titles.remove_if(|_, v| v.is_empty()); }