mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2025-10-29 05:40:21 -04:00
opt: Reduce unnecessary layout calculations
This commit is contained in:
parent
d32dde4d98
commit
a875fbd060
2 changed files with 23 additions and 44 deletions
|
|
@ -11,8 +11,7 @@ void fibonacci(Monitor *mon, int s) {
|
|||
cur_gappoh = smartgaps && mon->visible_tiling_clients == 1 ? 0 : cur_gappoh;
|
||||
cur_gappov = smartgaps && mon->visible_tiling_clients == 1 ? 0 : cur_gappov;
|
||||
// Count visible clients
|
||||
wl_list_for_each(c, &clients, link) if (VISIBLEON(c, mon) && ISTILED(c))
|
||||
n++;
|
||||
n = mon->visible_tiling_clients;
|
||||
|
||||
if (n == 0)
|
||||
return;
|
||||
|
|
@ -133,13 +132,7 @@ void grid(Monitor *m) {
|
|||
Client *c;
|
||||
n = 0;
|
||||
|
||||
// 第一次遍历,计算 n 的值
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (VISIBLEON(c, m) && !c->isunglobal &&
|
||||
((m->isoverview && !client_should_ignore_focus(c)) || ISTILED(c))) {
|
||||
n++;
|
||||
}
|
||||
}
|
||||
n = m->isoverview ? m->visible_clients : m->visible_tiling_clients;
|
||||
|
||||
if (n == 0) {
|
||||
return; // 没有需要处理的客户端,直接返回
|
||||
|
|
@ -252,7 +245,8 @@ void deck(Monitor *m) {
|
|||
cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh;
|
||||
cur_gappov = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov;
|
||||
|
||||
wl_list_for_each(c, &clients, link) if (VISIBLEON(c, m) && ISTILED(c)) n++;
|
||||
n = m->visible_tiling_clients;
|
||||
|
||||
if (n == 0)
|
||||
return;
|
||||
|
||||
|
|
@ -298,11 +292,10 @@ void deck(Monitor *m) {
|
|||
|
||||
// 滚动布局
|
||||
void scroller(Monitor *m) {
|
||||
unsigned int i, n;
|
||||
unsigned int i, n, j;
|
||||
|
||||
Client *c, *root_client = NULL;
|
||||
Client **tempClients = NULL; // 初始化为 NULL
|
||||
n = 0;
|
||||
struct wlr_box target_geom;
|
||||
int focus_client_index = 0;
|
||||
bool need_scroller = false;
|
||||
|
|
@ -317,12 +310,7 @@ void scroller(Monitor *m) {
|
|||
unsigned int max_client_width =
|
||||
m->w.width - 2 * scroller_structs - cur_gappih;
|
||||
|
||||
// 第一次遍历,计算 n 的值
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (VISIBLEON(c, m) && ISTILED(c)) {
|
||||
n++;
|
||||
}
|
||||
}
|
||||
n = m->visible_tiling_clients;
|
||||
|
||||
if (n == 0) {
|
||||
return; // 没有需要处理的客户端,直接返回
|
||||
|
|
@ -336,11 +324,11 @@ void scroller(Monitor *m) {
|
|||
}
|
||||
|
||||
// 第二次遍历,填充 tempClients
|
||||
n = 0;
|
||||
j = 0;
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (VISIBLEON(c, m) && ISTILED(c)) {
|
||||
tempClients[n] = c;
|
||||
n++;
|
||||
tempClients[j] = c;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -436,7 +424,8 @@ void tile(Monitor *m) {
|
|||
unsigned int i, n = 0, h, r, ie = enablegaps, mw, my, ty;
|
||||
Client *c;
|
||||
|
||||
wl_list_for_each(c, &clients, link) if (VISIBLEON(c, m) && ISTILED(c)) n++;
|
||||
n = m->visible_tiling_clients;
|
||||
|
||||
if (n == 0)
|
||||
return;
|
||||
|
||||
|
|
|
|||
|
|
@ -10,9 +10,8 @@ void vertical_fibonacci(Monitor *mon, int s) {
|
|||
cur_gappiv = smartgaps && mon->visible_tiling_clients == 1 ? 0 : cur_gappiv;
|
||||
cur_gappoh = smartgaps && mon->visible_tiling_clients == 1 ? 0 : cur_gappoh;
|
||||
cur_gappov = smartgaps && mon->visible_tiling_clients == 1 ? 0 : cur_gappov;
|
||||
// Count visible clients
|
||||
wl_list_for_each(c, &clients, link) if (VISIBLEON(c, mon) && ISTILED(c))
|
||||
n++;
|
||||
|
||||
n = mon->visible_tiling_clients;
|
||||
|
||||
if (n == 0)
|
||||
return;
|
||||
|
|
@ -130,14 +129,8 @@ void vertical_grid(Monitor *m) {
|
|||
unsigned int dy;
|
||||
unsigned int rows, cols, overrows;
|
||||
Client *c;
|
||||
n = 0;
|
||||
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (VISIBLEON(c, m) && !c->isunglobal &&
|
||||
((m->isoverview && !client_should_ignore_focus(c)) || ISTILED(c))) {
|
||||
n++;
|
||||
}
|
||||
}
|
||||
n = m->isoverview ? m->visible_clients : m->visible_tiling_clients;
|
||||
|
||||
if (n == 0) {
|
||||
return;
|
||||
|
|
@ -247,7 +240,8 @@ void vertical_deck(Monitor *m) {
|
|||
cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh;
|
||||
cur_gappov = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov;
|
||||
|
||||
wl_list_for_each(c, &clients, link) if (VISIBLEON(c, m) && ISTILED(c)) n++;
|
||||
n = m->visible_tiling_clients;
|
||||
|
||||
if (n == 0)
|
||||
return;
|
||||
|
||||
|
|
@ -288,10 +282,9 @@ void vertical_deck(Monitor *m) {
|
|||
}
|
||||
|
||||
void vertical_scroller(Monitor *m) {
|
||||
unsigned int i, n;
|
||||
unsigned int i, n, j;
|
||||
Client *c, *root_client = NULL;
|
||||
Client **tempClients = NULL;
|
||||
n = 0;
|
||||
struct wlr_box target_geom;
|
||||
int focus_client_index = 0;
|
||||
bool need_scroller = false;
|
||||
|
|
@ -306,11 +299,7 @@ void vertical_scroller(Monitor *m) {
|
|||
unsigned int max_client_height =
|
||||
m->w.height - 2 * scroller_structs - cur_gappiv;
|
||||
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (VISIBLEON(c, m) && ISTILED(c)) {
|
||||
n++;
|
||||
}
|
||||
}
|
||||
n = m->visible_tiling_clients;
|
||||
|
||||
if (n == 0) {
|
||||
return;
|
||||
|
|
@ -321,11 +310,11 @@ void vertical_scroller(Monitor *m) {
|
|||
return;
|
||||
}
|
||||
|
||||
n = 0;
|
||||
j = 0;
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (VISIBLEON(c, m) && ISTILED(c)) {
|
||||
tempClients[n] = c;
|
||||
n++;
|
||||
tempClients[j] = c;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -421,7 +410,8 @@ void vertical_tile(Monitor *m) {
|
|||
unsigned int i, n = 0, w, r, ie = enablegaps, mh, mx, tx;
|
||||
Client *c;
|
||||
|
||||
wl_list_for_each(c, &clients, link) if (VISIBLEON(c, m) && ISTILED(c)) n++;
|
||||
n = m->visible_tiling_clients;
|
||||
|
||||
if (n == 0)
|
||||
return;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue