From a5d44d7347b788a3958341333d1d8c1b74285bab Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Thu, 18 Jun 2026 10:18:16 +0800 Subject: [PATCH] opt: tab_bar_decorate and jump_label_decorate config separate --- docs/visuals/theming.md | 40 +++++-- src/action/client.h | 20 ++-- src/animation/client.h | 8 +- src/config/parse_config.h | 234 ++++++++++++++++++++++++++++---------- src/draw/text-node.c | 58 +++++----- src/draw/text-node.h | 52 ++++----- src/layout/arrange.h | 14 +-- src/layout/overview.h | 16 +-- src/mango.c | 16 +-- 9 files changed, 292 insertions(+), 166 deletions(-) diff --git a/docs/visuals/theming.md b/docs/visuals/theming.md index 928b1d24..2f9993be 100644 --- a/docs/visuals/theming.md +++ b/docs/visuals/theming.md @@ -14,7 +14,6 @@ Control the sizing of window borders and gaps. | `gappiv` | `5` | Vertical inner gap. | | `gappoh` | `10` | Horizontal outer gap (between windows and screen edges). | | `gappov` | `10` | Vertical outer gap. | -| `tab_bar_height` | `50` | Height of the tab bar for monocle layout. | ## Colors @@ -56,16 +55,35 @@ You can also color-code windows based on their state: ### Overview Jump Mode | Setting | Default | Description | | :--- | :--- | :--- | -| `text_decorate_fg_color` | `0xc4939dff` | label text color. | -| `text_decorate_bg_color` | `0x201b14ff` | label background color.| -| `text_decorate_focus_fg_color` | `0x201b14ff` | label text color for focus. | -| `text_decorate_focus_bg_color` | `0xc4939dff` | label background color for focus.| -| `text_decorate_border_color` | `0x8BAA9Bff` | label border color.| -| `text_decorate_border_width` | `4` | label border width.| -| `text_decorate_corner_radius` | `5` | label corner radius.| -| `text_decorate_padding_x` | `10` | label horizontal padding.| -| `text_decorate_padding_y` | `10` | label vertical padding.| -| `text_decorate_font_desc` | `monospace Bold 16` | label font set.| +| `jump_label_decorate_fg_color` | `0xc4939dff` | text color. | +| `jump_label_decorate_bg_color` | `0x201b14ff` | background color.| +| `jump_label_decorate_focus_fg_color` | `0x201b14ff` | text color for focus. | +| `jump_label_decorate_focus_bg_color` | `0xc4939dff` | background color for focus.| +| `jump_label_decorate_border_color` | `0x8BAA9Bff` | border color.| +| `jump_label_decorate_border_width` | `4` | border width.| +| `jump_label_decorate_corner_radius` | `5` | corner radius.| +| `jump_label_decorate_padding_x` | `10` | horizontal padding.| +| `jump_label_decorate_padding_y` | `10` | vertical padding.| +| `jump_label_decorate_font_desc` | `monospace Bold 16` | font set.| + +### Tab Bar For Monocle Layout +| Setting | Default | Description | +| :--- | :--- | :--- | +| `tab_bar_height` | `50` | Height of the tab bar for monocle layout. | +| `tab_bar_decorate_fg_color` | `0xc4939dff` | text color. +| `tab_bar_decorate_bg_color` | `0x201b14ff` | background color.| +| `tab_bar_decorate_focus_fg_color` | `0x201b14ff` | text color for focus. | +| `tab_bar_decorate_focus_bg_color` | `0xc4939dff` | background color for focus.| +| `tab_bar_decorate_border_color` | `0x8BAA9Bff` | border color.| +| `tab_bar_decorate_border_width` | `4` | border width.| +| `tab_bar_decorate_corner_radius` | `5` | corner radius.| +| `tab_bar_decorate_padding_x` | `0` | horizontal padding.| +| `tab_bar_decorate_padding_y` | `0` | vertical padding.| +| `tab_bar_decorate_font_desc` | `monospace Bold 16` | font set.| + +## Borders + +Control the appearance of window borders. ## Cursor Theme diff --git a/src/action/client.h b/src/action/client.h index d13cb5c6..80327487 100644 --- a/src/action/client.h +++ b/src/action/client.h @@ -97,20 +97,20 @@ void client_pending_force_kill(Client *c) { kill(c->pid, SIGKILL); } -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_jump_label_node(Client *c) { + c->jump_label_node = mango_jump_label_node_create(c->scene, config.jumplabeldata); + wlr_scene_node_lower_to_bottom(&c->jump_label_node->scene_buffer->node); + wlr_scene_node_set_enabled(&c->jump_label_node->scene_buffer->node, false); } -void client_add_titlebar_node(Client *c) { +void client_add_tab_bar_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); + c->tab_bar_node = mango_tab_bar_node_create( + mangonodedata, layers[LyrDecorate], config.tabdata, 0, 0); + wlr_scene_node_lower_to_bottom(&c->tab_bar_node->scene_buffer->node); + wlr_scene_node_set_enabled(&c->tab_bar_node->scene_buffer->node, false); + mango_tab_bar_node_update(c->tab_bar_node, client_get_title(c), 1.0); } diff --git a/src/animation/client.h b/src/animation/client.h index 22a7dcb1..5e4f3fd7 100644 --- a/src/animation/client.h +++ b/src/animation/client.h @@ -400,12 +400,12 @@ void client_draw_shadow(Client *c) { void global_draw_titlebar(Client *c, int32_t x, int32_t y, int32_t width, int32_t height) { - if (!c->titlebar_node) + if (!c->tab_bar_node) return; - wlr_scene_node_set_position(&c->titlebar_node->scene_buffer->node, x, y); - wlr_scene_node_set_enabled(&c->titlebar_node->scene_buffer->node, true); - mango_titlebar_node_set_size(c->titlebar_node, width, height); + wlr_scene_node_set_position(&c->tab_bar_node->scene_buffer->node, x, y); + wlr_scene_node_set_enabled(&c->tab_bar_node->scene_buffer->node, true); + mango_tab_bar_node_set_size(c->tab_bar_node, width, height); } void apply_split_border(Client *c, bool hit_no_border) { diff --git a/src/config/parse_config.h b/src/config/parse_config.h index 7b7f0daf..df332f7a 100644 --- a/src/config/parse_config.h +++ b/src/config/parse_config.h @@ -409,7 +409,8 @@ typedef struct { struct xkb_context *ctx; struct xkb_keymap *keymap; - TextDrawData textdata; + DecorateDrawData jumplabeldata; + DecorateDrawData tabdata; } Config; typedef int32_t (*FuncType)(const Arg *); @@ -1764,76 +1765,146 @@ bool parse_option(Config *config, char *key, char *value) { config->cursor_size = atoi(value); } else if (strcmp(key, "cursor_theme") == 0) { config->cursor_theme = strdup(value); - } else if (strcmp(key, "text_decorate_font_desc") == 0) { - config->textdata.font_desc = strdup(value); - } else if (strcmp(key, "text_decorate_fg_color") == 0) { + } else if (strcmp(key, "tab_bar_decorate_font_desc") == 0) { + config->tabdata.font_desc = strdup(value); + } else if (strcmp(key, "tab_bar_decorate_fg_color") == 0) { int64_t color = parse_color(value); if (color == -1) { fprintf(stderr, "\033[1m\033[31m[ERROR]:\033[33m Invalid " - "text_decorate_fg_color " + "tab_bar_decorate_fg_color " "format: %s\n", value); return false; } else { - convert_hex_to_rgba(config->textdata.fg_color, color); + convert_hex_to_rgba(config->tabdata.fg_color, color); } - } else if (strcmp(key, "text_decorate_bg_color") == 0) { + } else if (strcmp(key, "tab_bar_decorate_bg_color") == 0) { int64_t color = parse_color(value); if (color == -1) { fprintf(stderr, "\033[1m\033[31m[ERROR]:\033[33m Invalid " - "text_decorate_bg_color " + "tab_bar_decorate_bg_color " "format: %s\n", value); return false; } else { - convert_hex_to_rgba(config->textdata.bg_color, color); + convert_hex_to_rgba(config->tabdata.bg_color, color); } - } else if (strcmp(key, "text_decorate_focus_fg_color") == 0) { + } else if (strcmp(key, "tab_bar_decorate_focus_fg_color") == 0) { int64_t color = parse_color(value); if (color == -1) { fprintf(stderr, "\033[1m\033[31m[ERROR]:\033[33m Invalid " - "text_decorate_focus_fg_color " + "tab_bar_decorate_focus_fg_color " "format: %s\n", value); return false; } else { - convert_hex_to_rgba(config->textdata.focus_fg_color, color); + convert_hex_to_rgba(config->tabdata.focus_fg_color, color); } - } else if (strcmp(key, "text_decorate_focus_bg_color") == 0) { + } else if (strcmp(key, "tab_bar_decorate_focus_bg_color") == 0) { int64_t color = parse_color(value); if (color == -1) { fprintf(stderr, "\033[1m\033[31m[ERROR]:\033[33m Invalid " - "text_decorate_focus_bg_color " + "tab_bar_decorate_focus_bg_color " "format: %s\n", value); return false; } else { - convert_hex_to_rgba(config->textdata.focus_bg_color, color); + convert_hex_to_rgba(config->tabdata.focus_bg_color, color); } - } else if (strcmp(key, "text_decorate_border_color") == 0) { + } else if (strcmp(key, "tab_bar_decorate_border_color") == 0) { int64_t color = parse_color(value); if (color == -1) { fprintf(stderr, "\033[1m\033[31m[ERROR]:\033[33m Invalid " - "text_decorate_border_color " + "tab_bar_decorate_border_color " "format: %s\n", value); return false; } else { - convert_hex_to_rgba(config->textdata.border_color, color); + convert_hex_to_rgba(config->tabdata.border_color, color); } - } else if (strcmp(key, "text_decorate_border_width") == 0) { - config->textdata.border_width = CLAMP_INT(atoi(value), 0, 100); - } else if (strcmp(key, "text_decorate_corner_radius") == 0) { - config->textdata.corner_radius = CLAMP_INT(atoi(value), 0, 100); - } else if (strcmp(key, "text_decorate_padding_x") == 0) { - config->textdata.padding_x = CLAMP_INT(atoi(value), 0, 100); - } else if (strcmp(key, "text_decorate_padding_y") == 0) { - config->textdata.padding_y = CLAMP_INT(atoi(value), 0, 100); + } else if (strcmp(key, "tab_bar_decorate_border_width") == 0) { + config->tabdata.border_width = CLAMP_INT(atoi(value), 0, 100); + } else if (strcmp(key, "tab_bar_decorate_corner_radius") == 0) { + config->tabdata.corner_radius = CLAMP_INT(atoi(value), 0, 100); + } else if (strcmp(key, "tab_bar_decorate_padding_x") == 0) { + config->tabdata.padding_x = CLAMP_INT(atoi(value), 0, 100); + } else if (strcmp(key, "tab_bar_decorate_padding_y") == 0) { + config->tabdata.padding_y = CLAMP_INT(atoi(value), 0, 100); + } else if (strcmp(key, "jump_label_decorate_font_desc") == 0) { + config->jumplabeldata.font_desc = strdup(value); + } else if (strcmp(key, "jump_label_decorate_fg_color") == 0) { + int64_t color = parse_color(value); + if (color == -1) { + fprintf(stderr, + "\033[1m\033[31m[ERROR]:\033[33m Invalid " + "jump_label_decorate_fg_color " + "format: %s\n", + value); + return false; + } else { + convert_hex_to_rgba(config->jumplabeldata.fg_color, color); + } + } else if (strcmp(key, "jump_label_decorate_bg_color") == 0) { + int64_t color = parse_color(value); + if (color == -1) { + fprintf(stderr, + "\033[1m\033[31m[ERROR]:\033[33m Invalid " + "jump_label_decorate_bg_color " + "format: %s\n", + value); + return false; + } else { + convert_hex_to_rgba(config->jumplabeldata.bg_color, color); + } + } else if (strcmp(key, "jump_label_decorate_focus_fg_color") == 0) { + int64_t color = parse_color(value); + if (color == -1) { + fprintf(stderr, + "\033[1m\033[31m[ERROR]:\033[33m Invalid " + "jump_label_decorate_focus_fg_color " + "format: %s\n", + value); + return false; + } else { + convert_hex_to_rgba(config->jumplabeldata.focus_fg_color, color); + } + } else if (strcmp(key, "jump_label_decorate_focus_bg_color") == 0) { + int64_t color = parse_color(value); + if (color == -1) { + fprintf(stderr, + "\033[1m\033[31m[ERROR]:\033[33m Invalid " + "jump_label_decorate_focus_bg_color " + "format: %s\n", + value); + return false; + } else { + convert_hex_to_rgba(config->jumplabeldata.focus_bg_color, color); + } + } else if (strcmp(key, "jump_label_decorate_border_color") == 0) { + int64_t color = parse_color(value); + if (color == -1) { + fprintf(stderr, + "\033[1m\033[31m[ERROR]:\033[33m Invalid " + "jump_label_decorate_border_color " + "format: %s\n", + value); + return false; + } else { + convert_hex_to_rgba(config->jumplabeldata.border_color, color); + } + } else if (strcmp(key, "jump_label_decorate_border_width") == 0) { + config->jumplabeldata.border_width = CLAMP_INT(atoi(value), 0, 100); + } else if (strcmp(key, "jump_label_decorate_corner_radius") == 0) { + config->jumplabeldata.corner_radius = CLAMP_INT(atoi(value), 0, 100); + } else if (strcmp(key, "jump_label_decorate_padding_x") == 0) { + config->jumplabeldata.padding_x = CLAMP_INT(atoi(value), 0, 100); + } else if (strcmp(key, "jump_label_decorate_padding_y") == 0) { + config->jumplabeldata.padding_y = CLAMP_INT(atoi(value), 0, 100); } else if (strcmp(key, "disable_while_typing") == 0) { config->disable_while_typing = atoi(value); } else if (strcmp(key, "left_handed") == 0) { @@ -3325,9 +3396,14 @@ void free_config(void) { config.cursor_theme = NULL; } - if (config.textdata.font_desc) { - free((void *)config.textdata.font_desc); - config.textdata.font_desc = NULL; + if (config.jumplabeldata.font_desc) { + free((void *)config.jumplabeldata.font_desc); + config.jumplabeldata.font_desc = NULL; + } + + if (config.tabdata.font_desc) { + free((void *)config.tabdata.font_desc); + config.tabdata.font_desc = NULL; } if (config.tablet_map_to_mon) { @@ -3522,12 +3598,19 @@ void override_config(void) { config.unfocused_opacity = CLAMP_FLOAT(config.unfocused_opacity, 0.0f, 1.0f); - config.textdata.border_width = - CLAMP_INT(config.textdata.border_width, 0, 100); - config.textdata.corner_radius = - CLAMP_INT(config.textdata.corner_radius, 0, 100); - config.textdata.padding_x = CLAMP_INT(config.textdata.padding_x, 0, 100); - config.textdata.padding_y = CLAMP_INT(config.textdata.padding_y, 0, 100); + config.tabdata.border_width = + CLAMP_INT(config.tabdata.border_width, 0, 100); + config.tabdata.corner_radius = + CLAMP_INT(config.tabdata.corner_radius, 0, 100); + config.tabdata.padding_x = CLAMP_INT(config.tabdata.padding_x, 0, 100); + config.tabdata.padding_y = CLAMP_INT(config.tabdata.padding_y, 0, 100); + + config.jumplabeldata.border_width = + CLAMP_INT(config.jumplabeldata.border_width, 0, 100); + config.jumplabeldata.corner_radius = + CLAMP_INT(config.jumplabeldata.corner_radius, 0, 100); + config.jumplabeldata.padding_x = CLAMP_INT(config.jumplabeldata.padding_x, 0, 100); + config.jumplabeldata.padding_y = CLAMP_INT(config.jumplabeldata.padding_y, 0, 100); } void set_value_default() { @@ -3704,30 +3787,55 @@ void set_value_default() { config.animation_curve_opafadeout[2] = 0.5; config.animation_curve_opafadeout[3] = 0.5; - config.textdata.fg_color[0] = 0xc4 / 255.0f; - config.textdata.fg_color[1] = 0x93 / 255.0f; - config.textdata.fg_color[2] = 0x9d / 255.0f; - config.textdata.fg_color[3] = 1.0f; - config.textdata.bg_color[0] = 0x32 / 255.0f; - config.textdata.bg_color[1] = 0x32 / 255.0f; - config.textdata.bg_color[2] = 0x32 / 255.0f; - config.textdata.bg_color[3] = 1.0f; - config.textdata.focus_fg_color[0] = 0xed / 255.0f; - config.textdata.focus_fg_color[1] = 0xa6 / 255.0f; - config.textdata.focus_fg_color[2] = 0xb4 / 255.0f; - config.textdata.focus_fg_color[3] = 1.0f; - config.textdata.focus_bg_color[0] = 0x4e / 255.0f; - config.textdata.focus_bg_color[1] = 0x45 / 255.0f; - config.textdata.focus_bg_color[2] = 0x3c / 255.0f; - config.textdata.focus_bg_color[3] = 1.0f; - config.textdata.border_color[0] = 0x8b / 255.0f; - config.textdata.border_color[1] = 0xaa / 255.0f; - config.textdata.border_color[2] = 0x9b / 255.0f; - config.textdata.border_color[3] = 1.0f; - config.textdata.border_width = 4; - config.textdata.corner_radius = 5; - config.textdata.padding_x = 10; - config.textdata.padding_y = 10; + config.tabdata.fg_color[0] = 0xc4 / 255.0f; + config.tabdata.fg_color[1] = 0x93 / 255.0f; + config.tabdata.fg_color[2] = 0x9d / 255.0f; + config.tabdata.fg_color[3] = 1.0f; + config.tabdata.bg_color[0] = 0x32 / 255.0f; + config.tabdata.bg_color[1] = 0x32 / 255.0f; + config.tabdata.bg_color[2] = 0x32 / 255.0f; + config.tabdata.bg_color[3] = 1.0f; + config.tabdata.focus_fg_color[0] = 0xed / 255.0f; + config.tabdata.focus_fg_color[1] = 0xa6 / 255.0f; + config.tabdata.focus_fg_color[2] = 0xb4 / 255.0f; + config.tabdata.focus_fg_color[3] = 1.0f; + config.tabdata.focus_bg_color[0] = 0x4e / 255.0f; + config.tabdata.focus_bg_color[1] = 0x45 / 255.0f; + config.tabdata.focus_bg_color[2] = 0x3c / 255.0f; + config.tabdata.focus_bg_color[3] = 1.0f; + config.tabdata.border_color[0] = 0x8b / 255.0f; + config.tabdata.border_color[1] = 0xaa / 255.0f; + config.tabdata.border_color[2] = 0x9b / 255.0f; + config.tabdata.border_color[3] = 1.0f; + config.tabdata.border_width = 4; + config.tabdata.corner_radius = 5; + config.tabdata.padding_x = 0; + config.tabdata.padding_y = 0; + + config.jumplabeldata.fg_color[0] = 0xc4 / 255.0f; + config.jumplabeldata.fg_color[1] = 0x93 / 255.0f; + config.jumplabeldata.fg_color[2] = 0x9d / 255.0f; + config.jumplabeldata.fg_color[3] = 1.0f; + config.jumplabeldata.bg_color[0] = 0x32 / 255.0f; + config.jumplabeldata.bg_color[1] = 0x32 / 255.0f; + config.jumplabeldata.bg_color[2] = 0x32 / 255.0f; + config.jumplabeldata.bg_color[3] = 1.0f; + config.jumplabeldata.focus_fg_color[0] = 0xed / 255.0f; + config.jumplabeldata.focus_fg_color[1] = 0xa6 / 255.0f; + config.jumplabeldata.focus_fg_color[2] = 0xb4 / 255.0f; + config.jumplabeldata.focus_fg_color[3] = 1.0f; + config.jumplabeldata.focus_bg_color[0] = 0x4e / 255.0f; + config.jumplabeldata.focus_bg_color[1] = 0x45 / 255.0f; + config.jumplabeldata.focus_bg_color[2] = 0x3c / 255.0f; + config.jumplabeldata.focus_bg_color[3] = 1.0f; + config.jumplabeldata.border_color[0] = 0x8b / 255.0f; + config.jumplabeldata.border_color[1] = 0xaa / 255.0f; + config.jumplabeldata.border_color[2] = 0x9b / 255.0f; + config.jumplabeldata.border_color[3] = 1.0f; + config.jumplabeldata.border_width = 4; + config.jumplabeldata.corner_radius = 5; + config.jumplabeldata.padding_x = 10; + config.jumplabeldata.padding_y = 10; config.rootcolor[0] = 0x32 / 255.0f; config.rootcolor[1] = 0x32 / 255.0f; @@ -3841,7 +3949,8 @@ bool parse_config(void) { config.tag_rules = NULL; config.tag_rules_count = 0; config.cursor_theme = NULL; - config.textdata.font_desc = NULL; + config.jumplabeldata.font_desc = NULL; + config.tabdata.font_desc = NULL; config.tablet_map_to_mon = NULL; strcpy(config.keymode, "default"); @@ -4006,9 +4115,8 @@ void reapply_property(void) { c->bw = config.borderpx; } - mango_text_node_apply_config(c->text_node, &config.textdata); - mango_titlebar_node_apply_config(c->titlebar_node, - &config.textdata); + mango_jump_label_node_apply_config(c->jump_label_node, &config.jumplabeldata); + mango_tab_bar_node_apply_config(c->tab_bar_node, &config.tabdata); wlr_scene_rect_set_color(c->droparea, config.dropcolor); wlr_scene_rect_set_color(c->splitindicator[0], config.splitcolor); diff --git a/src/draw/text-node.c b/src/draw/text-node.c index 32164fbe..048b7d25 100644 --- a/src/draw/text-node.c +++ b/src/draw/text-node.c @@ -59,9 +59,9 @@ static const struct wlr_buffer_impl text_buffer_impl = { .end_data_ptr_access = text_buffer_end_data_ptr_access, }; -struct mango_text_node *mango_text_node_create(struct wlr_scene_tree *parent, - TextDrawData data) { - struct mango_text_node *node = calloc(1, sizeof(*node)); +struct mango_jump_label_node *mango_jump_label_node_create(struct wlr_scene_tree *parent, + DecorateDrawData data) { + struct mango_jump_label_node *node = calloc(1, sizeof(*node)); if (!node) return NULL; @@ -103,7 +103,7 @@ struct mango_text_node *mango_text_node_create(struct wlr_scene_tree *parent, return node; } -void mango_text_node_destroy(struct mango_text_node *node) { +void mango_jump_label_node_destroy(struct mango_jump_label_node *node) { if (!node) return; @@ -135,7 +135,7 @@ void mango_text_node_destroy(struct mango_text_node *node) { free(node); } -void mango_text_node_set_background(struct mango_text_node *node, float r, +void mango_jump_label_node_set_background(struct mango_jump_label_node *node, float r, float g, float b, float a) { if (!node) return; @@ -145,7 +145,7 @@ void mango_text_node_set_background(struct mango_text_node *node, float r, node->bg_color[3] = a; } -void mango_text_node_set_border(struct mango_text_node *node, float r, float g, +void mango_jump_label_node_set_border(struct mango_jump_label_node *node, float r, float g, float b, float a, int32_t width, int32_t radius) { if (!node) @@ -158,7 +158,7 @@ void mango_text_node_set_border(struct mango_text_node *node, float r, float g, node->corner_radius = radius; } -void mango_text_node_set_padding(struct mango_text_node *node, int32_t pad_x, +void mango_jump_label_node_set_padding(struct mango_jump_label_node *node, int32_t pad_x, int32_t pad_y) { if (!node) return; @@ -166,7 +166,7 @@ void mango_text_node_set_padding(struct mango_text_node *node, int32_t pad_x, node->padding_y = pad_y >= 0 ? pad_y : 0; } -static void get_text_pixel_size(struct mango_text_node *node, const char *text, +static void get_text_pixel_size(struct mango_jump_label_node *node, const char *text, float scale, int32_t *out_w, int32_t *out_h) { if (node->measure_scale != scale) { pango_cairo_context_set_resolution(node->measure_context, 96.0 * scale); @@ -191,7 +191,7 @@ static void draw_rounded_rect(cairo_t *cr, double x, double y, double w, cairo_close_path(cr); } -void mango_text_node_update(struct mango_text_node *node, const char *text, +void mango_jump_label_node_update(struct mango_jump_label_node *node, const char *text, float scale) { if (!node || !text) return; @@ -405,20 +405,20 @@ void mango_text_node_update(struct mango_text_node *node, const char *text, node->logical_height); } -void mango_text_node_set_focus(struct mango_text_node *node, bool focused) { +void mango_jump_label_node_set_focus(struct mango_jump_label_node *node, bool focused) { if (!node || node->focused == focused) return; node->focused = focused; // 使用缓存的文本和缩放触发重绘(如果无文本则不重绘) if (node->cached_text && node->cached_scale > 0.0f) { - mango_text_node_update(node, node->cached_text, node->cached_scale); + mango_jump_label_node_update(node, node->cached_text, node->cached_scale); } } -struct mango_titlebar_node * -mango_titlebar_node_create(void *mango_node_data, struct wlr_scene_tree *parent, - TextDrawData data, int32_t width, int32_t height) { - struct mango_titlebar_node *node = calloc(1, sizeof(*node)); +struct mango_tab_bar_node * +mango_tab_bar_node_create(void *mango_node_data, struct wlr_scene_tree *parent, + DecorateDrawData data, int32_t width, int32_t height) { + struct mango_tab_bar_node *node = calloc(1, sizeof(*node)); if (!node) return NULL; @@ -462,7 +462,7 @@ mango_titlebar_node_create(void *mango_node_data, struct wlr_scene_tree *parent, return node; } -void mango_titlebar_node_destroy(struct mango_titlebar_node *node) { +void mango_tab_bar_node_destroy(struct mango_tab_bar_node *node) { if (!node) return; @@ -498,7 +498,7 @@ void mango_titlebar_node_destroy(struct mango_titlebar_node *node) { free(node); } -void mango_titlebar_node_set_size(struct mango_titlebar_node *node, +void mango_tab_bar_node_set_size(struct mango_tab_bar_node *node, int32_t width, int32_t height) { if (!node) return; @@ -517,10 +517,10 @@ void mango_titlebar_node_set_size(struct mango_titlebar_node *node, const char *redraw_text = node->last_text ? node->last_text : ""; float redraw_scale = node->last_scale > 0.0f ? node->last_scale : 1.0f; - mango_titlebar_node_update(node, redraw_text, redraw_scale); + mango_tab_bar_node_update(node, redraw_text, redraw_scale); } -void mango_titlebar_node_update(struct mango_titlebar_node *node, +void mango_tab_bar_node_update(struct mango_tab_bar_node *node, const char *text, float scale) { if (!node || !text) return; @@ -760,18 +760,18 @@ void mango_titlebar_node_update(struct mango_titlebar_node *node, node->logical_height); } -void mango_titlebar_node_set_focus(struct mango_titlebar_node *node, +void mango_tab_bar_node_set_focus(struct mango_tab_bar_node *node, bool focused) { if (!node || node->focused == focused) return; node->focused = focused; if (node->last_text) { float scale = node->last_scale > 0.0f ? node->last_scale : 1.0f; - mango_titlebar_node_update(node, node->last_text, scale); + mango_tab_bar_node_update(node, node->last_text, scale); } } -void mango_titlebar_node_set_colors(struct mango_titlebar_node *node, +void mango_tab_bar_node_set_colors(struct mango_tab_bar_node *node, const float fg[4], const float bg[4]) { if (!node) return; @@ -781,12 +781,12 @@ void mango_titlebar_node_set_colors(struct mango_titlebar_node *node, if (!node->focused && node->last_text) { float scale = node->last_scale > 0.0f ? node->last_scale : 1.0f; - mango_titlebar_node_update(node, node->last_text, scale); + mango_tab_bar_node_update(node, node->last_text, scale); } } -void mango_text_node_apply_config(struct mango_text_node *node, - const TextDrawData *data) { +void mango_jump_label_node_apply_config(struct mango_jump_label_node *node, + const DecorateDrawData *data) { if (!node || !data) return; @@ -807,12 +807,12 @@ void mango_text_node_apply_config(struct mango_text_node *node, g_strdup(data->font_desc ? data->font_desc : "monospace Bold 16"); if (node->cached_text && node->cached_scale > 0.0f) { - mango_text_node_update(node, node->cached_text, node->cached_scale); + mango_jump_label_node_update(node, node->cached_text, node->cached_scale); } } -void mango_titlebar_node_apply_config(struct mango_titlebar_node *node, - const TextDrawData *data) { +void mango_tab_bar_node_apply_config(struct mango_tab_bar_node *node, + const DecorateDrawData *data) { if (!node || !data) return; @@ -834,6 +834,6 @@ void mango_titlebar_node_apply_config(struct mango_titlebar_node *node, if (node->last_text) { float scale = node->last_scale > 0.0f ? node->last_scale : 1.0f; - mango_titlebar_node_update(node, node->last_text, scale); + mango_tab_bar_node_update(node, node->last_text, scale); } } \ No newline at end of file diff --git a/src/draw/text-node.h b/src/draw/text-node.h index 32b937a1..ae9ac604 100644 --- a/src/draw/text-node.h +++ b/src/draw/text-node.h @@ -1,5 +1,5 @@ -#ifndef TEXT_NODE_H -#define TEXT_NODE_H +#ifndef jump_label_node_H +#define jump_label_node_H #include #include @@ -20,14 +20,14 @@ typedef struct { int32_t padding_x; int32_t padding_y; const char *font_desc; -} TextDrawData; +} DecorateDrawData; struct mango_text_buffer { struct wlr_buffer base; cairo_surface_t *surface; }; -struct mango_text_node { +struct mango_jump_label_node { struct wlr_scene_buffer *scene_buffer; struct mango_text_buffer *buffer; cairo_surface_t *surface; @@ -72,7 +72,7 @@ struct mango_text_node { int32_t logical_height; }; -struct mango_titlebar_node { +struct mango_tab_bar_node { struct wlr_scene_buffer *scene_buffer; struct mango_text_buffer *buffer; cairo_surface_t *surface; @@ -129,36 +129,36 @@ struct mango_titlebar_node { }; void mango_text_global_finish(void); -struct mango_text_node *mango_text_node_create(struct wlr_scene_tree *parent, - TextDrawData data); -void mango_text_node_destroy(struct mango_text_node *node); -void mango_text_node_set_background(struct mango_text_node *node, float r, +struct mango_jump_label_node *mango_jump_label_node_create(struct wlr_scene_tree *parent, + DecorateDrawData data); +void mango_jump_label_node_destroy(struct mango_jump_label_node *node); +void mango_jump_label_node_set_background(struct mango_jump_label_node *node, float r, float g, float b, float a); -void mango_text_node_set_border(struct mango_text_node *node, float r, float g, +void mango_jump_label_node_set_border(struct mango_jump_label_node *node, float r, float g, float b, float a, int32_t width, int32_t radius); -void mango_text_node_set_padding(struct mango_text_node *node, int32_t pad_x, +void mango_jump_label_node_set_padding(struct mango_jump_label_node *node, int32_t pad_x, int32_t pad_y); -void mango_text_node_update(struct mango_text_node *node, const char *text, +void mango_jump_label_node_update(struct mango_jump_label_node *node, const char *text, float scale); -struct mango_titlebar_node * -mango_titlebar_node_create(void *mango_node_data, struct wlr_scene_tree *parent, - TextDrawData data, int32_t width, int32_t height); -void mango_titlebar_node_destroy(struct mango_titlebar_node *node); -void mango_titlebar_node_set_size(struct mango_titlebar_node *node, +struct mango_tab_bar_node * +mango_tab_bar_node_create(void *mango_node_data, struct wlr_scene_tree *parent, + DecorateDrawData data, int32_t width, int32_t height); +void mango_tab_bar_node_destroy(struct mango_tab_bar_node *node); +void mango_tab_bar_node_set_size(struct mango_tab_bar_node *node, int32_t width, int32_t height); -void mango_titlebar_node_update(struct mango_titlebar_node *node, +void mango_tab_bar_node_update(struct mango_tab_bar_node *node, const char *text, float scale); -void mango_text_node_set_focus(struct mango_text_node *node, bool focused); -void mango_titlebar_node_set_focus(struct mango_titlebar_node *node, +void mango_jump_label_node_set_focus(struct mango_jump_label_node *node, bool focused); +void mango_tab_bar_node_set_focus(struct mango_tab_bar_node *node, bool focused); -void mango_titlebar_node_set_colors(struct mango_titlebar_node *node, +void mango_tab_bar_node_set_colors(struct mango_tab_bar_node *node, const float fg[4], const float bg[4]); -void mango_text_node_apply_config(struct mango_text_node *node, - const TextDrawData *data); -void mango_titlebar_node_apply_config(struct mango_titlebar_node *node, - const TextDrawData *data); -#endif // TEXT_NODE_H \ No newline at end of file +void mango_jump_label_node_apply_config(struct mango_jump_label_node *node, + const DecorateDrawData *data); +void mango_tab_bar_node_apply_config(struct mango_tab_bar_node *node, + const DecorateDrawData *data); +#endif // jump_label_node_H \ No newline at end of file diff --git a/src/layout/arrange.h b/src/layout/arrange.h index f1c4967a..4782b3ea 100644 --- a/src/layout/arrange.h +++ b/src/layout/arrange.h @@ -43,7 +43,7 @@ void monocle_set_focus(Client *c, bool focused) { return; c->is_monocle_hide = !focused; - mango_titlebar_node_set_focus(c->titlebar_node, focused); + mango_tab_bar_node_set_focus(c->tab_bar_node, focused); wlr_scene_node_set_enabled(&c->scene->node, focused); if (!focused) { @@ -1143,17 +1143,17 @@ 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->is_jump_mode && !c->jump_label_node) { + client_add_jump_label_node(c); } if (m->pertag->ltidxs[m->pertag->curtag]->id == MONOCLE && - !c->titlebar_node) { - client_add_titlebar_node(c); + !c->tab_bar_node) { + client_add_tab_bar_node(c); } - if (c->titlebar_node && c->mon == m) { - wlr_scene_node_set_enabled(&c->titlebar_node->scene_buffer->node, + if (c->tab_bar_node && c->mon == m) { + wlr_scene_node_set_enabled(&c->tab_bar_node->scene_buffer->node, false); } diff --git a/src/layout/overview.h b/src/layout/overview.h index 32a9a18d..b259fceb 100644 --- a/src/layout/overview.h +++ b/src/layout/overview.h @@ -368,13 +368,13 @@ void create_jump_hints(Monitor *m) { // 把字符变成字符串 char label_text[2] = {c_char, '\0'}; - mango_text_node_update(c->text_node, label_text, 1.0f); - wlr_scene_node_set_enabled(&c->text_node->scene_buffer->node, true); - wlr_scene_node_raise_to_top(&c->text_node->scene_buffer->node); + mango_jump_label_node_update(c->jump_label_node, label_text, 1.0f); + wlr_scene_node_set_enabled(&c->jump_label_node->scene_buffer->node, true); + wlr_scene_node_raise_to_top(&c->jump_label_node->scene_buffer->node); wlr_scene_node_set_position( - &c->text_node->scene_buffer->node, - c->geom.width / 2 - c->text_node->logical_width / 2, - c->geom.height / 2 - c->text_node->logical_height / 2); + &c->jump_label_node->scene_buffer->node, + c->geom.width / 2 - c->jump_label_node->logical_width / 2, + c->geom.height / 2 - c->jump_label_node->logical_height / 2); label_idx++; } } @@ -391,9 +391,9 @@ void finish_jump_mode(Monitor *m) { wl_list_for_each(c, &clients, link) { if (VISIBLEON(c, m)) { - if (c->text_node->scene_buffer->node.enabled) { + if (c->jump_label_node->scene_buffer->node.enabled) { c->jump_char = '\0'; - wlr_scene_node_set_enabled(&c->text_node->scene_buffer->node, + wlr_scene_node_set_enabled(&c->jump_label_node->scene_buffer->node, false); } } diff --git a/src/mango.c b/src/mango.c index bbdf5779..4b865bb4 100644 --- a/src/mango.c +++ b/src/mango.c @@ -179,7 +179,7 @@ enum { NUM_LAYERS }; /* scene layers */ -enum mango_node_type { MANGO_TITLE_NODE, MANGO_TEXT_NODE }; +enum mango_node_type { MANGO_TITLE_NODE, MANGO_jump_label_node }; #ifdef XWAYLAND enum { @@ -337,8 +337,8 @@ struct Client { struct wlr_scene_shadow *shadow; struct wlr_scene_tree *scene_surface; struct wlr_scene_tree *overview_scene_surface; - struct mango_text_node *text_node; - struct mango_titlebar_node *titlebar_node; + struct mango_jump_label_node *jump_label_node; + struct mango_tab_bar_node *tab_bar_node; struct wl_list link; struct wl_list flink; struct wl_list fadeout_link; @@ -1274,8 +1274,8 @@ void swallow(Client *c, Client *w) { overview_backup_surface(c); } - if (w->titlebar_node) { - wlr_scene_node_set_enabled(&w->titlebar_node->scene_buffer->node, + if (w->tab_bar_node) { + wlr_scene_node_set_enabled(&w->tab_bar_node->scene_buffer->node, false); } @@ -6570,8 +6570,8 @@ void unmapnotify(struct wl_listener *listener, void *data) { c->stack_proportion = 0.0f; - mango_text_node_destroy(c->text_node); - mango_titlebar_node_destroy(c->titlebar_node); + mango_jump_label_node_destroy(c->jump_label_node); + mango_tab_bar_node_destroy(c->tab_bar_node); wlr_scene_node_destroy(&c->scene->node); printstatus(IPC_WATCH_ARRANGGE); motionnotify(0, NULL, 0, 0, 0, 0); @@ -6724,7 +6724,7 @@ void updatetitle(struct wl_listener *listener, void *data) { const char *title; title = client_get_title(c); - mango_titlebar_node_update(c->titlebar_node, title, 1.0); + mango_tab_bar_node_update(c->tab_bar_node, title, 1.0); if (title && c->foreign_toplevel) wlr_foreign_toplevel_handle_v1_set_title(c->foreign_toplevel, title); if (c == focustop(c->mon))