From 94cf2fc81c202ee2a124bad530abe5a0a9931963 Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Fri, 27 Feb 2026 10:20:21 +0800 Subject: [PATCH] feat: insert the monitor scene tree into the global scene tree in sequence --- src/animation/client.h | 11 +++++++++-- src/mango.c | 23 +++++++++-------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/animation/client.h b/src/animation/client.h index 84ea80f8..f5795c9f 100644 --- a/src/animation/client.h +++ b/src/animation/client.h @@ -290,6 +290,13 @@ void apply_border(Client *c) { wlr_scene_node_set_position(&c->border[3]->node, fullgeom.width - bw, 0); } +void monitor_clip_scene_tree(Monitor *m) { + int i; + for (i = 0; i < NUM_LAYERS; i++) { + wlr_scene_tree_set_clip(m->layers_scene_tree[i], &m->m); + } +} + void client_apply_clip(Client *c, float factor) { if (c->iskilling || !client_surface(c)->mapped) return; @@ -306,7 +313,7 @@ void client_apply_clip(Client *c, float factor) { client_get_clip(c, &clip_box); // 获取相对于父级的初始剪切区域 - wlr_scene_tree_set_clip(c->mon->scene_tree, &c->mon->m); + monitor_clip_scene_tree(c->mon); apply_border(c); apply_shield(c); @@ -340,7 +347,7 @@ void client_apply_clip(Client *c, float factor) { clip_box.y = 0; } - wlr_scene_tree_set_clip(c->mon->scene_tree, &c->mon->m); + monitor_clip_scene_tree(c->mon); apply_border(c); apply_shield(c); diff --git a/src/mango.c b/src/mango.c index 35108bc7..ce7d236d 100644 --- a/src/mango.c +++ b/src/mango.c @@ -518,7 +518,6 @@ struct Monitor { bool skiping_frame; uint32_t resizing_count_pending; uint32_t resizing_count_current; - struct wlr_scene_tree *scene_tree; struct wlr_scene_tree *layers_scene_tree[NUM_LAYERS]; struct wl_list dwl_ipc_outputs; @@ -2858,12 +2857,11 @@ void createmon(struct wl_listener *listener, void *data) { m->wlr_output = wlr_output; m->wlr_output->data = m; - m->scene_tree = wlr_scene_tree_create(&scene->tree); - - for (i = 0; i < NUM_LAYERS; i++) - m->layers_scene_tree[i] = wlr_scene_tree_create(m->scene_tree); - - wlr_scene_node_place_below(&m->scene_tree->node, &layers[LyrTile]->node); + for (i = 0; i < NUM_LAYERS; i++) { + m->layers_scene_tree[i] = wlr_scene_tree_create(&scene->tree); + wlr_scene_node_place_below(&m->layers_scene_tree[i]->node, + &layers[i]->node); + } wl_list_init(&m->dwl_ipc_outputs); @@ -4680,16 +4678,13 @@ void requeststartdrag(struct wl_listener *listener, void *data) { void client_apply_node_layer(Client *c) { - if(!c->mon) { + if (!c->mon) { if (c->isoverlay) { - wlr_scene_node_reparent(&c->scene->node, - layers[LyrOverlay]); + wlr_scene_node_reparent(&c->scene->node, layers[LyrOverlay]); } else if (c->isfloating || c->isfullscreen) { - wlr_scene_node_reparent(&c->scene->node, - layers[LyrTop]); + wlr_scene_node_reparent(&c->scene->node, layers[LyrTop]); } else { - wlr_scene_node_reparent(&c->scene->node, - layers[LyrTile]); + wlr_scene_node_reparent(&c->scene->node, layers[LyrTile]); } return;