mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2025-10-29 05:40:21 -04:00
opt: change struct type name animationScale to BufferData
This commit is contained in:
parent
aa85026da7
commit
17071783aa
3 changed files with 70 additions and 69 deletions
|
|
@ -130,28 +130,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 =
|
||||
|
|
@ -162,34 +162,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;
|
||||
}
|
||||
|
|
@ -205,16 +205,16 @@ void scene_buffer_apply_effect(struct wlr_scene_buffer *buffer, int sx, int sy,
|
|||
return;
|
||||
|
||||
wlr_scene_buffer_set_corner_radius(buffer, border_radius,
|
||||
scale_data->corner_location);
|
||||
buffer_data->corner_location);
|
||||
|
||||
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;
|
||||
|
|
@ -497,7 +497,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;
|
||||
|
||||
enum corner_location current_corner_location =
|
||||
|
|
@ -527,9 +527,9 @@ 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,
|
||||
clip_box.height, opacity, opacity,
|
||||
current_corner_location, true});
|
||||
buffer_set_effect(c, (BufferData){1.0f, 1.0f, clip_box.width,
|
||||
clip_box.height, opacity, opacity,
|
||||
current_corner_location, true});
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -591,30 +591,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.corner_location = current_corner_location;
|
||||
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.corner_location = current_corner_location;
|
||||
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;
|
||||
|
|
@ -652,13 +653,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) {
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ void layer_draw_shadow(LayerSurface *l) {
|
|||
|
||||
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);
|
||||
|
|
@ -214,9 +214,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);
|
||||
|
|
@ -225,9 +225,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) {
|
||||
|
|
@ -252,9 +252,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) ||
|
||||
|
|
@ -262,7 +262,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){
|
||||
|
|
@ -319,13 +319,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 &&
|
||||
|
|
@ -333,7 +333,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){
|
||||
|
|
|
|||
|
|
@ -223,7 +223,7 @@ typedef struct {
|
|||
float opacity;
|
||||
enum corner_location corner_location;
|
||||
bool should_scale;
|
||||
} animationScale;
|
||||
} BufferData;
|
||||
|
||||
typedef struct Client Client;
|
||||
struct Client {
|
||||
|
|
@ -627,7 +627,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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue