From 684ae2f72f7900fc66ff7cc61ee30be456a29259 Mon Sep 17 00:00:00 2001 From: nolight132 Date: Mon, 16 Nov 2026 13:19:54 +0100 Subject: [PATCH 1/2] fix(gpui): grow the corners of a spread shadow with its box --- crates/gpui/src/window.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/crates/gpui/src/window.rs b/crates/gpui/src/window.rs index 903f03c..79f04b4 100644 --- a/crates/gpui/src/window.rs +++ b/crates/gpui/src/window.rs @@ -4931,12 +4931,24 @@ impl Window { continue; } let shadow_bounds = (bounds + shadow.offset).dilate(shadow.spread_radius); + // The spread grows the rounded corners with the box, as CSS does, so a ring drawn + // with a spread keeps one width around the corners. A square corner stays square. + let spread = |radius: Pixels| match radius > Pixels::ZERO { + true => (radius + shadow.spread_radius).max(Pixels::ZERO), + false => radius, + }; + let shadow_corner_radii = Corners { + top_left: spread(corner_radii.top_left), + top_right: spread(corner_radii.top_right), + bottom_right: spread(corner_radii.bottom_right), + bottom_left: spread(corner_radii.bottom_left), + }; self.next_frame.scene.insert_primitive(Shadow { order: 0, blur_radius: shadow.blur_radius.scale(scale_factor), bounds: self.cover_bounds(shadow_bounds), content_mask, - corner_radii: corner_radii.scale(scale_factor), + corner_radii: shadow_corner_radii.scale(scale_factor), color: shadow.color.opacity(opacity), element_bounds, element_corner_radii, From 0e3bd2f54adb10dd7f6dcbc3ffdafdc79d91a0b5 Mon Sep 17 00:00:00 2001 From: nolight132 Date: Mon, 16 Nov 2026 13:25:56 +0100 Subject: [PATCH 2/2] fix(gpui): grow a tight corner by less than the spread, as css does --- crates/gpui/src/window.rs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/crates/gpui/src/window.rs b/crates/gpui/src/window.rs index 79f04b4..1c41f86 100644 --- a/crates/gpui/src/window.rs +++ b/crates/gpui/src/window.rs @@ -4932,10 +4932,23 @@ impl Window { } let shadow_bounds = (bounds + shadow.offset).dilate(shadow.spread_radius); // The spread grows the rounded corners with the box, as CSS does, so a ring drawn - // with a spread keeps one width around the corners. A square corner stays square. - let spread = |radius: Pixels| match radius > Pixels::ZERO { - true => (radius + shadow.spread_radius).max(Pixels::ZERO), - false => radius, + // with a spread keeps one width around the corners. A square corner stays square, + // and a corner rounded less than the spread grows by less, so it does not jump to + // the full spread. + let spread = |radius: Pixels| { + let reach = shadow.spread_radius; + if radius <= Pixels::ZERO { + return radius; + } + if reach <= Pixels::ZERO { + return (radius + reach).max(Pixels::ZERO); + } + let ratio = radius / reach; + let grow = match ratio < 1. { + true => reach * (1. + (ratio - 1.).powi(3)), + false => reach, + }; + radius + grow }; let shadow_corner_radii = Corners { top_left: spread(corner_radii.top_left),