diff --git a/src/config/parse_config.h b/src/config/parse_config.h index ebc967e..10bbf44 100644 --- a/src/config/parse_config.h +++ b/src/config/parse_config.h @@ -130,6 +130,7 @@ typedef struct { typedef struct { int animations; + int layer_animations; char animation_type_open[10]; char animation_type_close[10]; int animation_fade_in; @@ -832,6 +833,8 @@ void parse_config_line(Config *config, const char *line) { if (strcmp(key, "animations") == 0) { config->animations = atoi(value); + } else if (strcmp(key, "layer_animations") == 0) { + config->layer_animations = atoi(value); } else if (strcmp(key, "animation_type_open") == 0) { snprintf(config->animation_type_open, sizeof(config->animation_type_open), "%.9s", @@ -2057,6 +2060,7 @@ void free_config(void) { void override_config(void) { // 动画启用 animations = CLAMP_INT(config.animations, 0, 1); + layer_animations = CLAMP_INT(config.layer_animations, 0, 1); // 标签动画方向 tag_animation_direction = CLAMP_INT(config.tag_animation_direction, 0, 1); @@ -2199,6 +2203,7 @@ void override_config(void) { void set_value_default() { /* animaion */ config.animations = animations; // 是否启用动画 + config.layer_animations = layer_animations; // 是否启用layer动画 config.animation_fade_in = animation_fade_in; // Enable animation fade in config.animation_fade_out = animation_fade_out; // Enable animation fade out config.tag_animation_direction = tag_animation_direction; // 标签动画方向 diff --git a/src/config/preset.h b/src/config/preset.h index 00fb739..07f672a 100644 --- a/src/config/preset.h +++ b/src/config/preset.h @@ -11,7 +11,7 @@ char *animation_type_open = "slide"; // 是否启用动画 //slide,zoom char *animation_type_close = "slide"; // 是否启用动画 //slide,zoom int animations = 1; // 是否启用动画 -int layer_animaitons = 1; // 是否启用layer动画 +int layer_animations = 1; // 是否启用layer动画 int tag_animation_direction = HORIZONTAL; // 标签动画方向 int animation_fade_in = 1; // Enable animation fade in int animation_fade_out = 1; // Enable animation fade out diff --git a/src/maomao.c b/src/maomao.c index 523a6c7..32e46be 100644 --- a/src/maomao.c +++ b/src/maomao.c @@ -1033,6 +1033,7 @@ void layer_animation_next_tick(LayerSurface *l) { if (animation_passed == 1.0) { l->animation.running = false; l->need_output_flush = false; + l->animation.action = MOVE; } else { l->animation.passed_frames++; } @@ -1486,7 +1487,7 @@ bool layer_draw_frame(LayerSurface *l) { return false; } - if (animations && l->animation.running && !l->noanim) { + if (animations && layer_animations && l->animation.running && !l->noanim) { layer_animation_next_tick(l); } else { wlr_scene_node_set_position(&l->scene->node, l->geom.x, l->geom.y); @@ -3173,17 +3174,8 @@ static void iter_layer_scene_buffers(struct wlr_scene_buffer *buffer, int sx, } } -void maplayersurfacenotify(struct wl_listener *listener, void *data) { - int ji; - LayerSurface *l = wl_container_of(listener, l, map); - if (!l->mon) - return; - struct wlr_layer_surface_v1 *layer_surface = l->layer_surface; - const struct wlr_layer_surface_v1_state *state = &layer_surface->current; - strncpy(l->mon->last_surface_ws_name, layer_surface->namespace, - sizeof(l->mon->last_surface_ws_name) - 1); // 最多拷贝255个字符 - l->mon->last_surface_ws_name[sizeof(l->mon->last_surface_ws_name) - 1] = - '\0'; // 确保字符串以null结尾 +void get_layer_target_geometry(LayerSurface *l, struct wlr_box *target_box) { + const struct wlr_layer_surface_v1_state *state = &l->layer_surface->current; // 计算几何位置 struct wlr_box bounds; @@ -3249,6 +3241,26 @@ void maplayersurfacenotify(struct wl_listener *listener, void *data) { } } + target_box->x = box.x; + target_box->y = box.y; + target_box->width = box.width; + target_box->height = box.height; +} + +void maplayersurfacenotify(struct wl_listener *listener, void *data) { + int ji; + LayerSurface *l = wl_container_of(listener, l, map); + if (!l->mon) + return; + struct wlr_layer_surface_v1 *layer_surface = l->layer_surface; + strncpy(l->mon->last_surface_ws_name, layer_surface->namespace, + sizeof(l->mon->last_surface_ws_name) - 1); // 最多拷贝255个字符 + l->mon->last_surface_ws_name[sizeof(l->mon->last_surface_ws_name) - 1] = + '\0'; // 确保字符串以null结尾 + + struct wlr_box box; + get_layer_target_geometry(l, &box); + // 更新几何位置 l->geom = box; l->noanim = 0; @@ -3353,7 +3365,7 @@ void layer_set_pending_state(LayerSurface *l) { l->pending = l->geom; set_layer_open_animaiton(l, l->geom); // 判断是否需要动画 - if (!animations || l->noanim || + if (!animations || !layer_animations || l->noanim || l->layer_surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND || l->layer_surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM) { @@ -7348,7 +7360,7 @@ void unmaplayersurfacenotify(struct wl_listener *listener, void *data) { void init_fadeout_layers(LayerSurface *l) { - if (!layer_animaitons || l->noanim) { + if (!layer_animations || l->noanim) { return; }