diff --git a/src/animation/client.h b/src/animation/client.h index 9038313..bd45a27 100644 --- a/src/animation/client.h +++ b/src/animation/client.h @@ -110,28 +110,28 @@ void set_client_open_animaiton(Client *c, struct wlr_box geo) { void snap_scene_buffer_apply_effect(struct wlr_scene_buffer *buffer, int sx, int sy, void *data) { - animationScale *scale_data = (animationScale *)data; - wlr_scene_buffer_set_dest_size(buffer, scale_data->width, - scale_data->height); + BufferData *buffer_data = (BufferData *)data; + wlr_scene_buffer_set_dest_size(buffer, buffer_data->width, + buffer_data->height); } void scene_buffer_apply_effect(struct wlr_scene_buffer *buffer, int sx, int sy, void *data) { - animationScale *scale_data = (animationScale *)data; + BufferData *buffer_data = (BufferData *)data; - if (scale_data->should_scale && scale_data->height_scale < 1 && - scale_data->width_scale < 1) { - scale_data->should_scale = false; + if (buffer_data->should_scale && buffer_data->height_scale < 1 && + buffer_data->width_scale < 1) { + buffer_data->should_scale = false; } - if (scale_data->should_scale && scale_data->height_scale == 1 && - scale_data->width_scale < 1) { - scale_data->should_scale = false; + if (buffer_data->should_scale && buffer_data->height_scale == 1 && + buffer_data->width_scale < 1) { + buffer_data->should_scale = false; } - if (scale_data->should_scale && scale_data->height_scale < 1 && - scale_data->width_scale == 1) { - scale_data->should_scale = false; + if (buffer_data->should_scale && buffer_data->height_scale < 1 && + buffer_data->width_scale == 1) { + buffer_data->should_scale = false; } struct wlr_scene_surface *scene_surface = @@ -142,34 +142,34 @@ void scene_buffer_apply_effect(struct wlr_scene_buffer *buffer, int sx, int sy, struct wlr_surface *surface = scene_surface->surface; - if (scale_data->should_scale) { + if (buffer_data->should_scale) { unsigned int surface_width = surface->current.width; unsigned int surface_height = surface->current.height; - surface_width = scale_data->width_scale < 1 + surface_width = buffer_data->width_scale < 1 ? surface_width - : scale_data->width_scale * surface_width; - surface_height = scale_data->height_scale < 1 + : buffer_data->width_scale * surface_width; + surface_height = buffer_data->height_scale < 1 ? surface_height - : scale_data->height_scale * surface_height; + : buffer_data->height_scale * surface_height; - if (surface_width > scale_data->width && + if (surface_width > buffer_data->width && wlr_subsurface_try_from_wlr_surface(surface) == NULL) { - surface_width = scale_data->width; + surface_width = buffer_data->width; } - if (surface_height > scale_data->height && + if (surface_height > buffer_data->height && wlr_subsurface_try_from_wlr_surface(surface) == NULL) { - surface_height = scale_data->height; + surface_height = buffer_data->height; } - if (surface_width > scale_data->width && + if (surface_width > buffer_data->width && wlr_subsurface_try_from_wlr_surface(surface) != NULL) { return; } - if (surface_height > scale_data->height && + if (surface_height > buffer_data->height && wlr_subsurface_try_from_wlr_surface(surface) != NULL) { return; } @@ -184,14 +184,14 @@ void scene_buffer_apply_effect(struct wlr_scene_buffer *buffer, int sx, int sy, if (wlr_xdg_popup_try_from_wlr_surface(surface) != NULL) return; - float target_opacity = scale_data->percent + fadein_begin_opacity; - if (target_opacity > scale_data->opacity) { - target_opacity = scale_data->opacity; + float target_opacity = buffer_data->percent + fadein_begin_opacity; + if (target_opacity > buffer_data->opacity) { + target_opacity = buffer_data->opacity; } wlr_scene_buffer_set_opacity(buffer, target_opacity); } -void buffer_set_effect(Client *c, animationScale data) { +void buffer_set_effect(Client *c, BufferData data) { if (!c || c->iskilling) return; @@ -373,7 +373,7 @@ void client_apply_clip(Client *c, float factor) { struct wlr_box clip_box; bool should_render_client_surface = false; struct ivec2 offset; - animationScale scale_data; + BufferData buffer_data; float opacity, percent; int bw = (int)c->bw; @@ -400,7 +400,7 @@ void client_apply_clip(Client *c, float factor) { wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip_box); - buffer_set_effect(c, (animationScale){1.0f, 1.0f, clip_box.width, + buffer_set_effect(c, (BufferData){1.0f, 1.0f, clip_box.width, clip_box.height, opacity, opacity, true}); return; @@ -463,31 +463,31 @@ void client_apply_clip(Client *c, float factor) { if (acutal_surface_width <= 0 || acutal_surface_height <= 0) return; - scale_data.should_scale = true; - scale_data.width = clip_box.width; - scale_data.height = clip_box.height; - scale_data.width_scale = (float)scale_data.width / acutal_surface_width; - scale_data.height_scale = (float)scale_data.height / acutal_surface_height; - scale_data.percent = percent; - scale_data.opacity = opacity; + buffer_data.should_scale = true; + buffer_data.width = clip_box.width; + buffer_data.height = clip_box.height; + buffer_data.width_scale = (float)buffer_data.width / acutal_surface_width; + buffer_data.height_scale = (float)buffer_data.height / acutal_surface_height; + buffer_data.percent = percent; + buffer_data.opacity = opacity; if (factor == 1.0) { - scale_data.width_scale = 1.0; - scale_data.height_scale = 1.0; + buffer_data.width_scale = 1.0; + buffer_data.height_scale = 1.0; } else { - scale_data.width_scale = (float)scale_data.width / acutal_surface_width; - scale_data.height_scale = - (float)scale_data.height / acutal_surface_height; + buffer_data.width_scale = (float)buffer_data.width / acutal_surface_width; + buffer_data.height_scale = + (float)buffer_data.height / acutal_surface_height; } - buffer_set_effect(c, scale_data); + buffer_set_effect(c, buffer_data); } void fadeout_client_animation_next_tick(Client *c) { if (!c) return; - animationScale scale_data; + BufferData buffer_data; double animation_passed = (double)c->animation.passed_frames / c->animation.total_frames; @@ -525,13 +525,13 @@ void fadeout_client_animation_next_tick(Client *c) { (!c->animation_type_close && strcmp(animation_type_close, "zoom") == 0)) { - scale_data.width = width; - scale_data.height = height; - scale_data.width_scale = animation_passed; - scale_data.height_scale = animation_passed; + buffer_data.width = width; + buffer_data.height = height; + buffer_data.width_scale = animation_passed; + buffer_data.height_scale = animation_passed; wlr_scene_node_for_each_buffer( - &c->scene->node, snap_scene_buffer_apply_effect, &scale_data); + &c->scene->node, snap_scene_buffer_apply_effect, &buffer_data); } if (animation_passed == 1.0) { diff --git a/src/animation/layer.h b/src/animation/layer.h index c353ce7..53ccb21 100644 --- a/src/animation/layer.h +++ b/src/animation/layer.h @@ -154,7 +154,7 @@ void set_layer_dir_animaiton(LayerSurface *l, struct wlr_box *geo) { void layer_scene_buffer_apply_effect(struct wlr_scene_buffer *buffer, int sx, int sy, void *data) { - animationScale *scale_data = (animationScale *)data; + BufferData *buffer_data = (BufferData *)data; struct wlr_scene_surface *scene_surface = wlr_scene_surface_try_from_buffer(buffer); @@ -165,9 +165,9 @@ void layer_scene_buffer_apply_effect(struct wlr_scene_buffer *buffer, int sx, struct wlr_surface *surface = scene_surface->surface; unsigned int surface_width = - surface->current.width * scale_data->width_scale; + surface->current.width * buffer_data->width_scale; unsigned int surface_height = - surface->current.height * scale_data->height_scale; + surface->current.height * buffer_data->height_scale; if (surface_height > 0 && surface_width > 0) { wlr_scene_buffer_set_dest_size(buffer, surface_width, surface_height); @@ -176,9 +176,9 @@ void layer_scene_buffer_apply_effect(struct wlr_scene_buffer *buffer, int sx, void layer_fadeout_scene_buffer_apply_effect(struct wlr_scene_buffer *buffer, int sx, int sy, void *data) { - animationScale *scale_data = (animationScale *)data; - wlr_scene_buffer_set_dest_size(buffer, scale_data->width, - scale_data->height); + BufferData *buffer_data = (BufferData *)data; + wlr_scene_buffer_set_dest_size(buffer, buffer_data->width, + buffer_data->height); } void fadeout_layer_animation_next_tick(LayerSurface *l) { @@ -203,9 +203,9 @@ void fadeout_layer_animation_next_tick(LayerSurface *l) { wlr_scene_node_set_position(&l->scene->node, x, y); - animationScale scale_data; - scale_data.width = width; - scale_data.height = height; + BufferData buffer_data; + buffer_data.width = width; + buffer_data.height = height; if ((!l->animation_type_close && strcmp(layer_animation_type_close, "zoom") == 0) || @@ -213,7 +213,7 @@ void fadeout_layer_animation_next_tick(LayerSurface *l) { strcmp(l->animation_type_close, "zoom") == 0)) { wlr_scene_node_for_each_buffer(&l->scene->node, layer_fadeout_scene_buffer_apply_effect, - &scale_data); + &buffer_data); } l->animation.current = (struct wlr_box){ @@ -270,13 +270,13 @@ void layer_animation_next_tick(LayerSurface *l) { wlr_scene_node_set_position(&l->scene->node, x, y); - animationScale scale_data; + BufferData buffer_data; if (factor == 1.0) { - scale_data.width_scale = 1.0f; - scale_data.height_scale = 1.0f; + buffer_data.width_scale = 1.0f; + buffer_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; + buffer_data.width_scale = (float)width / (float)l->current.width; + buffer_data.height_scale = (float)height / (float)l->current.height; } if ((!l->animation_type_open && @@ -284,7 +284,7 @@ void layer_animation_next_tick(LayerSurface *l) { (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); + &l->scene->node, layer_scene_buffer_apply_effect, &buffer_data); } l->animation.current = (struct wlr_box){ diff --git a/src/mango.c b/src/mango.c index e594a09..a9aa928 100644 --- a/src/mango.c +++ b/src/mango.c @@ -217,7 +217,7 @@ typedef struct { double percent; float opacity; bool should_scale; -} animationScale; +} BufferData; typedef struct Client Client; struct Client { @@ -625,7 +625,7 @@ static void scene_buffer_apply_opacity(struct wlr_scene_buffer *buffer, int sx, static Client *direction_select(const Arg *arg); static void view_in_mon(const Arg *arg, bool want_animation, Monitor *m); -static void buffer_set_effect(Client *c, animationScale scale_data); +static void buffer_set_effect(Client *c, BufferData buffer_data); static void snap_scene_buffer_apply_effect(struct wlr_scene_buffer *buffer, int sx, int sy, void *data); static void client_set_pending_state(Client *c);