From ee698c98460d75e32e95963730019bf67ea6811b Mon Sep 17 00:00:00 2001 From: nandithebull Date: Tue, 24 Nov 2026 20:08:58 -0800 Subject: [PATCH] Decorations: truncate window titles so they never draw over the title-bar buttons Co-Authored-By: Claude Sonnet 5.5 --- compositor/scene/scene.mbt | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/compositor/scene/scene.mbt b/compositor/scene/scene.mbt index 162add7..616f73c 100644 --- a/compositor/scene/scene.mbt +++ b/compositor/scene/scene.mbt @@ -353,19 +353,6 @@ pub fn build_breeze_decoration( Line(border, title_h - 1, outer_w - border, title_h - 1, p.border, 1), ] - let label = if title.length() > 0 { title } else { app_id } - ops.push( - Text( - 14, - title_h / 2, - label, - tokens.font_size, - title_fg, - Left, - focused, - ), - ) - // Window control buttons on the right: [ _ ] [ [] ] [ X ] let btn_size = 18 let btn_y = (title_h - btn_size) / 2 @@ -373,6 +360,21 @@ pub fn build_breeze_decoration( let max_x = close_x - 8 - btn_size let min_x = max_x - 8 - btn_size + // Title: truncated so it never runs under the buttons or past the window edge. + let label = if title.length() > 0 { title } else { app_id } + let char_w = if tokens.font_size >= 14 { 12 } else { 6 } + let max_chars = (min_x - 8 - 14) / char_w + let shown = if max_chars < 3 { + "" + } else if label.length() <= max_chars { + label + } else { + label[:max_chars - 2].to_string() + ".." + } + ops.push( + Text(14, title_h / 2, shown, tokens.font_size, title_fg, Left, focused), + ) + let close_bg = if focused { Rgba::new(218, 68, 83, 255) } else {