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

@ -380,10 +380,10 @@ void client_draw_shadow(Client *c) {
top_offset = GEZERO(c->mon->m.y - absolute_shadow_box.y);
}
left_offset = MIN(left_offset, shadow_box.width);
right_offset = MIN(right_offset, shadow_box.width);
top_offset = MIN(top_offset, shadow_box.height);
bottom_offset = MIN(bottom_offset, shadow_box.height);
left_offset = MANGO_MIN(left_offset, shadow_box.width);
right_offset = MANGO_MIN(right_offset, shadow_box.width);
top_offset = MANGO_MIN(top_offset, shadow_box.height);
bottom_offset = MANGO_MIN(bottom_offset, shadow_box.height);
wlr_scene_node_set_position(&c->shadow->node, shadow_box.x + left_offset,
shadow_box.y + top_offset);
@ -577,12 +577,12 @@ void apply_border(Client *c) {
if (right_offset > 0) {
inner_surface_width =
MIN(clip_box.width, inner_surface_width + right_offset);
MANGO_MIN(clip_box.width, inner_surface_width + right_offset);
}
if (bottom_offset > 0) {
inner_surface_height =
MIN(clip_box.height, inner_surface_height + bottom_offset);
MANGO_MIN(clip_box.height, inner_surface_height + bottom_offset);
}
struct clipped_region clipped_region = {
@ -1010,7 +1010,7 @@ void fadeout_client_animation_next_tick(Client *c) {
double percent = config.fadeout_begin_opacity -
(opacity_eased_progress * config.fadeout_begin_opacity);
double opacity = MAX(percent, 0);
double opacity = MANGO_MAX(percent, 0);
if (config.animation_fade_out && !c->nofadeout)
wlr_scene_node_for_each_buffer(&c->scene->node,
@ -1285,8 +1285,8 @@ void resize(Client *c, struct wlr_box geo, int32_t interact) {
if (is_scroller_layout(c->mon) && (!c->isfloating || c == grabc)) {
c->geom = geo;
c->geom.width = MAX(1 + 2 * (int32_t)c->bw, c->geom.width);
c->geom.height = MAX(1 + 2 * (int32_t)c->bw, c->geom.height);
c->geom.width = MANGO_MAX(1 + 2 * (int32_t)c->bw, c->geom.width);
c->geom.height = MANGO_MAX(1 + 2 * (int32_t)c->bw, c->geom.height);
} else { // 这里会限制不允许窗口划出屏幕
c->geom = geo;
applybounds(

View file

@ -279,7 +279,7 @@ void fadeout_layer_animation_next_tick(LayerSurface *l) {
double percent = config.fadeout_begin_opacity -
(opacity_eased_progress * config.fadeout_begin_opacity);
double opacity = MAX(percent, 0.0f);
double opacity = MANGO_MAX(percent, 0.0f);
if (config.animation_fade_out)
wlr_scene_node_for_each_buffer(&l->scene->node,
@ -323,10 +323,10 @@ void layer_animation_next_tick(LayerSurface *l) {
double opacity_eased_progress =
find_animation_curve_at(animation_passed, OPAFADEIN);
double opacity =
MIN(config.fadein_begin_opacity +
opacity_eased_progress * (1.0 - config.fadein_begin_opacity),
1.0f);
double opacity = MANGO_MIN(config.fadein_begin_opacity +
opacity_eased_progress *
(1.0 - config.fadein_begin_opacity),
1.0f);
if (config.animation_fade_in)
wlr_scene_node_for_each_buffer(&l->scene->node,

View file

@ -23,23 +23,23 @@ void set_tagin_animation(Monitor *m, Client *c) {
c->animainit_geom.x = config.tag_animation_direction == VERTICAL
? c->animation.current.x
: MAX(c->mon->m.x + c->mon->m.width,
c->geom.x + c->mon->m.width);
: MANGO_MAX(c->mon->m.x + c->mon->m.width,
c->geom.x + c->mon->m.width);
c->animainit_geom.y = config.tag_animation_direction == VERTICAL
? MAX(c->mon->m.y + c->mon->m.height,
c->geom.y + c->mon->m.height)
? MANGO_MAX(c->mon->m.y + c->mon->m.height,
c->geom.y + c->mon->m.height)
: c->animation.current.y;
} else {
c->animainit_geom.x =
config.tag_animation_direction == VERTICAL
? c->animation.current.x
: MIN(m->m.x - c->geom.width, c->geom.x - c->mon->m.width);
c->animainit_geom.y =
config.tag_animation_direction == VERTICAL
? MIN(m->m.y - c->geom.height, c->geom.y - c->mon->m.height)
: c->animation.current.y;
c->animainit_geom.x = config.tag_animation_direction == VERTICAL
? c->animation.current.x
: MANGO_MIN(m->m.x - c->geom.width,
c->geom.x - c->mon->m.width);
c->animainit_geom.y = config.tag_animation_direction == VERTICAL
? MANGO_MIN(m->m.y - c->geom.height,
c->geom.y - c->mon->m.height)
: c->animation.current.y;
}
}
@ -84,13 +84,13 @@ void set_tagout_animation(Monitor *m, Client *c) {
: m->pertag->curtag > m->pertag->prevtag;
if (going_forward) {
c->pending = c->geom;
c->pending.x =
config.tag_animation_direction == VERTICAL
? c->animation.current.x
: MIN(c->mon->m.x - c->geom.width, c->geom.x - c->mon->m.width);
c->pending.x = config.tag_animation_direction == VERTICAL
? c->animation.current.x
: MANGO_MIN(c->mon->m.x - c->geom.width,
c->geom.x - c->mon->m.width);
c->pending.y = config.tag_animation_direction == VERTICAL
? MIN(c->mon->m.y - c->geom.height,
c->geom.y - c->mon->m.height)
? MANGO_MIN(c->mon->m.y - c->geom.height,
c->geom.y - c->mon->m.height)
: c->animation.current.y;
resize(c, c->geom, 0);
@ -98,11 +98,11 @@ void set_tagout_animation(Monitor *m, Client *c) {
c->pending = c->geom;
c->pending.x = config.tag_animation_direction == VERTICAL
? c->animation.current.x
: MAX(c->mon->m.x + c->mon->m.width,
c->geom.x + c->mon->m.width);
: MANGO_MAX(c->mon->m.x + c->mon->m.width,
c->geom.x + c->mon->m.width);
c->pending.y = config.tag_animation_direction == VERTICAL
? MAX(c->mon->m.y + c->mon->m.height,
c->geom.y + c->mon->m.height)
? MANGO_MAX(c->mon->m.y + c->mon->m.height,
c->geom.y + c->mon->m.height)
: c->animation.current.y;
resize(c, c->geom, 0);
}