Merge remote-tracking branch 'origin/main' into scenefx-next

This commit is contained in:
DreamMaoMao 2026-03-13 12:06:23 +08:00
commit f23da9d98b
14 changed files with 863 additions and 1019 deletions

View file

@ -156,7 +156,7 @@ void layer_draw_shadow(LayerSurface *l) {
if (!l->mapped || !l->shadow)
return;
if (!shadows || !layer_shadows || l->noshadow) {
if (!config.shadows || !config.layer_shadows || l->noshadow) {
wlr_scene_shadow_set_size(l->shadow, 0, 0);
return;
}
@ -164,9 +164,8 @@ void layer_draw_shadow(LayerSurface *l) {
int32_t width, height;
layer_actual_size(l, &width, &height);
int32_t delta = shadows_size;
int32_t delta = config.shadows_size;
/* we calculate where to clip the shadow */
struct wlr_box layer_box = {
.x = 0,
.y = 0,
@ -175,22 +174,20 @@ void layer_draw_shadow(LayerSurface *l) {
};
struct wlr_box shadow_box = {
.x = shadows_position_x,
.y = shadows_position_y,
.x = config.shadows_position_x,
.y = config.shadows_position_y,
.width = width + 2 * delta,
.height = height + 2 * delta,
};
struct wlr_box intersection_box;
wlr_box_intersection(&intersection_box, &layer_box, &shadow_box);
/* clipped region takes shadow relative coords, so we translate everything
* by its position */
intersection_box.x -= shadows_position_x;
intersection_box.y -= shadows_position_y;
intersection_box.x -= config.shadows_position_x;
intersection_box.y -= config.shadows_position_y;
struct clipped_region clipped_region = {
.area = intersection_box,
.corners = corner_radii_all(border_radius),
.corners = corner_radii_all(config.border_radius),
};
wlr_scene_node_set_position(&l->shadow->node, shadow_box.x, shadow_box.y);
@ -260,7 +257,7 @@ void fadeout_layer_animation_next_tick(LayerSurface *l) {
buffer_data.height = height;
if ((!l->animation_type_close &&
strcmp(layer_animation_type_close, "zoom") == 0) ||
strcmp(config.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,
@ -278,12 +275,12 @@ void fadeout_layer_animation_next_tick(LayerSurface *l) {
double opacity_eased_progress =
find_animation_curve_at(animation_passed, OPAFADEOUT);
double percent = fadeout_begin_opacity -
(opacity_eased_progress * fadeout_begin_opacity);
double percent = config.fadeout_begin_opacity -
(opacity_eased_progress * config.fadeout_begin_opacity);
double opacity = MAX(percent, 0.0f);
if (animation_fade_out)
if (config.animation_fade_out)
wlr_scene_node_for_each_buffer(&l->scene->node,
scene_buffer_apply_opacity, &opacity);
@ -326,12 +323,12 @@ void layer_animation_next_tick(LayerSurface *l) {
find_animation_curve_at(animation_passed, OPAFADEIN);
double opacity =
MIN(fadein_begin_opacity +
opacity_eased_progress * (1.0 - fadein_begin_opacity),
MIN(config.fadein_begin_opacity +
opacity_eased_progress * (1.0 - config.fadein_begin_opacity),
1.0f);
if (animation_fade_in) {
if (blur && !l->noblur && !blur_optimized) {
if (config.animation_fade_in) {
if (blur && !l->noblur && !config.blur_optimized) {
wlr_scene_blur_set_strength(l->blur, opacity);
wlr_scene_blur_set_alpha(l->blur, opacity);
}
@ -351,7 +348,7 @@ void layer_animation_next_tick(LayerSurface *l) {
}
if ((!l->animation_type_open &&
strcmp(layer_animation_type_open, "zoom") == 0) ||
strcmp(config.layer_animation_type_open, "zoom") == 0) ||
(l->animation_type_open &&
strcmp(l->animation_type_open, "zoom") == 0)) {
wlr_scene_node_for_each_buffer(
@ -378,7 +375,7 @@ void layer_animation_next_tick(LayerSurface *l) {
void init_fadeout_layers(LayerSurface *l) {
if (!animations || !layer_animations || l->noanim) {
if (!config.animations || !config.layer_animations || l->noanim) {
return;
}
@ -388,7 +385,7 @@ void init_fadeout_layers(LayerSurface *l) {
if ((l->animation_type_close &&
strcmp(l->animation_type_close, "none") == 0) ||
(!l->animation_type_close &&
strcmp(layer_animation_type_close, "none") == 0)) {
strcmp(config.layer_animation_type_close, "none") == 0)) {
return;
}
@ -411,7 +408,7 @@ void init_fadeout_layers(LayerSurface *l) {
return;
}
fadeout_layer->animation.duration = animation_duration_close;
fadeout_layer->animation.duration = config.animation_duration_close;
fadeout_layer->geom = fadeout_layer->current =
fadeout_layer->animainit_geom = fadeout_layer->animation.initial =
l->animation.current;
@ -427,14 +424,14 @@ void init_fadeout_layers(LayerSurface *l) {
fadeout_layer->animation.initial.y = 0;
if ((!l->animation_type_close &&
strcmp(layer_animation_type_close, "zoom") == 0) ||
strcmp(config.layer_animation_type_close, "zoom") == 0) ||
(l->animation_type_close &&
strcmp(l->animation_type_close, "zoom") == 0)) {
// 算出要设置的绝对坐标和大小
fadeout_layer->current.width =
(float)l->animation.current.width * zoom_end_ratio;
(float)l->animation.current.width * config.zoom_end_ratio;
fadeout_layer->current.height =
(float)l->animation.current.height * zoom_end_ratio;
(float)l->animation.current.height * config.zoom_end_ratio;
fadeout_layer->current.x = usable_area.x + usable_area.width / 2 -
fadeout_layer->current.width / 2;
fadeout_layer->current.y = usable_area.y + usable_area.height / 2 -
@ -446,7 +443,7 @@ void init_fadeout_layers(LayerSurface *l) {
fadeout_layer->current.y - l->animation.current.y;
} else if ((!l->animation_type_close &&
strcmp(layer_animation_type_close, "slide") == 0) ||
strcmp(config.layer_animation_type_close, "slide") == 0) ||
(l->animation_type_close &&
strcmp(l->animation_type_close, "slide") == 0)) {
// 获取slide动画的结束绝对坐标和大小
@ -491,17 +488,18 @@ void layer_set_pending_state(LayerSurface *l) {
if (l->animation.action == OPEN && !l->animation.running) {
if ((!l->animation_type_open &&
strcmp(layer_animation_type_open, "zoom") == 0) ||
strcmp(config.layer_animation_type_open, "zoom") == 0) ||
(l->animation_type_open &&
strcmp(l->animation_type_open, "zoom") == 0)) {
l->animainit_geom.width = l->geom.width * zoom_initial_ratio;
l->animainit_geom.height = l->geom.height * zoom_initial_ratio;
l->animainit_geom.width = l->geom.width * config.zoom_initial_ratio;
l->animainit_geom.height =
l->geom.height * config.zoom_initial_ratio;
l->animainit_geom.x = usable_area.x + usable_area.width / 2 -
l->animainit_geom.width / 2;
l->animainit_geom.y = usable_area.y + usable_area.height / 2 -
l->animainit_geom.height / 2;
} else if ((!l->animation_type_open &&
strcmp(layer_animation_type_open, "slide") == 0) ||
strcmp(config.layer_animation_type_open, "slide") == 0) ||
(l->animation_type_open &&
strcmp(l->animation_type_open, "slide") == 0)) {
@ -515,8 +513,7 @@ void layer_set_pending_state(LayerSurface *l) {
} else {
l->animainit_geom = l->animation.current;
}
// 判断是否需要动画
if (!animations || !layer_animations || l->noanim ||
if (!config.animations || !config.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) {
@ -528,7 +525,7 @@ void layer_set_pending_state(LayerSurface *l) {
if (((l->animation_type_open &&
strcmp(l->animation_type_open, "none") == 0) ||
(!l->animation_type_open &&
strcmp(layer_animation_type_open, "none") == 0)) &&
strcmp(config.layer_animation_type_open, "none") == 0)) &&
l->animation.action == OPEN) {
l->animation.should_animate = false;
}
@ -575,7 +572,8 @@ bool layer_draw_frame(LayerSurface *l) {
return false;
}
if (animations && layer_animations && l->animation.running && !l->noanim) {
if (config.animations && config.layer_animations && l->animation.running &&
!l->noanim) {
layer_animation_next_tick(l);
layer_draw_shadow(l);
} else {