From 0fbb788e456e25360fc6ec2b9f359a20a8311e49 Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Sat, 12 Jul 2025 10:03:52 +0800 Subject: [PATCH] feat: support animaiton type none --- src/animation/client.h | 27 +++++++++++++++++++-------- src/animation/layer.h | 21 +++++++++++++++++++++ 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/animation/client.h b/src/animation/client.h index cbe6529..9d21d3f 100644 --- a/src/animation/client.h +++ b/src/animation/client.h @@ -383,7 +383,7 @@ void client_apply_clip(Client *c) { int bw = (int)c->bw; - if (!animations) { + if (!animations || !c->animation.running) { c->animation.running = false; c->need_output_flush = false; c->animainit_geom = c->current = c->pending = c->animation.current = @@ -604,8 +604,10 @@ void init_fadeout_client(Client *c) { return; } - if (c->animation_type_close && - strcmp(c->animation_type_close, "none") == 0) { + if ((c->animation_type_close && + strcmp(c->animation_type_close, "none") == 0) || + (!c->animation_type_close && + strcmp(animation_type_close, "none") == 0)) { return; } @@ -692,6 +694,12 @@ void client_commit(Client *c) { // 标记动画开始 c->animation.running = true; c->animation.should_animate = false; + } else { + // 如果动画没有开始,且被判定为不应该动画, + // 则设置总帧数为1,不然其他地方一旦获取动画 + // 进度,总帧数作为分母会造成除零 + if (!c->animation.running) + c->animation.total_frames = 1; } // 请求刷新屏幕 wlr_output_schedule_frame(c->mon->wlr_output); @@ -712,6 +720,14 @@ void client_set_pending_state(Client *c) { c->animation.should_animate = true; } + if (((c->animation_type_open && + strcmp(c->animation_type_open, "none") == 0) || + (!c->animation_type_open && + strcmp(animation_type_open, "none") == 0)) && + c->animation.action == OPEN) { + c->animation.should_animate = false; + } + // 开始动画 client_commit(c); c->dirty = true; @@ -822,11 +838,6 @@ void resize(Client *c, struct wlr_box geo, int interact) { c->animainit_geom = c->geom; } - if (c->animation_type_open && strcmp(c->animation_type_open, "none") == 0 && - c->animation.action == OPEN) { - c->animainit_geom = c->geom; - } - // 开始应用动画设置 client_set_pending_state(c); diff --git a/src/animation/layer.h b/src/animation/layer.h index 450cc26..10ad833 100644 --- a/src/animation/layer.h +++ b/src/animation/layer.h @@ -253,6 +253,13 @@ void init_fadeout_layers(LayerSurface *l) { return; } + if ((l->animation_type_close && + strcmp(l->animation_type_close, "none") == 0) || + (!l->animation_type_close && + strcmp(layer_animation_type_close, "none") == 0)) { + return; + } + if (l->layer_surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM || l->layer_surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND) return; @@ -339,6 +346,14 @@ void layer_set_pending_state(LayerSurface *l) { l->animation.should_animate = true; } + if (((l->animation_type_open && + strcmp(l->animation_type_open, "none") == 0) || + (!l->animation_type_open && + strcmp(layer_animation_type_open, "none") == 0)) && + l->animation.action == OPEN) { + l->animation.should_animate = false; + } + l->animation.duration = animation_duration_open; l->animation.action = OPEN; // 开始动画 @@ -367,6 +382,12 @@ void layer_commit(LayerSurface *l) { // 标记动画开始 l->animation.running = true; l->animation.should_animate = false; + } else { + // 如果动画没有开始,且被判定为不应该动画, + // 则设置总帧数为1,不然其他地方一旦获取动画 + // 进度,总帧数作为分母会造成除零 + if (!l->animation.running) + l->animation.total_frames = 1; } // 请求刷新屏幕 wlr_output_schedule_frame(l->mon->wlr_output);