mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-06-18 14:33:09 -04:00
This commit is contained in:
parent
405e8dbc1a
commit
f56fc468c3
1 changed files with 71 additions and 65 deletions
|
|
@ -547,79 +547,85 @@ static void dwindle_insert_with_config(DwindleNode **root, Client *new_c,
|
||||||
}
|
}
|
||||||
|
|
||||||
void dwindle(Monitor *m) {
|
void dwindle(Monitor *m) {
|
||||||
int32_t n = m->visible_tiling_clients;
|
int32_t n = m->visible_tiling_clients;
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint32_t tag = m->pertag->curtag;
|
uint32_t tag = m->pertag->curtag;
|
||||||
DwindleNode **root = &m->pertag->dwindle_root[tag];
|
DwindleNode **root = &m->pertag->dwindle_root[tag];
|
||||||
float ratio = config.dwindle_split_ratio;
|
float ratio = config.dwindle_split_ratio;
|
||||||
|
|
||||||
Client *vis[512];
|
Client *vis[512];
|
||||||
int32_t count = 0;
|
int32_t count = 0;
|
||||||
Client *c;
|
Client *c;
|
||||||
wl_list_for_each(c, &clients, link) {
|
wl_list_for_each(c, &clients, link) {
|
||||||
if (VISIBLEON(c, m) && ISTILED(c))
|
if (VISIBLEON(c, m) && ISTILED(c))
|
||||||
vis[count++] = c;
|
vis[count++] = c;
|
||||||
if (count >= 512)
|
if (count >= 512)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
// 清理树中已不存在的客户端
|
||||||
DwindleNode *leaves[512];
|
{
|
||||||
int32_t lc = 0;
|
DwindleNode *leaves[512];
|
||||||
|
int32_t lc = 0;
|
||||||
|
|
||||||
DwindleNode *stack[1024];
|
DwindleNode *stack[1024];
|
||||||
int32_t sp = 0;
|
int32_t sp = 0;
|
||||||
if (*root)
|
if (*root)
|
||||||
stack[sp++] = *root;
|
stack[sp++] = *root;
|
||||||
while (sp > 0) {
|
while (sp > 0) {
|
||||||
DwindleNode *nd = stack[--sp];
|
DwindleNode *nd = stack[--sp];
|
||||||
if (!nd->is_split) {
|
if (!nd->is_split) {
|
||||||
leaves[lc++] = nd;
|
leaves[lc++] = nd;
|
||||||
} else {
|
} else {
|
||||||
if (nd->second)
|
if (nd->second)
|
||||||
stack[sp++] = nd->second;
|
stack[sp++] = nd->second;
|
||||||
if (nd->first)
|
if (nd->first)
|
||||||
stack[sp++] = nd->first;
|
stack[sp++] = nd->first;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < lc; i++) {
|
for (int32_t i = 0; i < lc; i++) {
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (int32_t j = 0; j < count; j++)
|
for (int32_t j = 0; j < count; j++)
|
||||||
if (vis[j] == leaves[i]->client) {
|
if (vis[j] == leaves[i]->client) {
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
if (VISIBLEON(leaves[i]->client, m) &&
|
if (VISIBLEON(leaves[i]->client, m) &&
|
||||||
(leaves[i]->client->isfullscreen ||
|
(leaves[i]->client->isfullscreen ||
|
||||||
leaves[i]->client->ismaximizescreen))
|
leaves[i]->client->ismaximizescreen))
|
||||||
continue;
|
continue;
|
||||||
dwindle_remove(root, leaves[i]->client);
|
dwindle_remove(root, leaves[i]->client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Client *focused = focustop(m);
|
// 获得焦点客户端,若为空则用第一个可见平铺客户端兜底
|
||||||
if (focused && !dwindle_find_leaf(*root, focused))
|
Client *focused = focustop(m);
|
||||||
focused = m->sel;
|
if (focused && !dwindle_find_leaf(*root, focused))
|
||||||
for (int32_t i = 0; i < count; i++) {
|
focused = m->sel;
|
||||||
if (!dwindle_find_leaf(*root, vis[i]))
|
|
||||||
dwindle_insert_with_config(root, vis[i], focused, ratio);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t gap_ih = enablegaps ? m->gappih : 0;
|
if (!focused && count > 0)
|
||||||
int32_t gap_iv = enablegaps ? m->gappiv : 0;
|
focused = vis[0];
|
||||||
int32_t gap_oh = enablegaps ? m->gappoh : 0;
|
|
||||||
int32_t gap_ov = enablegaps ? m->gappov : 0;
|
|
||||||
if (config.smartgaps && n == 1)
|
|
||||||
gap_ih = gap_iv = gap_oh = gap_ov = 0;
|
|
||||||
|
|
||||||
dwindle_assign(*root, m->w.x + gap_oh, m->w.y + gap_ov,
|
for (int32_t i = 0; i < count; i++) {
|
||||||
m->w.width - 2 * gap_oh, m->w.height - 2 * gap_ov, gap_ih,
|
if (!dwindle_find_leaf(*root, vis[i]))
|
||||||
gap_iv);
|
dwindle_insert_with_config(root, vis[i], focused, ratio);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t gap_ih = enablegaps ? m->gappih : 0;
|
||||||
|
int32_t gap_iv = enablegaps ? m->gappiv : 0;
|
||||||
|
int32_t gap_oh = enablegaps ? m->gappoh : 0;
|
||||||
|
int32_t gap_ov = enablegaps ? m->gappov : 0;
|
||||||
|
if (config.smartgaps && n == 1)
|
||||||
|
gap_ih = gap_iv = gap_oh = gap_ov = 0;
|
||||||
|
|
||||||
|
dwindle_assign(*root, m->w.x + gap_oh, m->w.y + gap_ov,
|
||||||
|
m->w.width - 2 * gap_oh, m->w.height - 2 * gap_ov, gap_ih,
|
||||||
|
gap_iv);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cleanup_monitor_dwindle(Monitor *m) {
|
void cleanup_monitor_dwindle(Monitor *m) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue