opt: Reduce unnecessary text drawing

This commit is contained in:
DreamMaoMao 2026-06-17 08:35:44 +08:00
parent a515ad9b91
commit a7acc7f5f3
10 changed files with 308 additions and 194 deletions

View file

@ -264,7 +264,7 @@ int32_t incnmaster(const Arg *arg) {
if (!arg || !selmon)
return 0;
selmon->pertag->nmasters[selmon->pertag->curtag] =
MAX(selmon->pertag->nmasters[selmon->pertag->curtag] + arg->i, 0);
MANGO_MAX(selmon->pertag->nmasters[selmon->pertag->curtag] + arg->i, 0);
arrange(selmon, false, false);
return 0;
}
@ -736,12 +736,12 @@ int32_t smartmovewin(const Arg *arg) {
continue;
buttom = tc->geom.y + tc->geom.height + config.gappiv;
if (top > buttom && ny < buttom) {
tar = MAX(tar, buttom);
tar = MANGO_MAX(tar, buttom);
};
}
ny = tar == -99999 ? ny : tar;
ny = MAX(ny, c->mon->w.y + c->mon->gappov);
ny = MANGO_MAX(ny, c->mon->w.y + c->mon->gappov);
break;
case DOWN:
tar = 99999;
@ -756,12 +756,12 @@ int32_t smartmovewin(const Arg *arg) {
continue;
top = tc->geom.y - config.gappiv;
if (buttom < top && (ny + c->geom.height) > top) {
tar = MIN(tar, top - c->geom.height);
tar = MANGO_MIN(tar, top - c->geom.height);
};
}
ny = tar == 99999 ? ny : tar;
ny = MIN(ny, c->mon->w.y + c->mon->w.height - c->geom.height -
c->mon->gappov);
ny = MANGO_MIN(ny, c->mon->w.y + c->mon->w.height - c->geom.height -
c->mon->gappov);
break;
case LEFT:
tar = -99999;
@ -776,12 +776,12 @@ int32_t smartmovewin(const Arg *arg) {
continue;
right = tc->geom.x + tc->geom.width + config.gappih;
if (left > right && nx < right) {
tar = MAX(tar, right);
tar = MANGO_MAX(tar, right);
};
}
nx = tar == -99999 ? nx : tar;
nx = MAX(nx, c->mon->w.x + c->mon->gappoh);
nx = MANGO_MAX(nx, c->mon->w.x + c->mon->gappoh);
break;
case RIGHT:
tar = 99999;
@ -795,12 +795,12 @@ int32_t smartmovewin(const Arg *arg) {
continue;
left = tc->geom.x - config.gappih;
if (right < left && (nx + c->geom.width) > left) {
tar = MIN(tar, left - c->geom.width);
tar = MANGO_MIN(tar, left - c->geom.width);
};
}
nx = tar == 99999 ? nx : tar;
nx = MIN(nx, c->mon->w.x + c->mon->w.width - c->geom.width -
c->mon->gappoh);
nx = MANGO_MIN(nx, c->mon->w.x + c->mon->w.width - c->geom.width -
c->mon->gappoh);
break;
}
@ -828,7 +828,7 @@ int32_t smartresizewin(const Arg *arg) {
switch (arg->i) {
case UP:
nh -= selmon->w.height / 8;
nh = MAX(nh, selmon->w.height / 10);
nh = MANGO_MAX(nh, selmon->w.height / 10);
break;
case DOWN:
tar = -99999;
@ -843,7 +843,7 @@ int32_t smartresizewin(const Arg *arg) {
continue;
top = tc->geom.y - config.gappiv;
if (buttom < top && (nh + c->geom.y) > top) {
tar = MAX(tar, top - c->geom.y);
tar = MANGO_MAX(tar, top - c->geom.y);
};
}
nh = tar == -99999 ? nh : tar;
@ -852,7 +852,7 @@ int32_t smartresizewin(const Arg *arg) {
break;
case LEFT:
nw -= selmon->w.width / 16;
nw = MAX(nw, selmon->w.width / 10);
nw = MANGO_MAX(nw, selmon->w.width / 10);
break;
case RIGHT:
tar = 99999;
@ -866,7 +866,7 @@ int32_t smartresizewin(const Arg *arg) {
continue;
left = tc->geom.x - config.gappih;
if (right < left && (nw + c->geom.x) > left) {
tar = MIN(tar, left - c->geom.x);
tar = MANGO_MIN(tar, left - c->geom.x);
};
}
@ -1063,7 +1063,7 @@ int32_t switch_layout(const Arg *arg) {
if (config.circle_layout_count != 0) {
for (jk = 0; jk < config.circle_layout_count; jk++) {
len = MAX(
len = MANGO_MAX(
strlen(config.circle_layout[jk]),
strlen(selmon->pertag->ltidxs[selmon->pertag->curtag]->name));
@ -1082,7 +1082,8 @@ int32_t switch_layout(const Arg *arg) {
}
for (ji = 0; ji < LENGTH(layouts); ji++) {
len = MAX(strlen(layouts[ji].name), strlen(target_layout_name));
len =
MANGO_MAX(strlen(layouts[ji].name), strlen(target_layout_name));
if (strncmp(layouts[ji].name, target_layout_name, len) == 0) {
selmon->pertag->ltidxs[selmon->pertag->curtag] = &layouts[ji];