feat:Support vertical tag switching animation

This commit is contained in:
DreamMaoMao 2025-04-26 22:28:01 +08:00
parent 2bf0a791cd
commit 0161e35840
4 changed files with 39 additions and 8 deletions

View file

@ -1,8 +1,10 @@
# Animation Configuration(support type:zoom,slide)
# tag_animation_direction: 0-horizontal,1-vertical
animations=1
animation_type_open=slide
animation_type_close=slide
animation_fade_in=1
tag_animation_direction=1
zoom_initial_ratio=0.5
fadein_begin_opacity=0.5
fadeout_begin_opacity=0.8

View file

@ -109,6 +109,7 @@
#define BAKED_POINTS_COUNT 256
/* enums */
enum { VERTICAL, HORIZONTAL};
enum { SWIPE_UP, SWIPE_DOWN, SWIPE_LEFT, SWIPE_RIGHT };
enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
enum { XDGShell, LayerShell, X11 }; /* client types */
@ -1694,19 +1695,31 @@ arrange(Monitor *m, bool want_animation) {
wlr_scene_node_set_enabled(&c->scene->node, true);
}
client_set_suspended(c, false);
if (!c->animation.from_rule && want_animation &&
m->pertag->prevtag != 0 && m->pertag->curtag != 0 && animations) {
if (!c->animation.from_rule &&
want_animation &&
m->pertag->prevtag != 0 &&
m->pertag->curtag != 0 &&
animations && !c->animation.running) {
c->animation.tagining = true;
if (m->pertag->curtag > m->pertag->prevtag) {
c->animainit_geom.x = c->animation.running
c->animainit_geom.x = tag_animation_direction == VERTICAL
? c->animation.current.x
: c->mon->m.x + c->mon->m.width;
c->animainit_geom.y = tag_animation_direction == VERTICAL
? c->mon->m.y + c->mon->m.height
: c->animation.current.y;
} else {
c->animainit_geom.x = c->animation.running ? c->animation.current.x
: m->m.x - c->geom.width;
c->animainit_geom.x = tag_animation_direction == VERTICAL
? c->animation.current.x
: m->m.x - c->geom.width;
c->animainit_geom.y = tag_animation_direction == VERTICAL
? m->m.y - c->geom.height
: c->animation.current.y;
}
} else {
c->animainit_geom.x = c->animation.current.x;
c->animainit_geom.y = c->animation.current.y;
}
c->animation.from_rule = false;
@ -1722,11 +1735,22 @@ arrange(Monitor *m, bool want_animation) {
c->animation.tagining = false;
if (m->pertag->curtag > m->pertag->prevtag) {
c->pending = c->geom;
c->pending.x = c->mon->m.x - c->geom.width;
c->pending.x = tag_animation_direction == VERTICAL
? c->animation.current.x
: c->mon->m.x - c->geom.width;
c->pending.y = tag_animation_direction == VERTICAL
? c->mon->m.y - c->geom.height
: c->animation.current.y;
resize(c, c->geom, 0);
} else {
c->pending = c->geom;
c->pending.x = c->mon->m.x + c->mon->m.width;
c->pending.x = tag_animation_direction == VERTICAL
? c->animation.current.x
: c->mon->m.x + c->mon->m.width;
c->pending.y = tag_animation_direction == VERTICAL
? c->mon->m.y + c->mon->m.height
: c->animation.current.y;
resize(c, c->geom, 0);
}
} else {
@ -4861,7 +4885,6 @@ void resize(Client *c, struct wlr_box geo, int interact) {
} else if (c->animation.tagining) {
c->animainit_geom.height = c->animation.current.height;
c->animainit_geom.width = c->animation.current.width;
c->animainit_geom.y = c->animation.current.y;
} else if (c->is_open_animation) {
set_open_animaiton(c, c->geom);
} else {

View file

@ -88,6 +88,7 @@ typedef struct {
char animation_type_open[10];
char animation_type_close[10];
char animation_fade_in;
int tag_animation_direction;
float zoom_initial_ratio;
float fadein_begin_opacity;
float fadeout_begin_opacity;
@ -528,6 +529,8 @@ void parse_config_line(Config *config, const char *line) {
snprintf(config->animation_type_close, sizeof(config->animation_type_close), "%.9s", value); // string limit to 9 char
} else if (strcmp(key, "animation_fade_in") == 0) {
config->animation_fade_in = atoi(value);
} else if (strcmp(key, "tag_animation_direction") == 0) {
config->tag_animation_direction = atoi(value);
} else if (strcmp(key, "zoom_initial_ratio") == 0) {
config->zoom_initial_ratio = atof(value);
} else if (strcmp(key, "fadein_begin_opacity") == 0) {
@ -1171,6 +1174,7 @@ void override_config(void) {
animation_type_open = config.animation_type_open;
animation_type_close = config.animation_type_close;
animation_fade_in = config.animation_fade_in;
tag_animation_direction = config.tag_animation_direction;
zoom_initial_ratio = config.zoom_initial_ratio;
fadein_begin_opacity = config.fadein_begin_opacity;
fadeout_begin_opacity = config.fadeout_begin_opacity;
@ -1245,6 +1249,7 @@ void set_value_default() {
/* animaion */
config.animations = animations; // 是否启用动画
config.animation_fade_in = animation_fade_in; // Enable animation fade in
config.tag_animation_direction = tag_animation_direction; // 标签动画方向
config.zoom_initial_ratio = zoom_initial_ratio; // 动画起始窗口比例
config.fadein_begin_opacity = fadein_begin_opacity; // Begin opac window ratio for animations
config.fadeout_begin_opacity = fadeout_begin_opacity;

View file

@ -8,6 +8,7 @@
char *animation_type_open = "slide"; // 是否启用动画 //slide,zoom
char *animation_type_close = "slide"; // 是否启用动画 //slide,zoom
int animations = 1; // 是否启用动画
int tag_animation_direction = HORIZONTAL; // 标签动画方向
char animation_fade_in = 1; // Enable animation fade in
float zoom_initial_ratio = 0.5; // 动画起始窗口比例
float fadein_begin_opacity = 0.5; // Begin opac window ratio for animations