From 79d9b4aa6be987ab92fb94a48d378077d6195ed9 Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Wed, 17 Jun 2026 21:19:09 +0800 Subject: [PATCH] opt: If nodes are not used, then do not create them --- src/action/client.h | 20 +++++++++++++++++++- src/layout/arrange.h | 9 +++++++++ src/mango.c | 14 -------------- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/action/client.h b/src/action/client.h index 11602e70..d13cb5c6 100644 --- a/src/action/client.h +++ b/src/action/client.h @@ -95,4 +95,22 @@ void client_pending_force_kill(Client *c) { if (!c) return; kill(c->pid, SIGKILL); -} \ No newline at end of file +} + +void client_add_text_node(Client *c) { + c->text_node = mango_text_node_create(c->scene, config.textdata); + wlr_scene_node_lower_to_bottom(&c->text_node->scene_buffer->node); + wlr_scene_node_set_enabled(&c->text_node->scene_buffer->node, false); +} + +void client_add_titlebar_node(Client *c) { + MangoNodeData *mangonodedata = ecalloc(1, sizeof(MangoNodeData)); + mangonodedata->node_data = c; + mangonodedata->type = MANGO_TITLE_NODE; + + c->titlebar_node = mango_titlebar_node_create( + mangonodedata, layers[LyrDecorate], config.textdata, 0, 0); + wlr_scene_node_lower_to_bottom(&c->titlebar_node->scene_buffer->node); + wlr_scene_node_set_enabled(&c->titlebar_node->scene_buffer->node, false); + mango_titlebar_node_update(c->titlebar_node, client_get_title(c), 1.0); +} diff --git a/src/layout/arrange.h b/src/layout/arrange.h index 1c649691..f1c4967a 100644 --- a/src/layout/arrange.h +++ b/src/layout/arrange.h @@ -1143,6 +1143,15 @@ void pre_caculate_before_arrange(Monitor *m, bool want_animation, set_size_per(m, c); } + if (m->is_jump_mode && !c->text_node) { + client_add_text_node(c); + } + + if (m->pertag->ltidxs[m->pertag->curtag]->id == MONOCLE && + !c->titlebar_node) { + client_add_titlebar_node(c); + } + if (c->titlebar_node && c->mon == m) { wlr_scene_node_set_enabled(&c->titlebar_node->scene_buffer->node, false); diff --git a/src/mango.c b/src/mango.c index 5f9998aa..bbdf5779 100644 --- a/src/mango.c +++ b/src/mango.c @@ -4573,20 +4573,6 @@ mapnotify(struct wl_listener *listener, void *data) { #endif // extra node - c->text_node = mango_text_node_create(c->scene, config.textdata); - wlr_scene_node_lower_to_bottom(&c->text_node->scene_buffer->node); - wlr_scene_node_set_enabled(&c->text_node->scene_buffer->node, false); - - MangoNodeData *mangonodedata = ecalloc(1, sizeof(MangoNodeData)); - mangonodedata->node_data = c; - mangonodedata->type = MANGO_TITLE_NODE; - - c->titlebar_node = mango_titlebar_node_create( - mangonodedata, layers[LyrDecorate], config.textdata, 0, 0); - wlr_scene_node_lower_to_bottom(&c->titlebar_node->scene_buffer->node); - wlr_scene_node_set_enabled(&c->titlebar_node->scene_buffer->node, false); - mango_titlebar_node_update(c->titlebar_node, client_get_title(c), 1.0); - for (i = 0; i < 2; i++) { c->splitindicator[i] = wlr_scene_rect_create( c->scene, 0, 0,