opt: allow tab height to 0
Some checks are pending
Sync website / sync-website (push) Waiting to run
Sync wiki / sync-wiki (push) Waiting to run

This commit is contained in:
DreamMaoMao 2026-06-18 23:35:25 +08:00
parent 727b9fe77e
commit 5583f8901a
4 changed files with 29 additions and 15 deletions

View file

@ -105,6 +105,11 @@ void client_add_jump_label_node(Client *c) {
}
void client_add_tab_bar_node(Client *c) {
if (config.tab_bar_height <= 0) {
return;
}
MangoNodeData *mangonodedata = ecalloc(1, sizeof(MangoNodeData));
mangonodedata->node_data = c;
mangonodedata->type = MANGO_TITLE_NODE;

View file

@ -398,11 +398,15 @@ void client_draw_shadow(Client *c) {
wlr_scene_shadow_set_clipped_region(c->shadow, clipped_region);
}
void global_draw_titlebar(Client *c, int32_t x, int32_t y, int32_t width,
int32_t height) {
void global_draw_tab_bar(Client *c, int32_t x, int32_t y, int32_t width,
int32_t height) {
if (!c->tab_bar_node)
return;
if (height <= 0) {
wlr_scene_node_set_enabled(&c->tab_bar_node->scene_buffer->node, false);
}
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);

View file

@ -3569,7 +3569,7 @@ void override_config(void) {
config.scratchpad_height_ratio =
CLAMP_FLOAT(config.scratchpad_height_ratio, 0.1f, 1.0f);
config.borderpx = CLAMP_INT(config.borderpx, 0, 200);
config.tab_bar_height = CLAMP_INT(config.tab_bar_height, 5, 500);
config.tab_bar_height = CLAMP_INT(config.tab_bar_height, 0, 500);
config.smartgaps = CLAMP_INT(config.smartgaps, 0, 1);
config.blur = CLAMP_INT(config.blur, 0, 1);
config.blur_layer = CLAMP_INT(config.blur_layer, 0, 1);

View file

@ -546,7 +546,7 @@ void deck(Monitor *m) {
}
void monocle(Monitor *m) {
Client *c, *fc;
Client *c = NULL, *fc = NULL;
struct wlr_box geom;
int32_t cur_gappov = enablegaps ? m->gappov : 0;
int32_t cur_gappoh = enablegaps ? m->gappoh : 0;
@ -580,19 +580,24 @@ void monocle(Monitor *m) {
return;
}
int titlebar_height = config.tab_bar_height;
int title_y = m->w.y + cur_gappov;
int main_y = title_y + titlebar_height + cur_gapiv;
int main_height =
m->w.height - 2 * cur_gappov - 2 * cur_gapiv - titlebar_height;
int tab_bar_height = config.tab_bar_height;
int title_area_width = m->w.width - 2 * cur_gappoh;
int tab_bar_inner_gap_height =
config.tab_bar_height > 0 ? 2 * cur_gapiv : 0;
int tab_bar_y_offset = config.tab_bar_height > 0 ? cur_gapiv : 0;
int tab_y = m->w.y + cur_gappov;
int main_y = tab_y + tab_bar_height + tab_bar_y_offset;
int main_height = m->w.height - 2 * cur_gappov - tab_bar_inner_gap_height -
tab_bar_height;
int tab_area_width = m->w.width - 2 * cur_gappoh;
int total_gaps = (n - 1) * cur_gapih;
int base_width = (title_area_width - total_gaps) / n;
int remainder = (title_area_width - total_gaps) % n;
int base_width = (tab_area_width - total_gaps) / n;
int remainder = (tab_area_width - total_gaps) % n;
int title_x = m->w.x + cur_gappoh;
int tab_x = m->w.x + cur_gappoh;
int idx = 0;
wl_list_for_each(c, &clients, link) {
@ -612,9 +617,9 @@ void monocle(Monitor *m) {
client_tile_resize(c, geom, 0);
int tw = base_width + (idx < remainder ? 1 : 0);
global_draw_titlebar(c, title_x, title_y, tw, titlebar_height);
global_draw_tab_bar(c, tab_x, tab_y, tw, tab_bar_height);
title_x += tw + cur_gapih;
tab_x += tw + cur_gapih;
idx++;
}
}