feat: add shield_when_capture windowrule to disable capture

This commit is contained in:
DreamMaoMao 2026-02-19 14:39:37 +08:00
parent 78e7bc9f34
commit 5615fd554f
3 changed files with 95 additions and 1 deletions

View file

@ -227,6 +227,22 @@ void buffer_set_effect(Client *c, BufferData data) {
scene_buffer_apply_effect, &data);
}
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, clip_box.x, clip_box.y);
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) {
wlr_scene_node_lower_to_bottom(&c->shield->node);
wlr_scene_rect_set_size(c->shield, c->animation.current.width,
c->animation.current.height);
wlr_scene_node_set_enabled(&c->shield->node, false);
}
}
}
void apply_border(Client *c) {
bool hit_no_border = false;
@ -412,6 +428,7 @@ void client_apply_clip(Client *c, float factor) {
return;
}
apply_shield(c, clip_box);
wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip_box);
buffer_set_effect(
@ -459,6 +476,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);
// 获取剪切后的表面的实际大小用于计算缩放
@ -873,6 +891,7 @@ void resize(Client *c, struct wlr_box geo, int32_t interact) {
apply_border(c);
client_get_clip(c, &clip);
apply_shield(c, clip);
wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip);
return;
}