This commit is contained in:
DreamMaoMao 2026-01-24 18:48:53 +08:00 committed by GitHub
commit aa67ed2dea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 71 additions and 23 deletions

View file

@ -246,6 +246,10 @@ void buffer_set_effect(Client *c, BufferData data) {
data.corner_location = CORNER_LOCATION_NONE;
}
if (blur && !c->noblur) {
wlr_scene_blur_set_corner_radius(c->blur, border_radius,
data.corner_location);
}
wlr_scene_node_for_each_buffer(&c->scene_surface->node,
scene_buffer_apply_effect, &data);
}
@ -350,6 +354,14 @@ void client_draw_shadow(Client *c) {
wlr_scene_shadow_set_clipped_region(c->shadow, clipped_region);
}
void client_draw_blur(Client *c, struct wlr_box clip_box, struct ivec2 offset) {
if (blur && !c->noblur) {
wlr_scene_node_set_position(&c->blur->node, offset.x, offset.y);
wlr_scene_blur_set_size(c->blur, clip_box.width - c->bw,
clip_box.height - c->bw);
}
}
void apply_border(Client *c) {
if (!c || c->iskilling || !client_surface(c)->mapped)
return;
@ -521,12 +533,14 @@ void client_apply_clip(Client *c, float factor) {
apply_border(c);
client_draw_shadow(c);
client_draw_blur(c, clip_box, offset);
if (clip_box.width <= 0 || clip_box.height <= 0) {
return;
}
wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip_box);
buffer_set_effect(c, (BufferData){1.0f, 1.0f, clip_box.width,
clip_box.height,
current_corner_location, true});
@ -558,6 +572,7 @@ void client_apply_clip(Client *c, float factor) {
// 应用窗口装饰
apply_border(c);
client_draw_shadow(c);
client_draw_blur(c, clip_box, offset);
// 如果窗口剪切区域已经剪切到0则不渲染窗口表面
if (clip_box.width <= 0 || clip_box.height <= 0) {
@ -998,6 +1013,10 @@ void resize(Client *c, struct wlr_box geo, int32_t interact) {
apply_border(c);
client_get_clip(c, &clip);
wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip);
if (blur && !c->noblur)
wlr_scene_blur_set_size(c->blur,
c->animation.current.width - 2 * c->bw,
c->animation.current.height - 2 * c->bw);
return;
}
// 如果不是工作区切换时划出去的窗口,就让动画的结束位置,就是上面的真实位置和大小
@ -1132,6 +1151,16 @@ bool client_apply_focus_opacity(Client *c) {
target_opacity = opacity;
}
client_set_opacity(c, target_opacity);
if (blur && !c->noblur && !blur_optimized) {
wlr_scene_blur_set_strength(
c->blur, MIN(percent * (1.0 - fadein_begin_opacity) +
fadein_begin_opacity,
1.0));
wlr_scene_blur_set_alpha(
c->blur, MIN(percent * (1.0 - fadein_begin_opacity) +
fadein_begin_opacity,
1.0));
}
} else if (animations && c->opacity_animation.running) {
struct timespec now;