opt: optmize structruing\

This commit is contained in:
DreamMaoMao 2026-06-22 14:18:56 +08:00
parent afd7135fa6
commit b8ca3a3c34
11 changed files with 234 additions and 239 deletions

View file

@ -69,17 +69,17 @@ You can also color-code windows based on their state:
### Tab Bar For Monocle Layout ### Tab Bar For Monocle Layout
| Setting | Default | Description | | Setting | Default | Description |
| :--- | :--- | :--- | | :--- | :--- | :--- |
| `tab_bar_height` | `50` | Height of the tab bar for monocle layout. | | `group_bar_height` | `50` | Height of the tab bar for monocle layout. |
| `tab_bar_decorate_fg_color` | `0xc4939dff` | text color. | `group_bar_decorate_fg_color` | `0xc4939dff` | text color.
| `tab_bar_decorate_bg_color` | `0x201b14ff` | background color.| | `group_bar_decorate_bg_color` | `0x201b14ff` | background color.|
| `tab_bar_decorate_focus_fg_color` | `0x201b14ff` | text color for focus. | | `group_bar_decorate_focus_fg_color` | `0x201b14ff` | text color for focus. |
| `tab_bar_decorate_focus_bg_color` | `0xc4939dff` | background color for focus.| | `group_bar_decorate_focus_bg_color` | `0xc4939dff` | background color for focus.|
| `tab_bar_decorate_border_color` | `0x8BAA9Bff` | border color.| | `group_bar_decorate_border_color` | `0x8BAA9Bff` | border color.|
| `tab_bar_decorate_border_width` | `4` | border width.| | `group_bar_decorate_border_width` | `4` | border width.|
| `tab_bar_decorate_corner_radius` | `5` | corner radius.| | `group_bar_decorate_corner_radius` | `5` | corner radius.|
| `tab_bar_decorate_padding_x` | `0` | horizontal padding.| | `group_bar_decorate_padding_x` | `0` | horizontal padding.|
| `tab_bar_decorate_padding_y` | `0` | vertical padding.| | `group_bar_decorate_padding_y` | `0` | vertical padding.|
| `tab_bar_decorate_font_desc` | `monospace Bold 16` | font set.| | `group_bar_decorate_font_desc` | `monospace Bold 16` | font set.|
## Borders ## Borders

View file

