From 167acfd1d5254406fbcd5e3c5a76625cc47efbf9 Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Wed, 1 Jul 2026 12:35:31 +0800 Subject: [PATCH] testshieldlayer --- src/animation/layer.h | 34 ++++++++++++++++++++++++++++++++++ src/config/parse_config.h | 4 ++++ src/mango.c | 11 +++++++++++ 3 files changed, 49 insertions(+) diff --git a/src/animation/layer.h b/src/animation/layer.h index 80d7e6ca..65537033 100644 --- a/src/animation/layer.h +++ b/src/animation/layer.h @@ -151,6 +151,38 @@ void set_layer_dir_animaiton(LayerSurface *l, struct wlr_box *geo) { } } +void layer_draw_shield(LayerSurface *l) { + int32_t width, height; + wlr_log(WLR_ERROR,"0"); + + if (!l->mapped) + return; + + wlr_log(WLR_ERROR,"1"); + if (active_capture_count > 0 && l->shield_when_capture) { + + wlr_log(WLR_ERROR,"2"); + layer_actual_size(l, &width, &height); + + if (width <= 0 || height <= 0) { + wlr_scene_node_set_enabled(&l->shield->node, false); + return; + } + wlr_log(WLR_ERROR,"3"); + + wlr_scene_node_raise_to_top(&l->shield->node); + wlr_scene_node_set_position(&l->shield->node, 0, 0); + wlr_scene_rect_set_size(l->shield, width, height); + wlr_scene_node_set_enabled(&l->shield->node, true); + } else { + if (l->shield->node.enabled) { + wlr_scene_node_lower_to_bottom(&l->shield->node); + wlr_scene_node_set_position(&l->shield->node, 0, 0); + wlr_scene_node_set_enabled(&l->shield->node, false); + } + } +} + void layer_draw_shadow(LayerSurface *l) { if (!l->mapped || !l->shadow) @@ -575,8 +607,10 @@ bool layer_draw_frame(LayerSurface *l) { if (config.animations && config.layer_animations && l->animation.running && !l->noanim) { layer_animation_next_tick(l); + layer_draw_shield(l); layer_draw_shadow(l); } else { + layer_draw_shield(l); layer_draw_shadow(l); l->need_output_flush = false; } diff --git a/src/config/parse_config.h b/src/config/parse_config.h index fe8b7a0e..1cdc01cf 100644 --- a/src/config/parse_config.h +++ b/src/config/parse_config.h @@ -188,6 +188,7 @@ typedef struct { char *layer_name; // 布局名称 char *animation_type_open; char *animation_type_close; + int32_t shield_when_capture; int32_t noblur; int32_t noanim; int32_t noshadow; @@ -2310,6 +2311,7 @@ bool parse_option(Config *config, char *key, char *value) { rule->layer_name = NULL; rule->animation_type_open = NULL; rule->animation_type_close = NULL; + rule->shield_when_capture = 0; rule->noblur = 0; rule->noanim = 0; rule->noshadow = 0; @@ -2332,6 +2334,8 @@ bool parse_option(Config *config, char *key, char *value) { rule->animation_type_open = strdup(val); } else if (strcmp(key, "animation_type_close") == 0) { rule->animation_type_close = strdup(val); + } else if (strcmp(key, "shield_when_capture") == 0) { + rule->shield_when_capture = CLAMP_INT(atoi(val), 0, 1); } else if (strcmp(key, "noblur") == 0) { rule->noblur = CLAMP_INT(atoi(val), 0, 1); } else if (strcmp(key, "noanim") == 0) { diff --git a/src/mango.c b/src/mango.c index 056d7b6d..e22eb55f 100644 --- a/src/mango.c +++ b/src/mango.c @@ -522,6 +522,7 @@ typedef struct { Monitor *mon; struct wlr_scene_tree *scene; struct wlr_scene_tree *popups; + struct wlr_scene_rect *shield; struct wlr_scene_shadow *shadow; struct wlr_scene_blur *blur; struct wlr_scene_layer_surface_v1 *scene_layer; @@ -542,6 +543,7 @@ typedef struct { int32_t noshadow; char *animation_type_open; char *animation_type_close; + bool shield_when_capture; bool need_output_flush; bool being_unmapped; } LayerSurface; @@ -2808,6 +2810,7 @@ void maplayersurfacenotify(struct wl_listener *listener, void *data) { l->noanim = 0; l->dirty = false; + l->shield_when_capture = false; l->noblur = 0; l->shadow = NULL; l->need_output_flush = true; @@ -2820,6 +2823,7 @@ void maplayersurfacenotify(struct wl_listener *listener, void *data) { l->layer_surface->namespace)) { r = &config.layer_rules[ji]; + APPLY_INT_PROP(l, r, shield_when_capture); APPLY_INT_PROP(l, r, noblur); APPLY_INT_PROP(l, r, noanim); APPLY_INT_PROP(l, r, noshadow); @@ -2828,6 +2832,13 @@ void maplayersurfacenotify(struct wl_listener *listener, void *data) { } } + // 初始化屏蔽 + l->shield = + wlr_scene_rect_create(l->scene, 0, 0, (float[4]){0, 0, 0, 0xff}); + l->shield->node.data = l; + wlr_scene_node_lower_to_bottom(&l->shield->node); + wlr_scene_node_set_enabled(&l->shield->node, false); + // 初始化阴影 if (layer_surface->current.layer != ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM && layer_surface->current.layer != ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND) {