From 7485fa1b7e1306075fe384e19927c48b73219e7b Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Sun, 13 Jul 2025 09:02:50 +0800 Subject: [PATCH] opt: optimize layer scale offset --- src/animation/layer.h | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/src/animation/layer.h b/src/animation/layer.h index 0210cb2..583185b 100644 --- a/src/animation/layer.h +++ b/src/animation/layer.h @@ -209,14 +209,6 @@ void layer_scene_buffer_apply_effect(struct wlr_scene_buffer *buffer, int sx, struct wlr_surface *surface = scene_surface->surface; - if (scale_data->width_scale >= 0.99f) { - scale_data->width_scale = 1.0f; - } - - if (scale_data->height_scale >= 0.99f) { - scale_data->height_scale = 1.0f; - } - unsigned int surface_width = surface->current.width; unsigned int surface_height = surface->current.height; surface_width = scale_data->width_scale * surface_width; @@ -260,11 +252,10 @@ void fadeout_layer_animation_next_tick(LayerSurface *l) { scale_data.width = width; scale_data.height = height; - if (((!l->animation_type_close && - strcmp(layer_animation_type_close, "zoom") == 0) || - (l->animation_type_close && - strcmp(l->animation_type_close, "zoom") == 0)) && - (width != l->current.width || height != l->current.height)) { + if ((!l->animation_type_close && + strcmp(layer_animation_type_close, "zoom") == 0) || + (l->animation_type_close && + strcmp(l->animation_type_close, "zoom") == 0)) { wlr_scene_node_for_each_buffer(&l->scene->node, layer_fadeout_scene_buffer_apply_effect, &scale_data); @@ -325,14 +316,18 @@ void layer_animation_next_tick(LayerSurface *l) { wlr_scene_node_set_position(&l->scene->node, x, y); animationScale scale_data; - scale_data.width_scale = (float)width / (float)l->current.width; - scale_data.height_scale = (float)height / (float)l->current.height; + if (factor == 1.0) { + scale_data.width_scale = 1.0f; + scale_data.height_scale = 1.0f; + } else { + scale_data.width_scale = (float)width / (float)l->current.width; + scale_data.height_scale = (float)height / (float)l->current.height; + } - if (((!l->animation_type_open && - strcmp(layer_animation_type_open, "zoom") == 0) || - (l->animation_type_open && - strcmp(l->animation_type_open, "zoom") == 0)) && - (scale_data.width_scale != 1.0 || scale_data.height_scale != 1.0)) { + if ((!l->animation_type_open && + strcmp(layer_animation_type_open, "zoom") == 0) || + (l->animation_type_open && + strcmp(l->animation_type_open, "zoom") == 0)) { wlr_scene_node_for_each_buffer( &l->scene->node, layer_scene_buffer_apply_effect, &scale_data); }