From 381c5f84783e6f5e34cc88e135bb8734103b2044 Mon Sep 17 00:00:00 2001 From: atagen Date: Tue, 7 Apr 2026 12:14:48 +1000 Subject: [PATCH] renderer: fix overextended borders for floating windows w/ title gaps --- src/renderer.rs | 57 ++++++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/src/renderer.rs b/src/renderer.rs index 2b025344..d158ef29 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -683,31 +683,44 @@ impl Renderer<'_> { theme.colors.unfocused_title_background.get() }; let uc = theme.colors.separator.get(); - let borders = [ - Rect::new_sized_saturating(x, y, pos.width(), bw), - Rect::new_sized_saturating(x, y + bw, bw, pos.height() - bw), - Rect::new_sized_saturating(x + pos.width() - bw, y + bw, bw, pos.height() - bw), - Rect::new_sized_saturating(x + bw, y + pos.height() - bw, pos.width() - 2 * bw, bw), - ]; + let gap = theme.sizes.gap.get(); + let floating_title = theme.floating_titles.get() && gap != 0; let srgb_srgb = self.state.color_manager.srgb_gamma22(); let srgb = &srgb_srgb.linear; let perceptual = RenderIntent::Perceptual; - self.base.fill_boxes(&borders, &bc, srgb, perceptual); - let title = [Rect::new_sized_saturating( - x + bw, - y + bw, - pos.width() - 2 * bw, - th, - )]; - self.base.fill_boxes(&title, &tc, srgb, perceptual); - let title_underline = [Rect::new_sized_saturating( - x + bw, - y + bw + th, - pos.width() - 2 * bw, - tuh, - )]; - self.base - .fill_boxes(&title_underline, &uc, srgb, perceptual); + if floating_title { + let title_frame = [ + Rect::new_sized_saturating(x, y, pos.width(), bw), + Rect::new_sized_saturating(x, y + bw, bw, th), + Rect::new_sized_saturating(x + pos.width() - bw, y + bw, bw, th), + Rect::new_sized_saturating(x, y + bw + th, pos.width(), bw), + ]; + self.base.fill_boxes(&title_frame, &bc, srgb, perceptual); + let title_bg = [Rect::new_sized_saturating(x + bw, y + bw, pos.width() - 2 * bw, th)]; + self.base.fill_boxes(&title_bg, &tc, srgb, perceptual); + let body_top = y + tpuh; + let body_inner_top = y + bw + tpuh; + let body_inner_height = pos.height() - 2 * bw - tpuh; + let body_frame = [ + Rect::new_sized_saturating(x, body_top, pos.width(), bw), + Rect::new_sized_saturating(x, body_inner_top, bw, body_inner_height), + Rect::new_sized_saturating(x + pos.width() - bw, body_inner_top, bw, body_inner_height), + Rect::new_sized_saturating(x, y + pos.height() - bw, pos.width(), bw), + ]; + self.base.fill_boxes(&body_frame, &bc, srgb, perceptual); + } else { + let borders = [ + Rect::new_sized_saturating(x, y, pos.width(), bw), + Rect::new_sized_saturating(x, y + bw, bw, pos.height() - bw), + Rect::new_sized_saturating(x + pos.width() - bw, y + bw, bw, pos.height() - bw), + Rect::new_sized_saturating(x + bw, y + pos.height() - bw, pos.width() - 2 * bw, bw), + ]; + self.base.fill_boxes(&borders, &bc, srgb, perceptual); + let title = [Rect::new_sized_saturating(x + bw, y + bw, pos.width() - 2 * bw, th)]; + self.base.fill_boxes(&title, &tc, srgb, perceptual); + let title_underline = [Rect::new_sized_saturating(x + bw, y + bw + th, pos.width() - 2 * bw, tuh)]; + self.base.fill_boxes(&title_underline, &uc, srgb, perceptual); + } let rect = floating.title_rect.get().move_(x, y); let bounds = self.base.scale_rect(rect); let (mut x1, y1) = rect.position();