Fixed box shadow not using outer corner radii

This commit is contained in:
Erik Reider 2022-12-28 19:25:31 +01:00 committed by Will McKinnon
parent cb80e0520d
commit f498e62b53
2 changed files with 7 additions and 3 deletions

View file

@ -332,7 +332,7 @@ damage_finish:
// _box.width and .height are expected to be output-buffer-local
void render_box_shadow(struct sway_output *output, pixman_region32_t *output_damage,
const struct wlr_box *_box, const float color[static 4],
float blur_sigma, float corner_radius) {
float blur_sigma, float corner_radius, float border_thickness) {
struct wlr_output *wlr_output = output->wlr_output;
struct fx_renderer *renderer = output->server->renderer;
@ -351,6 +351,9 @@ void render_box_shadow(struct sway_output *output, pixman_region32_t *output_dam
box.width += 2 * blur_sigma;
box.height += 2 * blur_sigma;
// Uses the outer radii of the window for a more realistic look
corner_radius = corner_radius + border_thickness;
pixman_region32_t damage;
pixman_region32_init(&damage);
pixman_region32_union_rect(&damage, &damage, box.x, box.y,
@ -1039,7 +1042,8 @@ static void render_containers_linear(struct sway_output *output,
float blur_sigma = 20;
struct wlr_box box = { state->x, state->y, state->width, state->height };
scale_box(&box, output->wlr_output->scale);
render_box_shadow(output, damage, &box, color, blur_sigma, deco_data.corner_radius);
render_box_shadow(output, damage, &box, color, blur_sigma,
deco_data.corner_radius, child->current.border_thickness);
} else {
render_container(output, damage, child,
parent->focused || child->current.focused);

View file

@ -10,7 +10,7 @@ void main() {
vec2 half_size = size / 2.0;
vec2 q = abs(gl_FragCoord.xy - position - half_size) - half_size + radius;
float distance = min(max(q.x,q.y),0.0) + length(max(q,0.0)) - radius;
float smoothedAlpha = 1.0 - smoothstep(-1.0, 1.0, distance);
float smoothedAlpha = 1.0 - smoothstep(-1.0, 0.5, distance);
gl_FragColor = mix(vec4(0), v_color, smoothedAlpha);
if (gl_FragColor.a == 0.0) {
discard;