feat: monocle layout support title tab

This commit is contained in:
DreamMaoMao 2026-06-17 10:22:37 +08:00
parent 5652066c68
commit 5a60f39064
12 changed files with 843 additions and 133 deletions

View file

@ -37,6 +37,21 @@ void set_size_per(Monitor *m, Client *c) {
}
}
void monocle_set_focus(Client *c, bool focused) {
if (!c || !c->mon)
return;
c->is_monocle_hide = !focused;
mango_titlebar_node_set_focus(c->titlebar_node, focused);
wlr_scene_node_set_enabled(&c->scene->node, focused);
if (!focused) {
c->animation.current = c->animainit_geom = c->animation.initial =
c->pending = c->current = c->geom;
}
}
void resize_tile_master_horizontal(Client *grabc, bool isdrag, int32_t offsetx,
int32_t offsety, uint32_t time,
int32_t type) {
@ -1128,6 +1143,20 @@ 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);
}
if (c->mon == m && (c->isglobal || c->isunglobal)) {
c->tags = m->tagset[m->seltags];
}

View file

@ -545,32 +545,70 @@ void deck(Monitor *m) {
}
}
void // 17
monocle(Monitor *m) {
Client *c = NULL;
void monocle(Monitor *m) {
Client *c, *fc;
struct wlr_box geom;
int32_t cur_gappov = enablegaps ? m->gappov : 0;
int32_t cur_gappoh = enablegaps ? m->gappoh : 0;
int32_t cur_gapiv = enablegaps ? m->gappiv : 0;
int32_t cur_gapih = enablegaps ? m->gappih : 0;
cur_gappoh = config.smartgaps && m->visible_fake_tiling_clients == 1
? 0
: cur_gappoh;
cur_gappov = config.smartgaps && m->visible_fake_tiling_clients == 1
? 0
: cur_gappov;
if (config.smartgaps && m->visible_fake_tiling_clients == 1) {
cur_gappov = cur_gappoh = cur_gapiv = cur_gapih = 0;
}
wl_list_for_each(c, &clients, link) {
if (!VISIBLEON(c, m) || !ISFAKETILED(c))
int n = m->visible_fake_tiling_clients;
if (n == 0)
return;
wl_list_for_each(c, &fstack, flink) {
if (c->iskilling || c->isunglobal || !ISFAKETILED(c))
continue;
if (VISIBLEON(c, m)) {
fc = c;
break;
}
}
if (n == 1) {
geom.x = m->w.x + cur_gappoh;
geom.y = m->w.y + cur_gappov;
geom.width = m->w.width - 2 * cur_gappoh;
geom.height = m->w.height - 2 * cur_gappov;
client_tile_resize(c, geom, 0);
client_tile_resize(fc, geom, 0);
monocle_set_focus(fc, true);
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 title_area_width = m->w.width - 2 * cur_gappoh;
int tw = (title_area_width - (n - 1) * cur_gapih) / n;
int title_x = m->w.x + cur_gappoh;
wl_list_for_each(c, &clients, link) {
if (!VISIBLEON(c, m) || !ISFAKETILED(c))
continue;
if (c == fc) {
monocle_set_focus(c, true);
} else {
monocle_set_focus(c, false);
}
geom.x = m->w.x + cur_gappoh;
geom.y = main_y;
geom.width = m->w.width - 2 * cur_gappoh;
geom.height = main_height;
client_tile_resize(c, geom, 0);
global_draw_titlebar(c, title_x, title_y, tw, titlebar_height);
title_x += tw + cur_gapih;
}
if ((c = focustop(m)))
wlr_scene_node_raise_to_top(&c->scene->node);
}
// 网格布局窗口大小和位置计算