opt: use int instaead of uint in layout code

This commit is contained in:
DreamMaoMao
2026-01-03 10:38:42 +08:00
parent 2771053ee6
commit d2894f0bab
2 changed files with 66 additions and 67 deletions

View File

@@ -1,9 +1,9 @@
// 网格布局窗口大小和位置计算
void grid(Monitor *m) {
uint32_t i, n;
uint32_t cx, cy, cw, ch;
uint32_t dx;
uint32_t cols, rows, overcols;
int32_t i, n;
int32_t cx, cy, cw, ch;
int32_t dx;
int32_t cols, rows, overcols;
Client *c = NULL;
n = 0;
int32_t target_gappo =
@@ -112,15 +112,15 @@ void grid(Monitor *m) {
}
void deck(Monitor *m) {
uint32_t mw, my;
int32_t mw, my;
int32_t i, n = 0;
Client *c = NULL;
Client *fc = NULL;
float mfact;
uint32_t cur_gappih = enablegaps ? m->gappih : 0;
uint32_t cur_gappoh = enablegaps ? m->gappoh : 0;
uint32_t cur_gappov = enablegaps ? m->gappov : 0;
int32_t cur_gappih = enablegaps ? m->gappih : 0;
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;
@@ -183,9 +183,9 @@ void deck(Monitor *m) {
void horizontal_scroll_adjust_fullandmax(Client *c,
struct wlr_box *target_geom) {
Monitor *m = c->mon;
uint32_t cur_gappih = enablegaps ? m->gappih : 0;
uint32_t cur_gappoh = enablegaps ? m->gappoh : 0;
uint32_t cur_gappov = enablegaps ? m->gappov : 0;
int32_t cur_gappih = enablegaps ? m->gappih : 0;
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;
@@ -214,7 +214,7 @@ void horizontal_scroll_adjust_fullandmax(Client *c,
// 滚动布局
void scroller(Monitor *m) {
uint32_t i, n, j;
int32_t i, n, j;
float single_proportion = 1.0;
Client *c = NULL, *root_client = NULL;
@@ -222,9 +222,9 @@ void scroller(Monitor *m) {
struct wlr_box target_geom;
int32_t focus_client_index = 0;
bool need_scroller = false;
uint32_t cur_gappih = enablegaps ? m->gappih : 0;
uint32_t cur_gappoh = enablegaps ? m->gappoh : 0;
uint32_t cur_gappov = enablegaps ? m->gappov : 0;
int32_t cur_gappih = enablegaps ? m->gappih : 0;
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;
@@ -233,7 +233,7 @@ void scroller(Monitor *m) {
cur_gappov =
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappov;
uint32_t max_client_width = m->w.width - 2 * scroller_structs - cur_gappih;
int32_t max_client_width = m->w.width - 2 * scroller_structs - cur_gappih;
n = m->visible_scroll_tiling_clients;
@@ -368,7 +368,7 @@ void scroller(Monitor *m) {
}
void center_tile(Monitor *m) {
uint32_t i, n = 0, h, r, ie = enablegaps, mw, mx, my, oty, ety, tw;
int32_t i, n = 0, h, r, ie = enablegaps, mw, mx, my, oty, ety, tw;
Client *c = NULL;
Client *fc = NULL;
double mfact = 0;
@@ -391,10 +391,10 @@ void center_tile(Monitor *m) {
}
// 间隙参数处理
uint32_t cur_gappiv = enablegaps ? m->gappiv : 0; // 内部垂直间隙
uint32_t cur_gappih = enablegaps ? m->gappih : 0; // 内部水平间隙
uint32_t cur_gappov = enablegaps ? m->gappov : 0; // 外部垂直间隙
uint32_t cur_gappoh = enablegaps ? m->gappoh : 0; // 外部水平间隙
int32_t cur_gappiv = enablegaps ? m->gappiv : 0; // 内部垂直间隙
int32_t cur_gappih = enablegaps ? m->gappih : 0; // 内部水平间隙
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;
@@ -402,7 +402,7 @@ void center_tile(Monitor *m) {
cur_gappov = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov;
cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh;
uint32_t nmasters = m->pertag->nmasters[m->pertag->curtag];
int32_t nmasters = m->pertag->nmasters[m->pertag->curtag];
mfact = fc->master_mfact_per > 0.0f ? fc->master_mfact_per
: m->pertag->mfacts[m->pertag->curtag];
@@ -415,15 +415,15 @@ void center_tile(Monitor *m) {
// 判断是否需要主区域铺满
int32_t should_overspread = center_master_overspread && (n <= nmasters);
uint32_t master_surplus_height =
int32_t master_surplus_height =
(m->w.height - 2 * cur_gappov - cur_gappiv * ie * (master_num - 1));
float master_surplus_ratio = 1.0;
uint32_t slave_left_surplus_height =
int32_t slave_left_surplus_height =
(m->w.height - 2 * cur_gappov - cur_gappiv * ie * (stack_num / 2 - 1));
float slave_left_surplus_ratio = 1.0;
uint32_t slave_right_surplus_height =
int32_t slave_right_surplus_height =
(m->w.height - 2 * cur_gappov -
cur_gappiv * ie * ((stack_num + 1) / 2 - 1));
float slave_right_surplus_ratio = 1.0;
@@ -496,7 +496,7 @@ void center_tile(Monitor *m) {
my += c->geom.height + cur_gappiv * ie;
} else {
// 堆叠区域窗口
uint32_t stack_index = i - nmasters;
int32_t stack_index = i - nmasters;
if (n - nmasters == 1) {
// 单个堆叠窗口
@@ -600,7 +600,7 @@ void center_tile(Monitor *m) {
}
void tile(Monitor *m) {
uint32_t i, n = 0, h, r, ie = enablegaps, mw, my, ty;
int32_t i, n = 0, h, r, ie = enablegaps, mw, my, ty;
Client *c = NULL;
Client *fc = NULL;
double mfact = 0;
@@ -615,10 +615,10 @@ void tile(Monitor *m) {
if (n == 0)
return;
uint32_t cur_gappiv = enablegaps ? m->gappiv : 0;
uint32_t cur_gappih = enablegaps ? m->gappih : 0;
uint32_t cur_gappov = enablegaps ? m->gappov : 0;
uint32_t cur_gappoh = enablegaps ? m->gappoh : 0;
int32_t cur_gappiv = enablegaps ? m->gappiv : 0;
int32_t cur_gappih = enablegaps ? m->gappih : 0;
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;
@@ -643,11 +643,11 @@ void tile(Monitor *m) {
i = 0;
my = ty = cur_gappov;
uint32_t master_surplus_height =
int32_t master_surplus_height =
(m->w.height - 2 * cur_gappov - cur_gappiv * ie * (master_num - 1));
float master_surplus_ratio = 1.0;
uint32_t slave_surplus_height =
int32_t slave_surplus_height =
(m->w.height - 2 * cur_gappov - cur_gappiv * ie * (stack_num - 1));
float slave_surplus_ratio = 1.0;
@@ -710,7 +710,7 @@ void tile(Monitor *m) {
}
void right_tile(Monitor *m) {
uint32_t i, n = 0, h, r, ie = enablegaps, mw, my, ty;
int32_t i, n = 0, h, r, ie = enablegaps, mw, my, ty;
Client *c = NULL;
Client *fc = NULL;
double mfact = 0;
@@ -725,10 +725,10 @@ void right_tile(Monitor *m) {
if (n == 0)
return;
uint32_t cur_gappiv = enablegaps ? m->gappiv : 0;
uint32_t cur_gappih = enablegaps ? m->gappih : 0;
uint32_t cur_gappov = enablegaps ? m->gappov : 0;
uint32_t cur_gappoh = enablegaps ? m->gappoh : 0;
int32_t cur_gappiv = enablegaps ? m->gappiv : 0;
int32_t cur_gappih = enablegaps ? m->gappih : 0;
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;
@@ -753,11 +753,11 @@ void right_tile(Monitor *m) {
i = 0;
my = ty = cur_gappov;
uint32_t master_surplus_height =
int32_t master_surplus_height =
(m->w.height - 2 * cur_gappov - cur_gappiv * ie * (master_num - 1));
float master_surplus_ratio = 1.0;
uint32_t slave_surplus_height =
int32_t slave_surplus_height =
(m->w.height - 2 * cur_gappov - cur_gappiv * ie * (stack_num - 1));
float slave_surplus_ratio = 1.0;
@@ -825,8 +825,8 @@ monocle(Monitor *m) {
Client *c = NULL;
struct wlr_box geom;
uint32_t cur_gappov = enablegaps ? m->gappov : 0;
uint32_t cur_gappoh = enablegaps ? m->gappoh : 0;
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;
@@ -845,7 +845,7 @@ monocle(Monitor *m) {
}
void tgmix(Monitor *m) {
uint32_t n = m->visible_tiling_clients;
int32_t n = m->visible_tiling_clients;
if (n <= 3) {
tile(m);
return;

View File

@@ -1,5 +1,5 @@
void vertical_tile(Monitor *m) {
uint32_t i, n = 0, w, r, ie = enablegaps, mh, mx, tx;
int32_t i, n = 0, w, r, ie = enablegaps, mh, mx, tx;
Client *c = NULL;
Client *fc = NULL;
double mfact = 0;
@@ -14,10 +14,10 @@ void vertical_tile(Monitor *m) {
if (n == 0)
return;
uint32_t cur_gapih = enablegaps ? m->gappih : 0;
uint32_t cur_gapiv = enablegaps ? m->gappiv : 0;
uint32_t cur_gapoh = enablegaps ? m->gappoh : 0;
uint32_t cur_gapov = enablegaps ? m->gappov : 0;
int32_t cur_gapih = enablegaps ? m->gappih : 0;
int32_t cur_gapiv = enablegaps ? m->gappiv : 0;
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;
@@ -42,11 +42,11 @@ void vertical_tile(Monitor *m) {
i = 0;
mx = tx = cur_gapoh;
uint32_t master_surplus_width =
int32_t master_surplus_width =
(m->w.width - 2 * cur_gapoh - cur_gapih * ie * (master_num - 1));
float master_surplus_ratio = 1.0;
uint32_t slave_surplus_width =
int32_t slave_surplus_width =
(m->w.width - 2 * cur_gapoh - cur_gapih * ie * (stack_num - 1));
float slave_surplus_ratio = 1.0;
@@ -105,15 +105,15 @@ void vertical_tile(Monitor *m) {
}
void vertical_deck(Monitor *m) {
uint32_t mh, mx;
int32_t mh, mx;
int32_t i, n = 0;
Client *c = NULL;
Client *fc = NULL;
float mfact;
uint32_t cur_gappiv = enablegaps ? m->gappiv : 0;
uint32_t cur_gappoh = enablegaps ? m->gappoh : 0;
uint32_t cur_gappov = enablegaps ? m->gappov : 0;
int32_t cur_gappiv = enablegaps ? m->gappiv : 0;
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;
@@ -170,9 +170,9 @@ void vertical_deck(Monitor *m) {
void vertical_scroll_adjust_fullandmax(Client *c, struct wlr_box *target_geom) {
Monitor *m = c->mon;
uint32_t cur_gappiv = enablegaps ? m->gappiv : 0;
uint32_t cur_gappov = enablegaps ? m->gappov : 0;
uint32_t cur_gappoh = enablegaps ? m->gappoh : 0;
int32_t cur_gappiv = enablegaps ? m->gappiv : 0;
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;
@@ -201,7 +201,7 @@ void vertical_scroll_adjust_fullandmax(Client *c, struct wlr_box *target_geom) {
// 竖屏滚动布局
void vertical_scroller(Monitor *m) {
uint32_t i, n, j;
int32_t i, n, j;
float single_proportion = 1.0;
Client *c = NULL, *root_client = NULL;
@@ -209,9 +209,9 @@ void vertical_scroller(Monitor *m) {
struct wlr_box target_geom;
int32_t focus_client_index = 0;
bool need_scroller = false;
uint32_t cur_gappiv = enablegaps ? m->gappiv : 0;
uint32_t cur_gappov = enablegaps ? m->gappov : 0;
uint32_t cur_gappoh = enablegaps ? m->gappoh : 0;
int32_t cur_gappiv = enablegaps ? m->gappiv : 0;
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;
@@ -220,8 +220,7 @@ void vertical_scroller(Monitor *m) {
cur_gappoh =
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappoh;
uint32_t max_client_height =
m->w.height - 2 * scroller_structs - cur_gappiv;
int32_t max_client_height = m->w.height - 2 * scroller_structs - cur_gappiv;
n = m->visible_scroll_tiling_clients;
@@ -354,10 +353,10 @@ void vertical_scroller(Monitor *m) {
}
void vertical_grid(Monitor *m) {
uint32_t i, n;
uint32_t cx, cy, cw, ch;
uint32_t dy;
uint32_t rows, cols, overrows;
int32_t i, n;
int32_t cx, cy, cw, ch;
int32_t dy;
int32_t rows, cols, overrows;
Client *c = NULL;
int32_t target_gappo =
enablegaps ? m->isoverview ? overviewgappo : gappov : 0;