feat: support client fade int fade out only animaiton

This commit is contained in:
DreamMaoMao 2025-07-11 22:54:30 +08:00
parent 682db2bcbf
commit 43dba2151e
2 changed files with 36 additions and 46 deletions

View file

@ -8,28 +8,6 @@ void set_rect_size(struct wlr_scene_rect *rect, int width, int height) {
wlr_scene_rect_set_size(rect, GEZERO(width), GEZERO(height));
}
void apply_opacity_to_rect_nodes(Client *c, struct wlr_scene_node *node,
double animation_passed) {
if (node->type == WLR_SCENE_NODE_RECT) {
struct wlr_scene_rect *rect = wlr_scene_rect_from_node(node);
// Assuming the rect has a color field and we can modify it
rect->color[0] = 0;
rect->color[1] = 0;
rect->color[2] = 0;
rect->color[3] = 0;
wlr_scene_rect_set_color(rect, rect->color);
}
// If the node is a tree, recursively traverse its children
if (node->type == WLR_SCENE_NODE_TREE) {
struct wlr_scene_tree *scene_tree = wlr_scene_tree_from_node(node);
struct wlr_scene_node *child;
wl_list_for_each(child, &scene_tree->children, link) {
apply_opacity_to_rect_nodes(c, child, animation_passed);
}
}
}
enum corner_location set_client_corner_location(Client *c) {
enum corner_location current_corner_location = CORNER_LOCATION_ALL;
struct wlr_box target_geom = animations ? c->animation.current : c->geom;
@ -79,9 +57,17 @@ void set_client_open_animaiton(Client *c, struct wlr_box geo) {
int vertical, vertical_value;
int special_direction;
int center_x, center_y;
if ((!c->animation_type_open && strcmp(animation_type_open, "zoom") == 0) ||
(c->animation_type_open &&
strcmp(c->animation_type_open, "zoom") == 0)) {
if ((!c->animation_type_open && strcmp(animation_type_open, "fade") == 0)) {
c->animainit_geom.width = geo.width;
c->animainit_geom.height = geo.height;
c->animainit_geom.x = geo.x;
c->animainit_geom.y = geo.y;
return;
} else if ((!c->animation_type_open &&
strcmp(animation_type_open, "zoom") == 0) ||
(c->animation_type_open &&
strcmp(c->animation_type_open, "zoom") == 0)) {
c->animainit_geom.width = geo.width * zoom_initial_ratio;
c->animainit_geom.height = geo.height * zoom_initial_ratio;
c->animainit_geom.x = geo.x + (geo.width - c->animainit_geom.width) / 2;
@ -649,8 +635,6 @@ void fadeout_client_animation_next_tick(Client *c) {
wlr_scene_node_for_each_buffer(&c->scene->node,
scene_buffer_apply_opacity, &opacity);
apply_opacity_to_rect_nodes(c, &c->scene->node, animation_passed);
if ((c->animation_type_close &&
strcmp(c->animation_type_close, "zoom") == 0) ||
(!c->animation_type_close &&
@ -783,10 +767,16 @@ void init_fadeout_client(Client *c) {
fadeout_cient->animation.initial.x = 0;
fadeout_cient->animation.initial.y = 0;
if ((c->animation_type_close &&
strcmp(c->animation_type_close, "slide") == 0) ||
(!c->animation_type_close &&
strcmp(animation_type_close, "slide") == 0)) {
if (strcmp(animation_type_close, "fade") == 0) {
fadeout_cient->current.x = 0;
fadeout_cient->current.y = 0;
fadeout_cient->current.width = 0;
fadeout_cient->current.height = 0;
} else if ((c->animation_type_close &&
strcmp(c->animation_type_close, "slide") == 0) ||
(!c->animation_type_close &&
strcmp(animation_type_close, "slide") == 0)) {
fadeout_cient->current.y =
c->geom.y + c->geom.height / 2 > c->mon->m.y + c->mon->m.height / 2
? c->mon->m.height -

View file

@ -109,26 +109,26 @@ static bool scene_node_snapshot(struct wlr_scene_node *node, int lx, int ly,
break;
}
case WLR_SCENE_NODE_RECT: {
struct wlr_scene_rect *scene_rect = wlr_scene_rect_from_node(node);
// struct wlr_scene_rect *scene_rect = wlr_scene_rect_from_node(node);
struct wlr_scene_rect *snapshot_rect =
wlr_scene_rect_create(snapshot_tree, scene_rect->width,
scene_rect->height, scene_rect->color);
snapshot_rect->node.data = scene_rect->node.data;
if (snapshot_rect == NULL) {
return false;
}
// struct wlr_scene_rect *snapshot_rect =
// wlr_scene_rect_create(snapshot_tree, scene_rect->width,
// scene_rect->height, scene_rect->color);
// snapshot_rect->node.data = scene_rect->node.data;
// if (snapshot_rect == NULL) {
// return false;
// }
wlr_scene_rect_set_clipped_region(scene_rect,
snapshot_rect->clipped_region);
wlr_scene_rect_set_backdrop_blur(scene_rect, false);
// wlr_scene_rect_set_clipped_region(scene_rect,
// snapshot_rect->clipped_region);
// wlr_scene_rect_set_backdrop_blur(scene_rect, false);
// wlr_scene_rect_set_backdrop_blur_optimized(
// scene_rect, snapshot_rect->backdrop_blur_optimized);
wlr_scene_rect_set_corner_radius(
scene_rect, snapshot_rect->corner_radius, snapshot_rect->corners);
wlr_scene_rect_set_color(scene_rect, snapshot_rect->color);
// wlr_scene_rect_set_corner_radius(
// scene_rect, snapshot_rect->corner_radius, snapshot_rect->corners);
// wlr_scene_rect_set_color(scene_rect, snapshot_rect->color);
snapshot_node = &snapshot_rect->node;
// snapshot_node = &snapshot_rect->node;
break;
}
case WLR_SCENE_NODE_BUFFER: {