diff --git a/src/animation/layer.h b/src/animation/layer.h index 16ac9e6..6d7d04b 100644 --- a/src/animation/layer.h +++ b/src/animation/layer.h @@ -269,14 +269,16 @@ void init_fadeout_layers(LayerSurface *l) { fadeout_layer->animation.initial.x = 0; fadeout_layer->animation.initial.y = 0; - if (strcmp(animation_type_close, "zoom") == 0 || - strcmp(animation_type_close, "fade") == 0) { - fadeout_layer->current.x = 0; - fadeout_layer->current.y = 0; - } else { + if ((!l->animation_type_close && + strcmp(layer_animation_type_close, "slide") == 0) || + (l->animation_type_close && + strcmp(l->animation_type_close, "slide") == 0)) { set_layer_dir_animaiton(l, &fadeout_layer->current); fadeout_layer->current.x = fadeout_layer->current.x - l->geom.x; fadeout_layer->current.y = fadeout_layer->current.y - l->geom.y; + } else { + fadeout_layer->current.x = 0; + fadeout_layer->current.y = 0; } fadeout_layer->animation.passed_frames = 0; @@ -293,12 +295,15 @@ void layer_set_pending_state(LayerSurface *l) { l->pending = l->geom; if (l->animation.action == OPEN) { - if (strcmp(animation_type_open, "fade") == 0 || - strcmp(animation_type_open, "zoom") == 0) { + if ((!l->animation_type_open && + strcmp(layer_animation_type_open, "slide") == 0) || + (l->animation_type_open && + strcmp(l->animation_type_open, "slide") == 0)) { + + set_layer_dir_animaiton(l, &l->animainit_geom); + } else { l->animainit_geom.x = l->geom.x; l->animainit_geom.y = l->geom.y; - } else { - set_layer_dir_animaiton(l, &l->animainit_geom); } } else { l->animainit_geom = l->animation.current; diff --git a/src/config/parse_config.h b/src/config/parse_config.h index 9ea2a58..7b62127 100644 --- a/src/config/parse_config.h +++ b/src/config/parse_config.h @@ -42,6 +42,8 @@ typedef struct { float scroller_proportion; const char *animation_type_open; const char *animation_type_close; + const char *layer_animation_type_open; + const char *layer_animation_type_close; int isnoborder; int isopensilent; int isnamedscratchpad; @@ -125,6 +127,9 @@ typedef struct { typedef struct { char *layer_name; // 布局名称 + char *animation_type_open; + char *animation_type_close; + int noblur; int noanim; } ConfigLayerRule; @@ -133,6 +138,8 @@ typedef struct { int layer_animations; char animation_type_open[10]; char animation_type_close[10]; + char layer_animation_type_open[10]; + char layer_animation_type_close[10]; int animation_fade_in; int animation_fade_out; int tag_animation_direction; @@ -842,6 +849,14 @@ 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, "layer_animation_type_open") == 0) { + snprintf(config->layer_animation_type_open, + sizeof(config->layer_animation_type_open), "%.9s", + value); // string limit to 9 char + } else if (strcmp(key, "layer_animation_type_close") == 0) { + snprintf(config->layer_animation_type_close, + sizeof(config->layer_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, "animation_fade_out") == 0) { @@ -1276,6 +1291,9 @@ void parse_config_line(Config *config, const char *line) { // 设置默认值 rule->layer_name = NULL; + rule->animation_type_open = NULL; + rule->animation_type_close = NULL; + rule->noblur = 0; rule->noanim = 0; char *token = strtok(value, ","); @@ -1291,6 +1309,12 @@ void parse_config_line(Config *config, const char *line) { if (strcmp(key, "layer_name") == 0) { rule->layer_name = strdup(val); + } else if (strcmp(key, "animation_type_open") == 0) { + rule->animation_type_open = strdup(val); + } else if (strcmp(key, "animation_type_close") == 0) { + rule->animation_type_close = strdup(val); + } else if (strcmp(key, "noblur") == 0) { + rule->noblur = CLAMP_INT(atoi(val), 0, 1); } else if (strcmp(key, "noanim") == 0) { rule->noanim = CLAMP_INT(atoi(val), 0, 1); } @@ -1990,7 +2014,12 @@ void free_config(void) { // 释放 layer_rules if (config.layer_rules) { for (int i = 0; i < config.layer_rules_count; i++) { - free((void *)config.layer_rules[i].layer_name); + if (config.layer_rules[i].layer_name) + free((void *)config.layer_rules[i].layer_name); + if (config.layer_rules[i].animation_type_open) + free((void *)config.layer_rules[i].animation_type_open); + if (config.layer_rules[i].animation_type_close) + free((void *)config.layer_rules[i].animation_type_close); } free(config.layer_rules); config.layer_rules = NULL; @@ -2056,6 +2085,10 @@ void override_config(void) { animation_type_open = config.animation_type_open; animation_type_close = config.animation_type_close; + // layer打开关闭动画类型 + layer_animation_type_open = config.layer_animation_type_open; + layer_animation_type_close = config.layer_animation_type_close; + // 动画时间限制在合理范围(1-50000ms) animation_duration_move = CLAMP_INT(config.animation_duration_move, 1, 50000); diff --git a/src/config/preset.h b/src/config/preset.h index 30b1d4b..b420dfc 100644 --- a/src/config/preset.h +++ b/src/config/preset.h @@ -8,14 +8,16 @@ ((hex >> 8) & 0xFF) / 255.0f, (hex & 0xFF) / 255.0f} /* animaion */ -char *animation_type_open = "slide"; // 是否启用动画 //slide,zoom -char *animation_type_close = "slide"; // 是否启用动画 //slide,zoom -int animations = 1; // 是否启用动画 -int layer_animations = 0; // 是否启用layer动画 -int tag_animation_direction = HORIZONTAL; // 标签动画方向 -int animation_fade_in = 1; // Enable animation fade in -int animation_fade_out = 1; // Enable animation fade out -float zoom_initial_ratio = 0.5; // 动画起始窗口比例 +char *animation_type_open = "slide"; // 是否启用动画 //slide,zoom +char *animation_type_close = "slide"; // 是否启用动画 //slide,zoom +char *layer_animation_type_open = "slide"; // 是否启用layer动画 //slide,zoom +char *layer_animation_type_close = "slide"; // 是否启用layer动画 //slide,zoom +int animations = 1; // 是否启用动画 +int layer_animations = 0; // 是否启用layer动画 +int tag_animation_direction = HORIZONTAL; // 标签动画方向 +int animation_fade_in = 1; // Enable animation fade in +int animation_fade_out = 1; // Enable animation fade out +float zoom_initial_ratio = 0.5; // 动画起始窗口比例 float fadein_begin_opacity = 0.5; // Begin opac window ratio for animations float fadeout_begin_opacity = 0.5; // Begin opac window ratio for animations uint32_t animation_duration_move = 500; // Animation move speed diff --git a/src/maomao.c b/src/maomao.c index c1d5926..f525c52 100644 --- a/src/maomao.c +++ b/src/maomao.c @@ -367,6 +367,9 @@ typedef struct { struct dwl_animation animation; bool dirty; int noanim; + int noshadow; + char *animation_type_open; + char *animation_type_close; bool need_output_flush; } LayerSurface; @@ -2490,6 +2493,17 @@ void maplayersurfacenotify(struct wl_listener *listener, void *data) { if (config.layer_rules[ji].noanim > 0) { l->noanim = 1; } + if (config.layer_rules[ji].noshadow > 0) { + l->noshadow = 1; + } + if (config.layer_rules[ji].animation_type_open) { + l->animation_type_open = + config.layer_rules[ji].animation_type_open; + } + if (config.layer_rules[ji].animation_type_close) { + l->animation_type_close = + config.layer_rules[ji].animation_type_close; + } } }