@ -57,14 +57,14 @@ void client_tile_resize(Client *c, struct wlr_box geo, int32_t interact) {
if (!ISFAKETILED(c)) if (!ISFAKETILED(c))
return; return;
if (c->isfullscreen && c->tab_bar_node) { if (c->isfullscreen && c->group_bar) {
wlr_scene_node_set_enabled(&c->tab_bar_node->scene_buffer->node, false); wlr_scene_node_set_enabled(&c->group_bar->scene_buffer->node, false);
} }
if (!c->mon->isoverview && c->tab_bar_node && !c->isfullscreen && if (!c->mon->isoverview && c->group_bar && !c->isfullscreen &&
(c->group_next || c->group_prev)) { (c->group_next || c->group_prev)) {
geo.y = geo.y + config.tab_bar_height; geo.y = geo.y + config.group_bar_height;
geo.height -= config.tab_bar_height; geo.height -= config.group_bar_height;
} }
if ((!c->isfullscreen && !c->ismaximizescreen) || if ((!c->isfullscreen && !c->ismaximizescreen) ||
@ -115,27 +115,22 @@ void client_add_jump_label_node(Client *c) {
wlr_scene_node_set_enabled(&c->jump_label_node->scene_buffer->node, false); wlr_scene_node_set_enabled(&c->jump_label_node->scene_buffer->node, false);
} }
void client_add_tab_bar_node(Client *c) { void client_add_group_bar(Client *c) {
if (config.tab_bar_height <= 0) { if (config.group_bar_height <= 0) {
return; return;
} }
MangoCustomDecorate *MangoCustomDecorate =
ecalloc(1, sizeof(MangoCustomDecorate));
MangoCustomDecorate->node_data = c;
MangoCustomDecorate->node_type = MANGO_TITLE_NODE;
MangoCustomDecorate->type = CustomDecorate;
uint32_t layer = c->isoverlay ? LyrOverlay uint32_t layer = c->isoverlay ? LyrOverlay
: c->isfloating || c->isfullscreen ? LyrTop : c->isfloating || c->isfullscreen ? LyrTop
: c->ismaximizescreen ? LyrMaximize : c->ismaximizescreen ? LyrMaximize
: LyrTile; : LyrTile;
c->tab_bar_node = mango_tab_bar_node_create( c->group_bar = mango_group_bar_create(c, GroupBar, layers[layer],
MangoCustomDecorate, layers[layer], config.tabdata, 0, 0); config.tabdata, 0, 0);
wlr_scene_node_lower_to_bottom(&c->tab_bar_node->scene_buffer->node); wlr_scene_node_lower_to_bottom(&c->group_bar->scene_buffer->node);
wlr_scene_node_set_enabled(&c->tab_bar_node->scene_buffer->node, false); wlr_scene_node_set_enabled(&c->group_bar->scene_buffer->node, false);
mango_tab_bar_node_update(c->tab_bar_node, client_get_title(c), 1.0); mango_group_bar_update(c->group_bar, client_get_title(c), 1.0);
} }
void client_focus_group_member(Client *c) { void client_focus_group_member(Client *c) {
@ -165,11 +160,11 @@ void client_focus_group_member(Client *c) {
cur_focusing->isgroupfocusing = false; cur_focusing->isgroupfocusing = false;
c->mon = cur_focusing->mon; c->mon = cur_focusing->mon;
client_replace(c, cur_focusing, true); client_replace(c, cur_focusing, true);
mango_tab_bar_node_set_focus(cur_focusing->tab_bar_node, false); mango_group_bar_set_focus(cur_focusing->group_bar, false);
} }
c->isgroupfocusing = true; c->isgroupfocusing = true;
mango_tab_bar_node_set_focus(c->tab_bar_node, true); mango_group_bar_set_focus(c->group_bar, true);
client_reparent_group(c); client_reparent_group(c);
@ -189,14 +184,14 @@ void client_check_tab_node_visible(Client *c) {
Client *cur = head; Client *cur = head;
while (cur) { while (cur) {
if (!c->mon->isoverview && cur->tab_bar_node && if (!c->mon->isoverview && cur->group_bar &&
(cur->group_next || cur->group_prev) && VISIBLEON(c, c->mon) && (cur->group_next || cur->group_prev) && VISIBLEON(c, c->mon) &&
ISNORMAL(c) && !c->isfullscreen && ISNORMAL(c) && !c->isfullscreen &&
(!is_monocle_layout(c->mon) || c == c->mon->sel)) { (!is_monocle_layout(c->mon) || c == c->mon->sel)) {
wlr_scene_node_set_enabled(&cur->tab_bar_node->scene_buffer->node, wlr_scene_node_set_enabled(&cur->group_bar->scene_buffer->node,
true); true);
} else { } else {
wlr_scene_node_set_enabled(&cur->tab_bar_node->scene_buffer->node, wlr_scene_node_set_enabled(&cur->group_bar->scene_buffer->node,
false); false);
} }
cur = cur->group_next; cur = cur->group_next;
@ -216,8 +211,8 @@ void client_raise_group(Client *c) {
Client *cur = head; Client *cur = head;
while (cur) { while (cur) {
if (cur->tab_bar_node) { if (cur->group_bar) {
wlr_scene_node_raise_to_top(&cur->tab_bar_node->scene_buffer->node); wlr_scene_node_raise_to_top(&cur->group_bar->scene_buffer->node);
wlr_scene_node_raise_to_top(&cur->scene->node); wlr_scene_node_raise_to_top(&cur->scene->node);
} }
cur = cur->group_next; cur = cur->group_next;
@ -225,7 +220,7 @@ void client_raise_group(Client *c) {
} }
void client_reparent_group(Client *c) { void client_reparent_group(Client *c) {
if (!c || !c->tab_bar_node) if (!c || !c->group_bar)
return; return;
if (!c->group_prev && !c->group_next) if (!c->group_prev && !c->group_next)
@ -242,8 +237,8 @@ void client_reparent_group(Client *c) {
Client *cur = head; Client *cur = head;
while (cur) { while (cur) {
if (cur->tab_bar_node) { if (cur->group_bar) {
wlr_scene_node_reparent(&cur->tab_bar_node->scene_buffer->node, wlr_scene_node_reparent(&cur->group_bar->scene_buffer->node,
layers[layer]); layers[layer]);
wlr_scene_node_reparent(&cur->scene->node, layers[layer]); wlr_scene_node_reparent(&cur->scene->node, layers[layer]);
} }
@ -251,13 +246,13 @@ void client_reparent_group(Client *c) {
} }
} }
void client_handle_decorate_click(MangoCustomDecorate *md) { void client_handle_decorate_click(MangoGroupBar *gb) {
if (!md) if (!gb)
return; return;
if (md->node_type == MANGO_TITLE_NODE) { if (gb->node_data) {
Client *c = md->node_data; Client *c = gb->node_data;
client_focus_group_member(c); client_focus_group_member(c);
} }
} }

View file

@ -414,12 +414,12 @@ void client_draw_shadow(Client *c) {
void client_draw_title(Client *c) { void client_draw_title(Client *c) {
if (!c || !c->tab_bar_node) if (!c || !c->group_bar)
return; return;
if (!c->group_next && !c->group_prev && c->tab_bar_node && if (!c->group_next && !c->group_prev && c->group_bar &&
c->tab_bar_node->scene_buffer->node.enabled) { c->group_bar->scene_buffer->node.enabled) {
wlr_scene_node_set_enabled(&c->tab_bar_node->scene_buffer->node, false); wlr_scene_node_set_enabled(&c->group_bar->scene_buffer->node, false);
return; return;
} }
@ -438,21 +438,21 @@ void client_draw_title(Client *c) {
} }
int32_t tab_x = c->animation.current.x; int32_t tab_x = c->animation.current.x;
int32_t tab_y = c->animation.current.y - config.tab_bar_height; int32_t tab_y = c->animation.current.y - config.group_bar_height;
int32_t tw = c->animation.current.width; int32_t tw = c->animation.current.width;
int32_t th = config.tab_bar_height; int32_t th = config.group_bar_height;
int32_t left_over = c->mon->m.x - tab_x; int32_t left_over = c->mon->m.x - tab_x;
int32_t right_over = tab_x + tw - c->mon->m.x - c->mon->m.width; int32_t right_over = tab_x + tw - c->mon->m.x - c->mon->m.width;
int32_t top_over = c->mon->m.y - tab_y; int32_t top_over = c->mon->m.y - tab_y;
int32_t bottom_over = int32_t bottom_over =
tab_y + config.tab_bar_height - c->mon->m.y - c->mon->m.height; tab_y + config.group_bar_height - c->mon->m.y - c->mon->m.height;
if (c != grabc && if (c != grabc &&
(ISSCROLLTILED(c) || c->animation.tagining || c->animation.tagouting)) { (ISSCROLLTILED(c) || c->animation.tagining || c->animation.tagouting)) {
if (top_over > 0) { if (top_over > 0) {
tab_y = c->mon->m.y; tab_y = c->mon->m.y;
th = config.tab_bar_height - top_over; th = config.group_bar_height - top_over;
} }
if (bottom_over > 0) { if (bottom_over > 0) {
th = th - bottom_over; th = th - bottom_over;
@ -469,9 +469,9 @@ void client_draw_title(Client *c) {
if (tw <= 0 || th <= 0) { if (tw <= 0 || th <= 0) {
cur = head; cur = head;
while (cur) { while (cur) {
if (cur->tab_bar_node) if (cur->group_bar)
wlr_scene_node_set_enabled( wlr_scene_node_set_enabled(&cur->group_bar->scene_buffer->node,
&cur->tab_bar_node->scene_buffer->node, false); false);
cur = cur->group_next; cur = cur->group_next;
} }
return; return;
@ -486,7 +486,7 @@ void client_draw_title(Client *c) {
for (int i = 0; i < count && cur; i++) { for (int i = 0; i < count && cur; i++) {
int32_t w = bar_w + (i < rem ? 1 : 0); int32_t w = bar_w + (i < rem ? 1 : 0);
global_draw_tab_bar(cur, x, tab_y, w, th); global_draw_group_bar(cur, x, tab_y, w, th);
x += w; x += w;
cur = cur->group_next; cur = cur->group_next;
} }
@ -532,17 +532,17 @@ void client_draw_blur(Client *c, struct wlr_box clip_box, struct ivec2 offset) {
} }
} }
void global_draw_tab_bar(Client *c, int32_t x, int32_t y, int32_t width, void global_draw_group_bar(Client *c, int32_t x, int32_t y, int32_t width,
int32_t height) { int32_t height) {
if (!c->tab_bar_node) if (!c->group_bar)
return; return;
if (height <= 0) { if (height <= 0) {
wlr_scene_node_set_enabled(&c->tab_bar_node->scene_buffer->node, false); wlr_scene_node_set_enabled(&c->group_bar->scene_buffer->node, false);
} }
wlr_scene_node_set_position(&c->tab_bar_node->scene_buffer->node, x, y); wlr_scene_node_set_position(&c->group_bar->scene_buffer->node, x, y);
mango_tab_bar_node_set_size(c->tab_bar_node, width, height); mango_group_bar_set_size(c->group_bar, width, height);
} }
void apply_split_border(Client *c, bool hit_no_border) { void apply_split_border(Client *c, bool hit_no_border) {

View file

@ -333,7 +333,7 @@ typedef struct {
uint32_t gappoh; uint32_t gappoh;
uint32_t gappov; uint32_t gappov;
uint32_t borderpx; uint32_t borderpx;
uint32_t tab_bar_height; uint32_t group_bar_height;
float scratchpad_width_ratio; float scratchpad_width_ratio;
float scratchpad_height_ratio; float scratchpad_height_ratio;
float rootcolor[4]; float rootcolor[4];
@ -1774,75 +1774,75 @@ bool parse_option(Config *config, char *key, char *value) {
config->cursor_size = atoi(value); config->cursor_size = atoi(value);
} else if (strcmp(key, "cursor_theme") == 0) { } else if (strcmp(key, "cursor_theme") == 0) {
config->cursor_theme = strdup(value); config->cursor_theme = strdup(value);
} else if (strcmp(key, "tab_bar_decorate_font_desc") == 0) { } else if (strcmp(key, "group_bar_decorate_font_desc") == 0) {
config->tabdata.font_desc = strdup(value); config->tabdata.font_desc = strdup(value);
} else if (strcmp(key, "tab_bar_decorate_fg_color") == 0) { } else if (strcmp(key, "group_bar_decorate_fg_color") == 0) {
int64_t color = parse_color(value); int64_t color = parse_color(value);
if (color == -1) { if (color == -1) {
fprintf(stderr, fprintf(stderr,
"\033[1m\033[31m[ERROR]:\033[33m Invalid " "\033[1m\033[31m[ERROR]:\033[33m Invalid "
"tab_bar_decorate_fg_color " "group_bar_decorate_fg_color "
"format: %s\n", "format: %s\n",
value); value);
return false; return false;
} else { } else {
convert_hex_to_rgba(config->tabdata.fg_color, color); convert_hex_to_rgba(config->tabdata.fg_color, color);
} }
} else if (strcmp(key, "tab_bar_decorate_bg_color") == 0) { } else if (strcmp(key, "group_bar_decorate_bg_color") == 0) {
int64_t color = parse_color(value); int64_t color = parse_color(value);
if (color == -1) { if (color == -1) {
fprintf(stderr, fprintf(stderr,
"\033[1m\033[31m[ERROR]:\033[33m Invalid " "\033[1m\033[31m[ERROR]:\033[33m Invalid "
"tab_bar_decorate_bg_color " "group_bar_decorate_bg_color "
"format: %s\n", "format: %s\n",
value); value);
return false; return false;
} else { } else {
convert_hex_to_rgba(config->tabdata.bg_color, color); convert_hex_to_rgba(config->tabdata.bg_color, color);
} }
} else if (strcmp(key, "tab_bar_decorate_focus_fg_color") == 0) { } else if (strcmp(key, "group_bar_decorate_focus_fg_color") == 0) {
int64_t color = parse_color(value); int64_t color = parse_color(value);
if (color == -1) { if (color == -1) {
fprintf(stderr, fprintf(stderr,
"\033[1m\033[31m[ERROR]:\033[33m Invalid " "\033[1m\033[31m[ERROR]:\033[33m Invalid "
"tab_bar_decorate_focus_fg_color " "group_bar_decorate_focus_fg_color "
"format: %s\n", "format: %s\n",
value); value);
return false; return false;
} else { } else {
convert_hex_to_rgba(config->tabdata.focus_fg_color, color); convert_hex_to_rgba(config->tabdata.focus_fg_color, color);
} }
} else if (strcmp(key, "tab_bar_decorate_focus_bg_color") == 0) { } else if (strcmp(key, "group_bar_decorate_focus_bg_color") == 0) {
int64_t color = parse_color(value); int64_t color = parse_color(value);
if (color == -1) { if (color == -1) {
fprintf(stderr, fprintf(stderr,
"\033[1m\033[31m[ERROR]:\033[33m Invalid " "\033[1m\033[31m[ERROR]:\033[33m Invalid "
"tab_bar_decorate_focus_bg_color " "group_bar_decorate_focus_bg_color "
"format: %s\n", "format: %s\n",
value); value);
return false; return false;
} else { } else {
convert_hex_to_rgba(config->tabdata.focus_bg_color, color); convert_hex_to_rgba(config->tabdata.focus_bg_color, color);
} }
} else if (strcmp(key, "tab_bar_decorate_border_color") == 0) { } else if (strcmp(key, "group_bar_decorate_border_color") == 0) {
int64_t color = parse_color(value); int64_t color = parse_color(value);
if (color == -1) { if (color == -1) {
fprintf(stderr, fprintf(stderr,
"\033[1m\033[31m[ERROR]:\033[33m Invalid " "\033[1m\033[31m[ERROR]:\033[33m Invalid "
"tab_bar_decorate_border_color " "group_bar_decorate_border_color "
"format: %s\n", "format: %s\n",
value); value);
return false; return false;
} else { } else {
convert_hex_to_rgba(config->tabdata.border_color, color); convert_hex_to_rgba(config->tabdata.border_color, color);
} }
} else if (strcmp(key, "tab_bar_decorate_border_width") == 0) { } else if (strcmp(key, "group_bar_decorate_border_width") == 0) {
config->tabdata.border_width = CLAMP_INT(atoi(value), 0, 100); config->tabdata.border_width = CLAMP_INT(atoi(value), 0, 100);
} else if (strcmp(key, "tab_bar_decorate_corner_radius") == 0) { } else if (strcmp(key, "group_bar_decorate_corner_radius") == 0) {
config->tabdata.corner_radius = CLAMP_INT(atoi(value), 0, 100); config->tabdata.corner_radius = CLAMP_INT(atoi(value), 0, 100);
} else if (strcmp(key, "tab_bar_decorate_padding_x") == 0) { } else if (strcmp(key, "group_bar_decorate_padding_x") == 0) {
config->tabdata.padding_x = CLAMP_INT(atoi(value), 0, 100); config->tabdata.padding_x = CLAMP_INT(atoi(value), 0, 100);
} else if (strcmp(key, "tab_bar_decorate_padding_y") == 0) { } else if (strcmp(key, "group_bar_decorate_padding_y") == 0) {
config->tabdata.padding_y = CLAMP_INT(atoi(value), 0, 100); config->tabdata.padding_y = CLAMP_INT(atoi(value), 0, 100);
} else if (strcmp(key, "jump_label_decorate_font_desc") == 0) { } else if (strcmp(key, "jump_label_decorate_font_desc") == 0) {
config->jumplabeldata.font_desc = strdup(value); config->jumplabeldata.font_desc = strdup(value);
@ -1960,8 +1960,8 @@ bool parse_option(Config *config, char *key, char *value) {
config->scratchpad_height_ratio = atof(value); config->scratchpad_height_ratio = atof(value);
} else if (strcmp(key, "borderpx") == 0) { } else if (strcmp(key, "borderpx") == 0) {
config->borderpx = atoi(value); config->borderpx = atoi(value);
} else if (strcmp(key, "tab_bar_height") == 0) { } else if (strcmp(key, "group_bar_height") == 0) {
config->tab_bar_height = atoi(value); config->group_bar_height = atoi(value);
} else if (strcmp(key, "rootcolor") == 0) { } else if (strcmp(key, "rootcolor") == 0) {
int64_t color = parse_color(value); int64_t color = parse_color(value);
if (color == -1) { if (color == -1) {
@ -3581,7 +3581,7 @@ void override_config(void) {
config.scratchpad_height_ratio = config.scratchpad_height_ratio =
CLAMP_FLOAT(config.scratchpad_height_ratio, 0.1f, 1.0f); CLAMP_FLOAT(config.scratchpad_height_ratio, 0.1f, 1.0f);
config.borderpx = CLAMP_INT(config.borderpx, 0, 200); config.borderpx = CLAMP_INT(config.borderpx, 0, 200);
config.tab_bar_height = CLAMP_INT(config.tab_bar_height, 0, 500); config.group_bar_height = CLAMP_INT(config.group_bar_height, 0, 500);
config.smartgaps = CLAMP_INT(config.smartgaps, 0, 1); config.smartgaps = CLAMP_INT(config.smartgaps, 0, 1);
config.blur = CLAMP_INT(config.blur, 0, 1); config.blur = CLAMP_INT(config.blur, 0, 1);
config.blur_layer = CLAMP_INT(config.blur_layer, 0, 1); config.blur_layer = CLAMP_INT(config.blur_layer, 0, 1);
@ -3713,7 +3713,7 @@ void set_value_default() {
config.idleinhibit_ignore_visible = 0; config.idleinhibit_ignore_visible = 0;
config.borderpx = 4; config.borderpx = 4;
config.tab_bar_height = 50; config.group_bar_height = 50;
config.overviewgappi = 5; config.overviewgappi = 5;
config.overviewgappo = 30; config.overviewgappo = 30;
config.cursor_hide_timeout = 0; config.cursor_hide_timeout = 0;
@ -4130,7 +4130,7 @@ void reapply_property(void) {
mango_jump_label_node_apply_config(c->jump_label_node, mango_jump_label_node_apply_config(c->jump_label_node,
&config.jumplabeldata); &config.jumplabeldata);
mango_tab_bar_node_apply_config(c->tab_bar_node, &config.tabdata); mango_group_bar_apply_config(c->group_bar, &config.tabdata);
wlr_scene_rect_set_color(c->droparea, config.dropcolor); wlr_scene_rect_set_color(c->droparea, config.dropcolor);
wlr_scene_rect_set_color(c->splitindicator[0], config.splitcolor); wlr_scene_rect_set_color(c->splitindicator[0], config.splitcolor);

View file

@ -59,10 +59,9 @@ static const struct wlr_buffer_impl text_buffer_impl = {
.end_data_ptr_access = text_buffer_end_data_ptr_access, .end_data_ptr_access = text_buffer_end_data_ptr_access,
}; };
struct mango_jump_label_node * MangoJumpLabel *mango_jump_label_node_create(struct wlr_scene_tree *parent,
mango_jump_label_node_create(struct wlr_scene_tree *parent, DecorateDrawData data) {
DecorateDrawData data) { MangoJumpLabel *node = calloc(1, sizeof(*node));
struct mango_jump_label_node *node = calloc(1, sizeof(*node));
if (!node) if (!node)
return NULL; return NULL;
@ -104,7 +103,7 @@ mango_jump_label_node_create(struct wlr_scene_tree *parent,
return node; return node;
} }
void mango_jump_label_node_destroy(struct mango_jump_label_node *node) { void mango_jump_label_node_destroy(MangoJumpLabel *node) {
if (!node) if (!node)
return; return;
@ -136,8 +135,8 @@ void mango_jump_label_node_destroy(struct mango_jump_label_node *node) {
free(node); free(node);
} }
void mango_jump_label_node_set_background(struct mango_jump_label_node *node, void mango_jump_label_node_set_background(MangoJumpLabel *node, float r,
float r, float g, float b, float a) { float g, float b, float a) {
if (!node) if (!node)
return; return;
node->bg_color[0] = r; node->bg_color[0] = r;
@ -146,9 +145,9 @@ void mango_jump_label_node_set_background(struct mango_jump_label_node *node,
node->bg_color[3] = a; node->bg_color[3] = a;
} }
void mango_jump_label_node_set_border(struct mango_jump_label_node *node, void mango_jump_label_node_set_border(MangoJumpLabel *node, float r, float g,
float r, float g, float b, float a, float b, float a, int32_t width,
int32_t width, int32_t radius) { int32_t radius) {
if (!node) if (!node)
return; return;
node->border_color[0] = r; node->border_color[0] = r;
@ -159,17 +158,16 @@ void mango_jump_label_node_set_border(struct mango_jump_label_node *node,
node->corner_radius = radius; node->corner_radius = radius;
} }
void mango_jump_label_node_set_padding(struct mango_jump_label_node *node, void mango_jump_label_node_set_padding(MangoJumpLabel *node, int32_t pad_x,
int32_t pad_x, int32_t pad_y) { int32_t pad_y) {
if (!node) if (!node)
return; return;
node->padding_x = pad_x >= 0 ? pad_x : 0; node->padding_x = pad_x >= 0 ? pad_x : 0;
node->padding_y = pad_y >= 0 ? pad_y : 0; node->padding_y = pad_y >= 0 ? pad_y : 0;
} }
static void get_text_pixel_size(struct mango_jump_label_node *node, static void get_text_pixel_size(MangoJumpLabel *node, const char *text,
const char *text, float scale, int32_t *out_w, float scale, int32_t *out_w, int32_t *out_h) {
int32_t *out_h) {
if (node->measure_scale != scale) { if (node->measure_scale != scale) {
pango_cairo_context_set_resolution(node->measure_context, 96.0 * scale); pango_cairo_context_set_resolution(node->measure_context, 96.0 * scale);
node->measure_scale = scale; node->measure_scale = scale;
@ -193,8 +191,8 @@ static void draw_rounded_rect(cairo_t *cr, double x, double y, double w,
cairo_close_path(cr); cairo_close_path(cr);
} }
void mango_jump_label_node_update(struct mango_jump_label_node *node, void mango_jump_label_node_update(MangoJumpLabel *node, const char *text,
const char *text, float scale) { float scale) {
if (!node || !text) if (!node || !text)
return; return;
if (scale <= 0.0f) if (scale <= 0.0f)
@ -407,8 +405,7 @@ void mango_jump_label_node_update(struct mango_jump_label_node *node,
node->logical_height); node->logical_height);
} }
void mango_jump_label_node_set_focus(struct mango_jump_label_node *node, void mango_jump_label_node_set_focus(MangoJumpLabel *node, bool focused) {
bool focused) {
if (!node || node->focused == focused) if (!node || node->focused == focused)
return; return;
node->focused = focused; node->focused = focused;
@ -419,55 +416,61 @@ void mango_jump_label_node_set_focus(struct mango_jump_label_node *node,
} }
} }
struct mango_tab_bar_node * MangoGroupBar *mango_group_bar_create(void *cdata, uint32_t type,
mango_tab_bar_node_create(void *mango_node_data, struct wlr_scene_tree *parent, struct wlr_scene_tree *parent,
DecorateDrawData data, int32_t width, DecorateDrawData data, int32_t width,
int32_t height) { int32_t height) {
struct mango_tab_bar_node *node = calloc(1, sizeof(*node)); MangoGroupBar *mangobar = calloc(1, sizeof(*mangobar));
if (!node) if (!mangobar)
return NULL; return NULL;
node->scene_buffer = wlr_scene_buffer_create(parent, NULL); mangobar->scene_buffer = wlr_scene_buffer_create(parent, NULL);
if (!node->scene_buffer) { if (!mangobar->scene_buffer) {
free(node); free(mangobar);
return NULL; return NULL;
} }
memcpy(node->fg_color, data.fg_color, sizeof(node->fg_color)); memcpy(mangobar->fg_color, data.fg_color, sizeof(mangobar->fg_color));
memcpy(node->bg_color, data.bg_color, sizeof(node->bg_color)); memcpy(mangobar->bg_color, data.bg_color, sizeof(mangobar->bg_color));
memcpy(node->focus_fg_color, data.focus_fg_color, memcpy(mangobar->focus_fg_color, data.focus_fg_color,
sizeof(node->focus_fg_color)); sizeof(mangobar->focus_fg_color));
memcpy(node->focus_bg_color, data.focus_bg_color, memcpy(mangobar->focus_bg_color, data.focus_bg_color,
sizeof(node->focus_bg_color)); sizeof(mangobar->focus_bg_color));
memcpy(node->border_color, data.border_color, sizeof(node->border_color)); memcpy(mangobar->border_color, data.border_color,
node->border_width = data.border_width; sizeof(mangobar->border_color));
node->corner_radius = data.corner_radius; mangobar->border_width = data.border_width;
node->padding_x = data.padding_x; mangobar->corner_radius = data.corner_radius;
node->padding_y = data.padding_y; mangobar->padding_x = data.padding_x;
node->font_desc = mangobar->padding_y = data.padding_y;
mangobar->font_desc =
g_strdup(data.font_desc ? data.font_desc : "monospace Bold 16"); g_strdup(data.font_desc ? data.font_desc : "monospace Bold 16");
node->target_width = width; mangobar->target_width = width;
node->target_height = height; mangobar->target_height = height;
node->focused = false; mangobar->focused = false;
node->cached_focused = false; mangobar->cached_focused = false;
node->measure_surface = mangobar->measure_surface =
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1); cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1);
node->measure_cr = cairo_create(node->measure_surface); mangobar->measure_cr = cairo_create(mangobar->measure_surface);
node->measure_context = pango_cairo_create_context(node->measure_cr); mangobar->measure_context =
node->measure_layout = pango_layout_new(node->measure_context); pango_cairo_create_context(mangobar->measure_cr);
node->measure_scale = 1.0f; mangobar->measure_layout = pango_layout_new(mangobar->measure_context);
mangobar->measure_scale = 1.0f;
node->cached_scale = -1.0f; mangobar->cached_scale = -1.0f;
node->last_text = NULL; mangobar->last_text = NULL;
node->last_scale = 0.0f; mangobar->last_scale = 0.0f;
node->scene_buffer->node.data = mango_node_data;
return node; mangobar->type = type;
mangobar->node_data = cdata;
mangobar->scene_buffer->node.data = mangobar;
return mangobar;
} }
void mango_tab_bar_node_destroy(struct mango_tab_bar_node *node) { void mango_group_bar_destroy(MangoGroupBar *node) {
if (!node) if (!node)
return; return;
@ -492,19 +495,15 @@ void mango_tab_bar_node_destroy(struct mango_tab_bar_node *node) {
if (node->measure_cr) if (node->measure_cr)
cairo_destroy(node->measure_cr); cairo_destroy(node->measure_cr);
void *data = node->scene_buffer->node.data;
wlr_scene_node_destroy(&node->scene_buffer->node);
g_free(node->font_desc); g_free(node->font_desc);
g_free(node->cached_text); g_free(node->cached_text);
g_free(node->cached_font_desc); g_free(node->cached_font_desc);
g_free(node->last_text); g_free(node->last_text);
free(data);
free(node); free(node);
} }
void mango_tab_bar_node_set_size(struct mango_tab_bar_node *node, int32_t width, void mango_group_bar_set_size(MangoGroupBar *node, int32_t width,
int32_t height) { int32_t height) {
if (!node) if (!node)
return; return;
@ -522,11 +521,11 @@ void mango_tab_bar_node_set_size(struct mango_tab_bar_node *node, int32_t width,
const char *redraw_text = node->last_text ? node->last_text : ""; const char *redraw_text = node->last_text ? node->last_text : "";
float redraw_scale = node->last_scale > 0.0f ? node->last_scale : 1.0f; float redraw_scale = node->last_scale > 0.0f ? node->last_scale : 1.0f;
mango_tab_bar_node_update(node, redraw_text, redraw_scale); mango_group_bar_update(node, redraw_text, redraw_scale);
} }
void mango_tab_bar_node_update(struct mango_tab_bar_node *node, void mango_group_bar_update(MangoGroupBar *node, const char *text,
const char *text, float scale) { float scale) {
if (!node || !text) if (!node || !text)
return; return;
if (scale <= 0.0f) if (scale <= 0.0f)
@ -765,19 +764,18 @@ void mango_tab_bar_node_update(struct mango_tab_bar_node *node,
node->logical_height); node->logical_height);
} }
void mango_tab_bar_node_set_focus(struct mango_tab_bar_node *node, void mango_group_bar_set_focus(MangoGroupBar *node, bool focused) {
bool focused) {
if (!node || node->focused == focused) if (!node || node->focused == focused)
return; return;
node->focused = focused; node->focused = focused;
if (node->last_text) { if (node->last_text) {
float scale = node->last_scale > 0.0f ? node->last_scale : 1.0f; float scale = node->last_scale > 0.0f ? node->last_scale : 1.0f;
mango_tab_bar_node_update(node, node->last_text, scale); mango_group_bar_update(node, node->last_text, scale);
} }
} }
void mango_tab_bar_node_set_colors(struct mango_tab_bar_node *node, void mango_group_bar_set_colors(MangoGroupBar *node, const float fg[4],
const float fg[4], const float bg[4]) { const float bg[4]) {
if (!node) if (!node)
return; return;
@ -786,11 +784,11 @@ void mango_tab_bar_node_set_colors(struct mango_tab_bar_node *node,
if (!node->focused && node->last_text) { if (!node->focused && node->last_text) {
float scale = node->last_scale > 0.0f ? node->last_scale : 1.0f; float scale = node->last_scale > 0.0f ? node->last_scale : 1.0f;
mango_tab_bar_node_update(node, node->last_text, scale); mango_group_bar_update(node, node->last_text, scale);
} }
} }
void mango_jump_label_node_apply_config(struct mango_jump_label_node *node, void mango_jump_label_node_apply_config(MangoJumpLabel *node,
const DecorateDrawData *data) { const DecorateDrawData *data) {
if (!node || !data) if (!node || !data)
return; return;
@ -817,8 +815,8 @@ void mango_jump_label_node_apply_config(struct mango_jump_label_node *node,
} }
} }
void mango_tab_bar_node_apply_config(struct mango_tab_bar_node *node, void mango_group_bar_apply_config(MangoGroupBar *node,
const DecorateDrawData *data) { const DecorateDrawData *data) {
if (!node || !data) if (!node || !data)
return; return;
@ -840,6 +838,6 @@ void mango_tab_bar_node_apply_config(struct mango_tab_bar_node *node,
if (node->last_text) { if (node->last_text) {
float scale = node->last_scale > 0.0f ? node->last_scale : 1.0f; float scale = node->last_scale > 0.0f ? node->last_scale : 1.0f;
mango_tab_bar_node_update(node, node->last_text, scale); mango_group_bar_update(node, node->last_text, scale);
} }
} }

View file

@ -26,8 +26,7 @@ struct mango_text_buffer {
struct wlr_buffer base; struct wlr_buffer base;
cairo_surface_t *surface; cairo_surface_t *surface;
}; };
typedef struct {
struct mango_jump_label_node {
struct wlr_scene_buffer *scene_buffer; struct wlr_scene_buffer *scene_buffer;
struct mango_text_buffer *buffer; struct mango_text_buffer *buffer;
cairo_surface_t *surface; cairo_surface_t *surface;
@ -70,13 +69,15 @@ struct mango_jump_label_node {
int32_t logical_width; int32_t logical_width;
int32_t logical_height; int32_t logical_height;
}; } MangoJumpLabel;
struct mango_tab_bar_node { typedef struct {
uint32_t type;
struct wlr_scene_buffer *scene_buffer; struct wlr_scene_buffer *scene_buffer;
struct mango_text_buffer *buffer; struct mango_text_buffer *buffer;
cairo_surface_t *surface; cairo_surface_t *surface;
int surface_pixel_w, surface_pixel_h; int surface_pixel_w, surface_pixel_h;
void *node_data; // 存储窗口指针
// 初始配置 // 初始配置
float fg_color[4]; float fg_color[4];
@ -126,41 +127,38 @@ struct mango_tab_bar_node {
int32_t logical_width; int32_t logical_width;
int32_t logical_height; int32_t logical_height;
}; } MangoGroupBar;
void mango_text_global_finish(void); void mango_text_global_finish(void);
struct mango_jump_label_node * MangoJumpLabel *mango_jump_label_node_create(struct wlr_scene_tree *parent,
mango_jump_label_node_create(struct wlr_scene_tree *parent, DecorateDrawData data);
DecorateDrawData data); void mango_jump_label_node_destroy(MangoJumpLabel *node);
void mango_jump_label_node_destroy(struct mango_jump_label_node *node); void mango_jump_label_node_set_background(MangoJumpLabel *node, float r,
void mango_jump_label_node_set_background(struct mango_jump_label_node *node, float g, float b, float a);
float r, float g, float b, float a); void mango_jump_label_node_set_border(MangoJumpLabel *node, float r, float g,
void mango_jump_label_node_set_border(struct mango_jump_label_node *node, float b, float a, int32_t width,
float r, float g, float b, float a, int32_t radius);
int32_t width, int32_t radius); void mango_jump_label_node_set_padding(MangoJumpLabel *node, int32_t pad_x,
void mango_jump_label_node_set_padding(struct mango_jump_label_node *node, int32_t pad_y);
int32_t pad_x, int32_t pad_y); void mango_jump_label_node_update(MangoJumpLabel *node, const char *text,
void mango_jump_label_node_update(struct mango_jump_label_node *node, float scale);
const char *text, float scale);
struct mango_tab_bar_node * MangoGroupBar *mango_group_bar_create(void *cdata, uint32_t type,
mango_tab_bar_node_create(void *mango_node_data, struct wlr_scene_tree *parent, struct wlr_scene_tree *parent,
DecorateDrawData data, int32_t width, int32_t height); DecorateDrawData data, int32_t width,
void mango_tab_bar_node_destroy(struct mango_tab_bar_node *node); int32_t height);
void mango_tab_bar_node_set_size(struct mango_tab_bar_node *node, int32_t width, void mango_group_bar_destroy(MangoGroupBar *node);
int32_t height); void mango_group_bar_set_size(MangoGroupBar *node, int32_t width,
void mango_tab_bar_node_update(struct mango_tab_bar_node *node, int32_t height);
const char *text, float scale); void mango_group_bar_update(MangoGroupBar *node, const char *text, float scale);
void mango_jump_label_node_set_focus(struct mango_jump_label_node *node, void mango_jump_label_node_set_focus(MangoJumpLabel *node, bool focused);
bool focused); void mango_group_bar_set_focus(MangoGroupBar *node, bool focused);
void mango_tab_bar_node_set_focus(struct mango_tab_bar_node *node,
bool focused);
void mango_tab_bar_node_set_colors(struct mango_tab_bar_node *node, void mango_group_bar_set_colors(MangoGroupBar *node, const float fg[4],
const float fg[4], const float bg[4]); const float bg[4]);
void mango_jump_label_node_apply_config(struct mango_jump_label_node *node, void mango_jump_label_node_apply_config(MangoJumpLabel *node,
const DecorateDrawData *data); const DecorateDrawData *data);
void mango_tab_bar_node_apply_config(struct mango_tab_bar_node *node, void mango_group_bar_apply_config(MangoGroupBar *node,
const DecorateDrawData *data); const DecorateDrawData *data);
#endif // jump_label_node_H #endif // jump_label_node_H

View file

@ -27,6 +27,7 @@ struct dwl_input_method_relay {
}; };
struct dwl_input_method_popup { struct dwl_input_method_popup {
uint32_t type;
struct wlr_input_popup_surface_v2 *popup_surface; struct wlr_input_popup_surface_v2 *popup_surface;
struct wlr_scene_tree *tree; struct wlr_scene_tree *tree;
struct wlr_scene_tree *scene_surface; struct wlr_scene_tree *scene_surface;
@ -404,6 +405,8 @@ static void handle_input_method_new_popup_surface(struct wl_listener *listener,
popup->tree = wlr_scene_tree_create(layers[LyrIMPopup]); popup->tree = wlr_scene_tree_create(layers[LyrIMPopup]);
popup->scene_surface = wlr_scene_subsurface_tree_create( popup->scene_surface = wlr_scene_subsurface_tree_create(
popup->tree, popup->popup_surface->surface); popup->tree, popup->popup_surface->surface);
popup->type = XdgImPopup;
popup->scene_surface->node.data = popup; popup->scene_surface->node.data = popup;
wl_list_insert(&relay->popups, &popup->link); wl_list_insert(&relay->popups, &popup->link);

View file

@ -100,13 +100,12 @@ static bool layer_ignores_focus(LayerSurface *l) {
} }
void xytonode(double x, double y, struct wlr_surface **psurface, Client **pc, void xytonode(double x, double y, struct wlr_surface **psurface, Client **pc,
LayerSurface **pl, MangoCustomDecorate **pd, double *nx, LayerSurface **pl, MangoGroupBar **gb, double *nx, double *ny) {
double *ny) {
struct wlr_scene_node *node = NULL, *pnode = NULL; struct wlr_scene_node *node = NULL, *pnode = NULL;
struct wlr_surface *surface = NULL; struct wlr_surface *surface = NULL;
Client *c = NULL; Client *c = NULL;
LayerSurface *l = NULL; LayerSurface *l = NULL;
MangoCustomDecorate *mangocustomdecorate = NULL; MangoGroupBar *mangogroupbar = NULL;
int32_t layer; int32_t layer;
Client *ovc = NULL; Client *ovc = NULL;
@ -116,8 +115,8 @@ void xytonode(double x, double y, struct wlr_surface **psurface, Client **pc,
*pc = NULL; *pc = NULL;
if (pl) if (pl)
*pl = NULL; *pl = NULL;
if (pd) if (gb)
*pd = NULL; *gb = NULL;
for (layer = NUM_LAYERS - 1; layer >= 0; layer--) { for (layer = NUM_LAYERS - 1; layer >= 0; layer--) {
if (layer == LyrFadeOut) if (layer == LyrFadeOut)
@ -152,8 +151,8 @@ void xytonode(double x, double y, struct wlr_surface **psurface, Client **pc,
Client *temp_c = (Client *)data; Client *temp_c = (Client *)data;
if (temp_c->type == LayerShell) { if (temp_c->type == LayerShell) {
l = (LayerSurface *)temp_c; l = (LayerSurface *)temp_c;
} else if (temp_c->type == CustomDecorate) { } else if (temp_c->type == GroupBar) {
mangocustomdecorate = (MangoCustomDecorate *)temp_c; mangogroupbar = (MangoGroupBar *)temp_c;
} else if (temp_c->type == XDGShell || temp_c->type == X11) { } else if (temp_c->type == XDGShell || temp_c->type == X11) {
c = temp_c; c = temp_c;
} }
@ -175,8 +174,8 @@ void xytonode(double x, double y, struct wlr_surface **psurface, Client **pc,
*pc = c; *pc = c;
if (pl) if (pl)
*pl = l; *pl = l;
if (pd) if (gb)
*pd = mangocustomdecorate; *gb = mangogroupbar;
if (selmon && selmon->isoverview && config.ov_no_resize) { if (selmon && selmon->isoverview && config.ov_no_resize) {
ovc = xytoclient(x, y); ovc = xytoclient(x, y);
@ -196,8 +195,8 @@ void xytonode(double x, double y, struct wlr_surface **psurface, Client **pc,
*psurface = ovc ? client_surface(ovc) : NULL; *psurface = ovc ? client_surface(ovc) : NULL;
if (pl) if (pl)
*pl = NULL; *pl = NULL;
if (pd) if (gb)
*pd = NULL; *gb = NULL;
} }
} }
} }

View file

@ -1132,7 +1132,7 @@ void pre_caculate_before_arrange(Monitor *m, bool want_animation,
client_add_jump_label_node(c); client_add_jump_label_node(c);
} }
if (c->tab_bar_node && c->tab_bar_node->scene_buffer->node.enabled) { if (c->group_bar && c->group_bar->scene_buffer->node.enabled) {
client_check_tab_node_visible(c); client_check_tab_node_visible(c);
} }

View file

@ -698,7 +698,7 @@ void vertical_scroller(Monitor *m) {
} else { } else {
bar_height = !root_client->isfullscreen && (root_client->group_prev || bar_height = !root_client->isfullscreen && (root_client->group_prev ||
root_client->group_next) root_client->group_next)
? config.tab_bar_height ? config.group_bar_height
: 0; : 0;
target_geom.y = root_client->geom.y - bar_height; target_geom.y = root_client->geom.y - bar_height;
@ -718,7 +718,7 @@ void vertical_scroller(Monitor *m) {
bar_height = !heads[focus_index - i + 1]->client->isfullscreen && bar_height = !heads[focus_index - i + 1]->client->isfullscreen &&
(heads[focus_index - i + 1]->client->group_prev || (heads[focus_index - i + 1]->client->group_prev ||
heads[focus_index - i + 1]->client->group_next) heads[focus_index - i + 1]->client->group_next)
? config.tab_bar_height ? config.group_bar_height
: 0; : 0;
up_geom.y = heads[focus_index - i + 1]->client->geom.y - cur_gappiv - up_geom.y = heads[focus_index - i + 1]->client->geom.y - cur_gappiv -

View file

@ -165,9 +165,17 @@ enum { TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT };
enum { VERTICAL, HORIZONTAL }; enum { VERTICAL, HORIZONTAL };
enum { SWIPE_UP, SWIPE_DOWN, SWIPE_LEFT, SWIPE_RIGHT }; enum { SWIPE_UP, SWIPE_DOWN, SWIPE_LEFT, SWIPE_RIGHT };
enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */ enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
enum { XDGShell, LayerShell, X11, CustomDecorate, Snapshot }; /* client types */ enum {
enum { AxisUp, AxisDown, AxisLeft, AxisRight }; // 滚轮滚动的方向 XDGShell,
LayerShell,
X11,
Snapshot,
XdgPopup,
XdgImPopup,
GroupBar
}; /* client types */
enum { AxisUp, AxisDown, AxisLeft, AxisRight }; // 滚轮滚动的方向
enum { enum {
LyrBg, LyrBg,
LyrBlur, LyrBlur,
@ -182,8 +190,6 @@ enum {
NUM_LAYERS NUM_LAYERS
}; /* scene layers */ }; /* scene layers */
enum mango_node_type { MANGO_TITLE_NODE, MANGO_JUMP_NODE };
#ifdef XWAYLAND #ifdef XWAYLAND
enum { enum {
NetWMWindowTypeDialog, NetWMWindowTypeDialog,
@ -249,13 +255,6 @@ typedef struct {
uint32_t ui2; uint32_t ui2;
Client *tc; Client *tc;
} Arg; } Arg;
typedef struct {
uint32_t type;
enum mango_node_type node_type;
void *node_data;
} MangoCustomDecorate;
typedef struct { typedef struct {
uint32_t mod; uint32_t mod;
uint32_t button; uint32_t button;
@ -347,8 +346,8 @@ struct Client {
struct wlr_ext_image_capture_source_v1 *image_capture_source; struct wlr_ext_image_capture_source_v1 *image_capture_source;
struct wlr_scene_surface *image_capture_scene_surface; struct wlr_scene_surface *image_capture_scene_surface;
struct wlr_scene_tree *overview_scene_surface; struct wlr_scene_tree *overview_scene_surface;
struct mango_jump_label_node *jump_label_node; MangoJumpLabel *jump_label_node;
struct mango_tab_bar_node *tab_bar_node; MangoGroupBar *group_bar;
struct wl_list link; struct wl_list link;
struct wl_list flink; struct wl_list flink;
struct wl_list fadeout_link; struct wl_list fadeout_link;
@ -540,6 +539,7 @@ typedef struct {
} LayerSurface; } LayerSurface;
typedef struct { typedef struct {
uint32_t type;
struct wlr_xdg_popup *wlr_popup; struct wlr_xdg_popup *wlr_popup;
struct wl_listener destroy; struct wl_listener destroy;
struct wl_listener commit; struct wl_listener commit;
@ -805,7 +805,7 @@ static Monitor *get_monitor_nearest_to(int32_t x, int32_t y);
static void handle_iamge_copy_capture_new_session(struct wl_listener *listener, static void handle_iamge_copy_capture_new_session(struct wl_listener *listener,
void *data); void *data);
static void xytonode(double x, double y, struct wlr_surface **psurface, static void xytonode(double x, double y, struct wlr_surface **psurface,
Client **pc, LayerSurface **pl, MangoCustomDecorate **pd, Client **pc, LayerSurface **pl, MangoGroupBar **tb,
double *nx, double *ny); double *nx, double *ny);
static void clear_fullscreen_flag(Client *c); static void clear_fullscreen_flag(Client *c);
static pid_t getparentprocess(pid_t p); static pid_t getparentprocess(pid_t p);
@ -943,8 +943,8 @@ static void overview_backup_surface(Client *c);
static void create_jump_hints(Monitor *m); static void create_jump_hints(Monitor *m);
static void finish_jump_mode(Monitor *m); static void finish_jump_mode(Monitor *m);
static void begin_jump_mode(Monitor *m); static void begin_jump_mode(Monitor *m);
static void global_draw_tab_bar(Client *c, int32_t x, int32_t y, int32_t width, static void global_draw_group_bar(Client *c, int32_t x, int32_t y,
int32_t height); int32_t width, int32_t height);
static void client_reparent_group(Client *c); static void client_reparent_group(Client *c);
@ -1333,7 +1333,7 @@ void client_replace(Client *c, Client *w, bool isgroupaction) {
} }
if (c->isgroupfocusing) if (c->isgroupfocusing)
mango_tab_bar_node_set_focus(c->tab_bar_node, true); mango_group_bar_set_focus(c->group_bar, true);
} }
if (w->overview_scene_surface) { if (w->overview_scene_surface) {
@ -1346,8 +1346,8 @@ void client_replace(Client *c, Client *w, bool isgroupaction) {
overview_backup_surface(c); overview_backup_surface(c);
} }
if (w->tab_bar_node && !isgroupaction) { if (w->group_bar && !isgroupaction) {
wlr_scene_node_set_enabled(&w->tab_bar_node->scene_buffer->node, false); wlr_scene_node_set_enabled(&w->group_bar->scene_buffer->node, false);
} }
if (c->link.prev && c->link.next && c->link.prev != &c->link) { if (c->link.prev && c->link.next && c->link.prev != &c->link) {
@ -2436,7 +2436,7 @@ bool handle_buttonpress(struct wlr_pointer_button_event *event) {
uint32_t hard_mods, mods; uint32_t hard_mods, mods;
Client *c = NULL; Client *c = NULL;
LayerSurface *l = NULL; LayerSurface *l = NULL;
MangoCustomDecorate *md = NULL; MangoGroupBar *gb = NULL;
struct wlr_surface *surface; struct wlr_surface *surface;
Client *tmpc = NULL; Client *tmpc = NULL;
int32_t ji; int32_t ji;
@ -2458,7 +2458,7 @@ bool handle_buttonpress(struct wlr_pointer_button_event *event) {
if (locked) if (locked)
break; break;
xytonode(cursor->x, cursor->y, &surface, NULL, NULL, &md, NULL, NULL); xytonode(cursor->x, cursor->y, &surface, NULL, NULL, &gb, NULL, NULL);
if (toplevel_from_wlr_surface(surface, &c, &l) >= 0) { if (toplevel_from_wlr_surface(surface, &c, &l) >= 0) {
if (c && c->scene->node.enabled && if (c && c->scene->node.enabled &&
(!client_is_unmanaged(c) || client_wants_focus(c))) (!client_is_unmanaged(c) || client_wants_focus(c)))
@ -2489,7 +2489,7 @@ bool handle_buttonpress(struct wlr_pointer_button_event *event) {
} }
// handle click on tile node // handle click on tile node
client_handle_decorate_click(md); client_handle_decorate_click(gb);
// 当鼠标焦点在layer上的时候不检测虚拟键盘的mod状态 // 当鼠标焦点在layer上的时候不检测虚拟键盘的mod状态
// 避免layer虚拟键盘锁死mod按键状态 // 避免layer虚拟键盘锁死mod按键状态
@ -3154,6 +3154,8 @@ static void createpopup(struct wl_listener *listener, void *data) {
if (!popup) if (!popup)
return; return;
popup->type = XdgPopup;
popup->destroy.notify = destroypopup; popup->destroy.notify = destroypopup;
wl_signal_add(&wlr_popup->events.destroy, &popup->destroy); wl_signal_add(&wlr_popup->events.destroy, &popup->destroy);
@ -4521,7 +4523,7 @@ void init_client_properties(Client *c) {
c->grid_col_per = 1.0f; c->grid_col_per = 1.0f;
c->grid_row_per = 1.0f; c->grid_row_per = 1.0f;
c->jump_label_node = NULL; c->jump_label_node = NULL;
c->tab_bar_node = NULL; c->group_bar = NULL;
c->overview_scene_surface = NULL; c->overview_scene_surface = NULL;
c->drop_direction = UNDIR; c->drop_direction = UNDIR;
c->enable_drop_area_draw = false; c->enable_drop_area_draw = false;
@ -4698,7 +4700,7 @@ mapnotify(struct wl_listener *listener, void *data) {
wlr_scene_node_set_enabled(&c->splitindicator[i]->node, false); wlr_scene_node_set_enabled(&c->splitindicator[i]->node, false);
} }
client_add_tab_bar_node(c); client_add_group_bar(c);
c->droparea = wlr_scene_rect_create(c->scene, 0, 0, config.dropcolor); c->droparea = wlr_scene_rect_create(c->scene, 0, 0, config.dropcolor);
wlr_scene_node_lower_to_bottom(&c->droparea->node); wlr_scene_node_lower_to_bottom(&c->droparea->node);
@ -5716,9 +5718,9 @@ void reset_maximizescreen_size(Client *c) {
geom.width = c->mon->w.width - 2 * config.gappoh; geom.width = c->mon->w.width - 2 * config.gappoh;
geom.height = c->mon->w.height - 2 * config.gappov; geom.height = c->mon->w.height - 2 * config.gappov;
if ((c->group_next || c->group_prev) && c->tab_bar_node) { if ((c->group_next || c->group_prev) && c->group_bar) {
geom.height -= config.tab_bar_height; geom.height -= config.group_bar_height;
geom.y += config.tab_bar_height; geom.y += config.group_bar_height;
} }
resize(c, geom, 0); resize(c, geom, 0);
@ -5763,9 +5765,9 @@ void setmaximizescreen(Client *c, int32_t maximizescreen, bool rearrange) {
maximizescreen_box.width = c->mon->w.width - 2 * config.gappoh; maximizescreen_box.width = c->mon->w.width - 2 * config.gappoh;
maximizescreen_box.height = c->mon->w.height - 2 * config.gappov; maximizescreen_box.height = c->mon->w.height - 2 * config.gappov;
if ((c->group_next || c->group_prev) && c->tab_bar_node) { if ((c->group_next || c->group_prev) && c->group_bar) {
maximizescreen_box.height -= config.tab_bar_height; maximizescreen_box.height -= config.group_bar_height;
maximizescreen_box.y += config.tab_bar_height; maximizescreen_box.y += config.group_bar_height;
} }
wlr_scene_node_raise_to_top(&c->scene->node); wlr_scene_node_raise_to_top(&c->scene->node);
@ -6853,9 +6855,9 @@ void unmapnotify(struct wl_listener *listener, void *data) {
mango_jump_label_node_destroy(c->jump_label_node); mango_jump_label_node_destroy(c->jump_label_node);
c->jump_label_node = NULL; c->jump_label_node = NULL;
} }
if (c->tab_bar_node) { if (c->group_bar) {
mango_tab_bar_node_destroy(c->tab_bar_node); mango_group_bar_destroy(c->group_bar);
c->tab_bar_node = NULL; c->group_bar = NULL;
} }
wlr_scene_node_destroy(&c->image_capture_scene_surface->buffer->node); wlr_scene_node_destroy(&c->image_capture_scene_surface->buffer->node);
@ -7015,7 +7017,7 @@ void updatetitle(struct wl_listener *listener, void *data) {
const char *title; const char *title;
title = client_get_title(c); title = client_get_title(c);
mango_tab_bar_node_update(c->tab_bar_node, title, 1.0); mango_group_bar_update(c->group_bar, title, 1.0);
if (title && c->foreign_toplevel) if (title && c->foreign_toplevel)
wlr_foreign_toplevel_handle_v1_set_title(c->foreign_toplevel, title); wlr_foreign_toplevel_handle_v1_set_title(c->foreign_toplevel, title);
if (title && c->ext_foreign_toplevel) { if (title && c->ext_foreign_toplevel) {