opt: use config.xxx instead of global presets

This commit is contained in:
tonybanters 2026-03-12 06:49:58 -07:00 committed by DreamMaoMao
parent 1fc89d01eb
commit a7461d9d5b
13 changed files with 826 additions and 997 deletions

View file

@ -309,7 +309,7 @@ void resize_tile_master_horizontal(Client *grabc, bool isdrag, int32_t offsetx,
}
if (last_apply_drap_time == 0 ||
time - last_apply_drap_time > drag_tile_refresh_interval) {
time - last_apply_drap_time > config.drag_tile_refresh_interval) {
arrange(grabc->mon, false, false);
last_apply_drap_time = time;
}
@ -478,7 +478,7 @@ void resize_tile_master_vertical(Client *grabc, bool isdrag, int32_t offsetx,
}
if (last_apply_drap_time == 0 ||
time - last_apply_drap_time > drag_tile_refresh_interval) {
time - last_apply_drap_time > config.drag_tile_refresh_interval) {
arrange(grabc->mon, false, false);
last_apply_drap_time = time;
}
@ -494,7 +494,7 @@ void resize_tile_scroller(Client *grabc, bool isdrag, int32_t offsetx,
Client *stack_head = get_scroll_stack_head(grabc);
if (grabc && grabc->mon->visible_tiling_clients == 1 &&
!scroller_ignore_proportion_single)
!config.scroller_ignore_proportion_single)
return;
if (!start_drag_window && isdrag) {
@ -670,7 +670,7 @@ void resize_tile_scroller(Client *grabc, bool isdrag, int32_t offsetx,
}
if (last_apply_drap_time == 0 ||
time - last_apply_drap_time > drag_tile_refresh_interval) {
time - last_apply_drap_time > config.drag_tile_refresh_interval) {
arrange(grabc->mon, false, false);
last_apply_drap_time = time;
}

View file

@ -7,9 +7,9 @@ void grid(Monitor *m) {
Client *c = NULL;
n = 0;
int32_t target_gappo =
enablegaps ? m->isoverview ? overviewgappo : gappoh : 0;
enablegaps ? m->isoverview ? config.overviewgappo : config.gappoh : 0;
int32_t target_gappi =
enablegaps ? m->isoverview ? overviewgappi : gappih : 0;
enablegaps ? m->isoverview ? config.overviewgappi : config.gappih : 0;
float single_width_ratio = m->isoverview ? 0.7 : 0.9;
float single_height_ratio = m->isoverview ? 0.8 : 0.9;
@ -123,9 +123,12 @@ void deck(Monitor *m) {
int32_t cur_gappoh = enablegaps ? m->gappoh : 0;
int32_t cur_gappov = enablegaps ? m->gappov : 0;
cur_gappih = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappih;
cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh;
cur_gappov = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov;
cur_gappih =
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappih;
cur_gappoh =
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh;
cur_gappov =
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov;
n = m->visible_tiling_clients;
@ -188,12 +191,15 @@ void horizontal_scroll_adjust_fullandmax(Client *c,
int32_t cur_gappoh = enablegaps ? m->gappoh : 0;
int32_t cur_gappov = enablegaps ? m->gappov : 0;
cur_gappih =
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappih;
cur_gappoh =
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappoh;
cur_gappov =
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappov;
cur_gappih = config.smartgaps && m->visible_scroll_tiling_clients == 1
? 0
: cur_gappih;
cur_gappoh = config.smartgaps && m->visible_scroll_tiling_clients == 1
? 0
: cur_gappoh;
cur_gappov = config.smartgaps && m->visible_scroll_tiling_clients == 1
? 0
: cur_gappov;
if (c->isfullscreen) {
target_geom->height = m->m.height;
@ -289,14 +295,18 @@ void scroller(Monitor *m) {
int32_t cur_gappov = enablegaps ? m->gappov : 0;
int32_t cur_gappiv = enablegaps ? m->gappiv : 0;
cur_gappih =
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappih;
cur_gappoh =
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappoh;
cur_gappov =
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappov;
cur_gappih = config.smartgaps && m->visible_scroll_tiling_clients == 1
? 0
: cur_gappih;
cur_gappoh = config.smartgaps && m->visible_scroll_tiling_clients == 1
? 0
: cur_gappoh;
cur_gappov = config.smartgaps && m->visible_scroll_tiling_clients == 1
? 0
: cur_gappov;
int32_t max_client_width = m->w.width - 2 * scroller_structs - cur_gappih;
int32_t max_client_width =
m->w.width - 2 * config.scroller_structs - cur_gappih;
n = m->visible_scroll_tiling_clients;
@ -320,13 +330,13 @@ void scroller(Monitor *m) {
}
}
if (n == 1 && !scroller_ignore_proportion_single &&
if (n == 1 && !config.scroller_ignore_proportion_single &&
!tempClients[0]->isfullscreen && !tempClients[0]->ismaximizescreen) {
c = tempClients[0];
single_proportion = c->scroller_proportion_single > 0.0f
? c->scroller_proportion_single
: scroller_default_proportion_single;
: config.scroller_default_proportion_single;
target_geom.height = m->w.height - 2 * cur_gappov;
target_geom.width = (m->w.width - 2 * cur_gappoh) * single_proportion;
@ -360,9 +370,9 @@ void scroller(Monitor *m) {
for (i = 0; i < n; i++) {
c = tempClients[i];
if (root_client == c) {
if (c->geom.x >= m->w.x + scroller_structs &&
if (c->geom.x >= m->w.x + config.scroller_structs &&
c->geom.x + c->geom.width <=
m->w.x + m->w.width - scroller_structs) {
m->w.x + m->w.width - config.scroller_structs) {
need_scroller = false;
} else {
need_scroller = true;
@ -373,7 +383,8 @@ void scroller(Monitor *m) {
}
bool need_apply_overspread =
scroller_prefer_overspread && m->visible_scroll_tiling_clients > 1 &&
config.scroller_prefer_overspread &&
m->visible_scroll_tiling_clients > 1 &&
(focus_client_index == 0 || focus_client_index == n - 1) &&
tempClients[focus_client_index]->scroller_proportion < 1.0f;
@ -403,16 +414,16 @@ void scroller(Monitor *m) {
}
bool need_apply_center =
scroller_focus_center || m->visible_scroll_tiling_clients == 1 ||
(scroller_prefer_center && !need_apply_overspread &&
config.scroller_focus_center || m->visible_scroll_tiling_clients == 1 ||
(config.scroller_prefer_center && !need_apply_overspread &&
(!m->prevsel ||
(ISSCROLLTILED(m->prevsel) &&
(m->prevsel->scroller_proportion * max_client_width) +
(tempClients[focus_client_index]->scroller_proportion *
max_client_width) >
m->w.width - 2 * scroller_structs - cur_gappih)));
m->w.width - 2 * config.scroller_structs - cur_gappih)));
if (n == 1 && scroller_ignore_proportion_single) {
if (n == 1 && config.scroller_ignore_proportion_single) {
need_scroller = true;
}
@ -439,14 +450,14 @@ void scroller(Monitor *m) {
target_geom.x = m->w.x + (m->w.width - target_geom.width) / 2;
} else if (need_apply_overspread) {
if (over_overspread_to_left) {
target_geom.x = m->w.x + scroller_structs;
target_geom.x = m->w.x + config.scroller_structs;
} else {
target_geom.x =
m->w.x +
(m->w.width -
tempClients[focus_client_index]->scroller_proportion *
max_client_width -
scroller_structs);
config.scroller_structs);
}
} else {
@ -456,8 +467,8 @@ void scroller(Monitor *m) {
tempClients[focus_client_index]
->scroller_proportion *
max_client_width -
scroller_structs)
: m->w.x + scroller_structs;
config.scroller_structs)
: m->w.x + config.scroller_structs;
}
horizontal_check_scroller_root_inside_mon(
tempClients[focus_client_index], &target_geom);
@ -522,10 +533,14 @@ void center_tile(Monitor *m) {
int32_t cur_gappoh = enablegaps ? m->gappoh : 0; // 外部水平间隙
// 智能间隙处理
cur_gappiv = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv;
cur_gappih = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappih;
cur_gappov = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov;
cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh;
cur_gappiv =
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv;
cur_gappih =
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappih;
cur_gappov =
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov;
cur_gappoh =
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh;
int32_t nmasters = m->pertag->nmasters[m->pertag->curtag];
mfact = fc->master_mfact_per > 0.0f ? fc->master_mfact_per
@ -538,7 +553,8 @@ void center_tile(Monitor *m) {
tw = mw;
// 判断是否需要主区域铺满
int32_t should_overspread = center_master_overspread && (n <= nmasters);
int32_t should_overspread =
config.center_master_overspread && (n <= nmasters);
int32_t master_surplus_height =
(m->w.height - 2 * cur_gappov - cur_gappiv * ie * (master_num - 1));
@ -564,7 +580,7 @@ void center_tile(Monitor *m) {
mx = cur_gappoh + tw + cur_gappih * ie;
} else if (n - nmasters == 1) {
// 单个堆叠窗口的处理
if (center_when_single_stack) {
if (config.center_when_single_stack) {
// stack在右边master居中左边空着
tw = (m->w.width - mw) / 2 - cur_gappoh - cur_gappih * ie;
mx = cur_gappoh + tw + cur_gappih * ie; // master居中
@ -641,7 +657,7 @@ void center_tile(Monitor *m) {
}
int32_t stack_x;
if (center_when_single_stack) {
if (config.center_when_single_stack) {
// 放在右侧master居中时stack在右边
stack_x = m->w.x + mx + mw + cur_gappih * ie;
} else {
@ -745,10 +761,14 @@ void tile(Monitor *m) {
int32_t cur_gappov = enablegaps ? m->gappov : 0;
int32_t cur_gappoh = enablegaps ? m->gappoh : 0;
cur_gappiv = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv;
cur_gappih = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappih;
cur_gappov = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov;
cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh;
cur_gappiv =
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv;
cur_gappih =
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappih;
cur_gappov =
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov;
cur_gappoh =
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh;
wl_list_for_each(fc, &clients, link) {
@ -855,10 +875,14 @@ void right_tile(Monitor *m) {
int32_t cur_gappov = enablegaps ? m->gappov : 0;
int32_t cur_gappoh = enablegaps ? m->gappoh : 0;
cur_gappiv = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv;
cur_gappih = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappih;
cur_gappov = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov;
cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh;
cur_gappiv =
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv;
cur_gappih =
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappih;
cur_gappov =
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov;
cur_gappoh =
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh;
wl_list_for_each(fc, &clients, link) {
@ -953,8 +977,10 @@ monocle(Monitor *m) {
int32_t cur_gappov = enablegaps ? m->gappov : 0;
int32_t cur_gappoh = enablegaps ? m->gappoh : 0;
cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh;
cur_gappov = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov;
cur_gappoh =
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh;
cur_gappov =
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov;
wl_list_for_each(c, &clients, link) {
if (!VISIBLEON(c, m) || !ISTILED(c))

View file

@ -19,10 +19,14 @@ void vertical_tile(Monitor *m) {
int32_t cur_gapoh = enablegaps ? m->gappoh : 0;
int32_t cur_gapov = enablegaps ? m->gappov : 0;
cur_gapih = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gapih;
cur_gapiv = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gapiv;
cur_gapoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gapoh;
cur_gapov = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gapov;
cur_gapih =
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gapih;
cur_gapiv =
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gapiv;
cur_gapoh =
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gapoh;
cur_gapov =
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gapov;
wl_list_for_each(fc, &clients, link) {
if (VISIBLEON(fc, m) && ISTILED(fc))
@ -116,9 +120,12 @@ void vertical_deck(Monitor *m) {
int32_t cur_gappoh = enablegaps ? m->gappoh : 0;
int32_t cur_gappov = enablegaps ? m->gappov : 0;
cur_gappiv = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv;
cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh;
cur_gappov = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov;
cur_gappiv =
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv;
cur_gappoh =
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh;
cur_gappov =
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov;
n = m->visible_tiling_clients;
@ -175,12 +182,15 @@ void vertical_scroll_adjust_fullandmax(Client *c, struct wlr_box *target_geom) {
int32_t cur_gappov = enablegaps ? m->gappov : 0;
int32_t cur_gappoh = enablegaps ? m->gappoh : 0;
cur_gappiv =
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappiv;
cur_gappov =
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappov;
cur_gappoh =
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappoh;
cur_gappiv = config.smartgaps && m->visible_scroll_tiling_clients == 1
? 0
: cur_gappiv;
cur_gappov = config.smartgaps && m->visible_scroll_tiling_clients == 1
? 0
: cur_gappov;
cur_gappoh = config.smartgaps && m->visible_scroll_tiling_clients == 1
? 0
: cur_gappoh;
if (c->isfullscreen) {
target_geom->width = m->m.width;
@ -276,14 +286,18 @@ void vertical_scroller(Monitor *m) {
int32_t cur_gappoh = enablegaps ? m->gappoh : 0;
int32_t cur_gappih = enablegaps ? m->gappih : 0;
cur_gappiv =
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappiv;
cur_gappov =
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappov;
cur_gappoh =
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappoh;
cur_gappiv = config.smartgaps && m->visible_scroll_tiling_clients == 1
? 0
: cur_gappiv;
cur_gappov = config.smartgaps && m->visible_scroll_tiling_clients == 1
? 0
: cur_gappov;
cur_gappoh = config.smartgaps && m->visible_scroll_tiling_clients == 1
? 0
: cur_gappoh;
int32_t max_client_height = m->w.height - 2 * scroller_structs - cur_gappiv;
int32_t max_client_height =
m->w.height - 2 * config.scroller_structs - cur_gappiv;
n = m->visible_scroll_tiling_clients;
@ -304,13 +318,13 @@ void vertical_scroller(Monitor *m) {
}
}
if (n == 1 && !scroller_ignore_proportion_single &&
if (n == 1 && !config.scroller_ignore_proportion_single &&
!tempClients[0]->isfullscreen && !tempClients[0]->ismaximizescreen) {
c = tempClients[0];
single_proportion = c->scroller_proportion_single > 0.0f
? c->scroller_proportion_single
: scroller_default_proportion_single;
: config.scroller_default_proportion_single;
target_geom.width = m->w.width - 2 * cur_gappoh;
target_geom.height = (m->w.height - 2 * cur_gappov) * single_proportion;
@ -344,9 +358,9 @@ void vertical_scroller(Monitor *m) {
for (i = 0; i < n; i++) {
c = tempClients[i];
if (root_client == c) {
if (c->geom.y >= m->w.y + scroller_structs &&
if (c->geom.y >= m->w.y + config.scroller_structs &&
c->geom.y + c->geom.height <=
m->w.y + m->w.height - scroller_structs) {
m->w.y + m->w.height - config.scroller_structs) {
need_scroller = false;
} else {
need_scroller = true;
@ -357,7 +371,8 @@ void vertical_scroller(Monitor *m) {
}
bool need_apply_overspread =
scroller_prefer_overspread && m->visible_scroll_tiling_clients > 1 &&
config.scroller_prefer_overspread &&
m->visible_scroll_tiling_clients > 1 &&
(focus_client_index == 0 || focus_client_index == n - 1) &&
tempClients[focus_client_index]->scroller_proportion < 1.0f;
@ -387,16 +402,16 @@ void vertical_scroller(Monitor *m) {
}
bool need_apply_center =
scroller_focus_center || m->visible_scroll_tiling_clients == 1 ||
(scroller_prefer_center && !need_apply_overspread &&
config.scroller_focus_center || m->visible_scroll_tiling_clients == 1 ||
(config.scroller_prefer_center && !need_apply_overspread &&
(!m->prevsel ||
(ISSCROLLTILED(m->prevsel) &&
(m->prevsel->scroller_proportion * max_client_height) +
(tempClients[focus_client_index]->scroller_proportion *
max_client_height) >
m->w.height - 2 * scroller_structs - cur_gappiv)));
m->w.height - 2 * config.scroller_structs - cur_gappiv)));
if (n == 1 && scroller_ignore_proportion_single) {
if (n == 1 && config.scroller_ignore_proportion_single) {
need_scroller = true;
}
@ -426,14 +441,14 @@ void vertical_scroller(Monitor *m) {
target_geom.y = m->w.y + (m->w.height - target_geom.height) / 2;
} else if (need_apply_overspread) {
if (over_overspread_to_up) {
target_geom.y = m->w.y + scroller_structs;
target_geom.y = m->w.y + config.scroller_structs;
} else {
target_geom.y =
m->w.y +
(m->w.height -
tempClients[focus_client_index]->scroller_proportion *
max_client_height -
scroller_structs);
config.scroller_structs);
}
} else {
target_geom.y = root_client->geom.y > m->w.y + (m->w.height) / 2
@ -441,8 +456,8 @@ void vertical_scroller(Monitor *m) {
tempClients[focus_client_index]
->scroller_proportion *
max_client_height -
scroller_structs)
: m->w.y + scroller_structs;
config.scroller_structs)
: m->w.y + config.scroller_structs;
}
vertical_check_scroller_root_inside_mon(tempClients[focus_client_index],
&target_geom);
@ -486,9 +501,9 @@ void vertical_grid(Monitor *m) {
int32_t rows, cols, overrows;
Client *c = NULL;
int32_t target_gappo =
enablegaps ? m->isoverview ? overviewgappo : gappov : 0;
enablegaps ? m->isoverview ? config.overviewgappo : config.gappov : 0;
int32_t target_gappi =
enablegaps ? m->isoverview ? overviewgappi : gappiv : 0;
enablegaps ? m->isoverview ? config.overviewgappi : config.gappiv : 0;
float single_width_ratio = m->isoverview ? 0.7 : 0.9;
float single_height_ratio = m->isoverview ? 0.8 : 0.9;