From 4d48679cccf480c324ad2661a6bd1d280ded478b Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Tue, 25 Feb 2025 20:28:59 +0800 Subject: [PATCH] opt: optimize animation clip judge --- maomao.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/maomao.c b/maomao.c index 587a45d..bb03185 100644 --- a/maomao.c +++ b/maomao.c @@ -123,6 +123,7 @@ enum { }; /* EWMH atoms */ #endif enum { UP, DOWN, LEFT, RIGHT, UNDIR }; /* movewin */ +enum {NONE,OPEN,MOVE,CLOSE,TAG}; typedef struct { int i; @@ -165,6 +166,7 @@ struct dwl_animation { uint32_t duration; struct wlr_box initial; struct wlr_box current; + int action; }; typedef struct Pertag Pertag; @@ -878,7 +880,7 @@ void apply_border(Client *c, struct wlr_box clip_box, int offset) { wlr_scene_rect_set_size(c->border[0], clip_box.width, c->bw); wlr_scene_rect_set_size(c->border[1], clip_box.width, c->bw); - if (c->animation.running) { + if (c->animation.running && c->animation.action != MOVE) { if (c->animation.current.x < c->mon->m.x) { wlr_scene_rect_set_size(c->border[2], 0, 0); wlr_scene_rect_set_size(c->border[3], c->bw, clip_box.height - 2 * c->bw); @@ -944,7 +946,7 @@ void client_apply_clip(Client *c) { } // make tagout tagin animations not visible in other monitors - if (c->animation.running) { + if (c->animation.running && c->animation.action != MOVE) { if (c->animation.current.x <= c->mon->m.x) { offset = c->mon->m.x - c->animation.current.x; clip_box.x = clip_box.x + offset; @@ -4119,12 +4121,16 @@ void resize(Client *c, struct wlr_box geo, int interact) { if (c->animation.tagouting) { c->animation.duration = animation_duration_tag; + c->animation.action = TAG; } else if (c->animation.tagining) { c->animation.duration = animation_duration_tag; + c->animation.action = TAG; } else if (c->is_open_animation) { c->animation.duration = animation_duration_open; + c->animation.action = OPEN; } else { c->animation.duration = animation_duration_move; + c->animation.action = MOVE; } // 动画起始位置大小设置