feat: layer animaiton fade in fade out only support

This commit is contained in:
DreamMaoMao 2025-07-11 22:28:10 +08:00
parent 805dae0cf3
commit fed7fb854a

View file

@ -164,7 +164,7 @@ void fadeout_layer_animation_next_tick(LayerSurface *l) {
.height = height, .height = height,
}; };
double opacity = MAX(fadeout_begin_opacity - animation_passed, 0); double opacity = MAX(fadeout_begin_opacity - animation_passed, 0.0f);
if (animation_fade_out) if (animation_fade_out)
wlr_scene_node_for_each_buffer(&l->scene->node, wlr_scene_node_for_each_buffer(&l->scene->node,
@ -203,6 +203,12 @@ void layer_animation_next_tick(LayerSurface *l) {
unsigned int y = l->animation.initial.y + unsigned int y = l->animation.initial.y +
(l->current.y - l->animation.initial.y) * factor; (l->current.y - l->animation.initial.y) * factor;
double opacity = MIN(fadein_begin_opacity + animation_passed, 1.0f);
if (animation_fade_in)
wlr_scene_node_for_each_buffer(&l->scene->node,
scene_buffer_apply_opacity, &opacity);
wlr_scene_node_set_position(&l->scene->node, x, y); wlr_scene_node_set_position(&l->scene->node, x, y);
l->animation.current = (struct wlr_box){ l->animation.current = (struct wlr_box){
@ -263,10 +269,15 @@ void init_fadeout_layers(LayerSurface *l) {
fadeout_layer->animation.initial.x = 0; fadeout_layer->animation.initial.x = 0;
fadeout_layer->animation.initial.y = 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 {
set_layer_dir_animaiton(l, &fadeout_layer->current); set_layer_dir_animaiton(l, &fadeout_layer->current);
fadeout_layer->current.x = fadeout_layer->current.x - l->geom.x; fadeout_layer->current.x = fadeout_layer->current.x - l->geom.x;
fadeout_layer->current.y = fadeout_layer->current.y - l->geom.y; fadeout_layer->current.y = fadeout_layer->current.y - l->geom.y;
}
fadeout_layer->animation.passed_frames = 0; fadeout_layer->animation.passed_frames = 0;
fadeout_layer->animation.total_frames = fadeout_layer->animation.total_frames =
@ -281,10 +292,17 @@ void layer_set_pending_state(LayerSurface *l) {
return; return;
l->pending = l->geom; l->pending = l->geom;
if (l->animation.action == OPEN) if (l->animation.action == OPEN) {
if (strcmp(animation_type_open, "fade") == 0 ||
strcmp(animation_type_open, "zoom") == 0) {
l->animainit_geom.x = l->geom.x;
l->animainit_geom.y = l->geom.y;
} else {
set_layer_dir_animaiton(l, &l->animainit_geom); set_layer_dir_animaiton(l, &l->animainit_geom);
else }
} else {
l->animainit_geom = l->animation.current; l->animainit_geom = l->animation.current;
}
// 判断是否需要动画 // 判断是否需要动画
if (!animations || !layer_animations || l->noanim || if (!animations || !layer_animations || l->noanim ||
l->layer_surface->current.layer == l->layer_surface->current.layer ==