opt: shield clip when over screen

This commit is contained in:
DreamMaoMao 2026-02-19 15:03:52 +08:00
parent d9aaf4df3f
commit a7803bd2a5

View file

@ -350,13 +350,12 @@ void client_draw_shadow(Client *c) {
wlr_scene_shadow_set_clipped_region(c->shadow, clipped_region);
}
void apply_shield(Client *c) {
void apply_shield(Client *c, struct wlr_box clip_box) {
if (active_capture_count > 0 && c->shield_when_capture) {
wlr_scene_node_raise_to_top(&c->shield->node);
wlr_scene_node_set_position(&c->shield->node, c->bw, c->bw);
wlr_scene_rect_set_size(c->shield,
c->animation.current.width - 2 * c->bw,
c->animation.current.height - 2 * c->bw);
wlr_scene_node_set_position(&c->shield->node, clip_box.x + c->bw,
clip_box.y + c->bw);
wlr_scene_rect_set_size(c->shield, clip_box.width, clip_box.height);
wlr_scene_node_set_enabled(&c->shield->node, true);
} else {
if (c->shield->node.enabled) {
@ -553,12 +552,12 @@ void client_apply_clip(Client *c, float factor) {
apply_border(c);
client_draw_shadow(c);
apply_shield(c);
if (clip_box.width <= 0 || clip_box.height <= 0) {
return;
}
apply_shield(c, clip_box);
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,
@ -591,7 +590,6 @@ void client_apply_clip(Client *c, float factor) {
// 应用窗口装饰
apply_border(c);
client_draw_shadow(c);
apply_shield(c);
// 如果窗口剪切区域已经剪切到0则不渲染窗口表面
if (clip_box.width <= 0 || clip_box.height <= 0) {
@ -608,6 +606,7 @@ void client_apply_clip(Client *c, float factor) {
}
// 应用窗口表面剪切
apply_shield(c, clip_box);
wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip_box);
// 获取剪切后的表面的实际大小用于计算缩放
@ -1020,8 +1019,8 @@ void resize(Client *c, struct wlr_box geo, int32_t interact) {
client_draw_shadow(c);
apply_border(c);
apply_shield(c);
client_get_clip(c, &clip);
apply_shield(c, clip);
wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip);
return;
}