opt code struct
This commit is contained in:
@@ -130,6 +130,7 @@ typedef struct {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int animations;
|
int animations;
|
||||||
|
int layer_animations;
|
||||||
char animation_type_open[10];
|
char animation_type_open[10];
|
||||||
char animation_type_close[10];
|
char animation_type_close[10];
|
||||||
int animation_fade_in;
|
int animation_fade_in;
|
||||||
@@ -832,6 +833,8 @@ void parse_config_line(Config *config, const char *line) {
|
|||||||
|
|
||||||
if (strcmp(key, "animations") == 0) {
|
if (strcmp(key, "animations") == 0) {
|
||||||
config->animations = atoi(value);
|
config->animations = atoi(value);
|
||||||
|
} else if (strcmp(key, "layer_animations") == 0) {
|
||||||
|
config->layer_animations = atoi(value);
|
||||||
} else if (strcmp(key, "animation_type_open") == 0) {
|
} else if (strcmp(key, "animation_type_open") == 0) {
|
||||||
snprintf(config->animation_type_open,
|
snprintf(config->animation_type_open,
|
||||||
sizeof(config->animation_type_open), "%.9s",
|
sizeof(config->animation_type_open), "%.9s",
|
||||||
@@ -2057,6 +2060,7 @@ void free_config(void) {
|
|||||||
void override_config(void) {
|
void override_config(void) {
|
||||||
// 动画启用
|
// 动画启用
|
||||||
animations = CLAMP_INT(config.animations, 0, 1);
|
animations = CLAMP_INT(config.animations, 0, 1);
|
||||||
|
layer_animations = CLAMP_INT(config.layer_animations, 0, 1);
|
||||||
|
|
||||||
// 标签动画方向
|
// 标签动画方向
|
||||||
tag_animation_direction = CLAMP_INT(config.tag_animation_direction, 0, 1);
|
tag_animation_direction = CLAMP_INT(config.tag_animation_direction, 0, 1);
|
||||||
@@ -2199,6 +2203,7 @@ void override_config(void) {
|
|||||||
void set_value_default() {
|
void set_value_default() {
|
||||||
/* animaion */
|
/* animaion */
|
||||||
config.animations = animations; // 是否启用动画
|
config.animations = animations; // 是否启用动画
|
||||||
|
config.layer_animations = layer_animations; // 是否启用layer动画
|
||||||
config.animation_fade_in = animation_fade_in; // Enable animation fade in
|
config.animation_fade_in = animation_fade_in; // Enable animation fade in
|
||||||
config.animation_fade_out = animation_fade_out; // Enable animation fade out
|
config.animation_fade_out = animation_fade_out; // Enable animation fade out
|
||||||
config.tag_animation_direction = tag_animation_direction; // 标签动画方向
|
config.tag_animation_direction = tag_animation_direction; // 标签动画方向
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
char *animation_type_open = "slide"; // 是否启用动画 //slide,zoom
|
char *animation_type_open = "slide"; // 是否启用动画 //slide,zoom
|
||||||
char *animation_type_close = "slide"; // 是否启用动画 //slide,zoom
|
char *animation_type_close = "slide"; // 是否启用动画 //slide,zoom
|
||||||
int animations = 1; // 是否启用动画
|
int animations = 1; // 是否启用动画
|
||||||
int layer_animaitons = 1; // 是否启用layer动画
|
int layer_animations = 1; // 是否启用layer动画
|
||||||
int tag_animation_direction = HORIZONTAL; // 标签动画方向
|
int tag_animation_direction = HORIZONTAL; // 标签动画方向
|
||||||
int animation_fade_in = 1; // Enable animation fade in
|
int animation_fade_in = 1; // Enable animation fade in
|
||||||
int animation_fade_out = 1; // Enable animation fade out
|
int animation_fade_out = 1; // Enable animation fade out
|
||||||
|
|||||||
40
src/maomao.c
40
src/maomao.c
@@ -1033,6 +1033,7 @@ void layer_animation_next_tick(LayerSurface *l) {
|
|||||||
if (animation_passed == 1.0) {
|
if (animation_passed == 1.0) {
|
||||||
l->animation.running = false;
|
l->animation.running = false;
|
||||||
l->need_output_flush = false;
|
l->need_output_flush = false;
|
||||||
|
l->animation.action = MOVE;
|
||||||
} else {
|
} else {
|
||||||
l->animation.passed_frames++;
|
l->animation.passed_frames++;
|
||||||
}
|
}
|
||||||
@@ -1486,7 +1487,7 @@ bool layer_draw_frame(LayerSurface *l) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (animations && l->animation.running && !l->noanim) {
|
if (animations && layer_animations && l->animation.running && !l->noanim) {
|
||||||
layer_animation_next_tick(l);
|
layer_animation_next_tick(l);
|
||||||
} else {
|
} else {
|
||||||
wlr_scene_node_set_position(&l->scene->node, l->geom.x, l->geom.y);
|
wlr_scene_node_set_position(&l->scene->node, l->geom.x, l->geom.y);
|
||||||
@@ -3173,17 +3174,8 @@ static void iter_layer_scene_buffers(struct wlr_scene_buffer *buffer, int sx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void maplayersurfacenotify(struct wl_listener *listener, void *data) {
|
void get_layer_target_geometry(LayerSurface *l, struct wlr_box *target_box) {
|
||||||
int ji;
|
const struct wlr_layer_surface_v1_state *state = &l->layer_surface->current;
|
||||||
LayerSurface *l = wl_container_of(listener, l, map);
|
|
||||||
if (!l->mon)
|
|
||||||
return;
|
|
||||||
struct wlr_layer_surface_v1 *layer_surface = l->layer_surface;
|
|
||||||
const struct wlr_layer_surface_v1_state *state = &layer_surface->current;
|
|
||||||
strncpy(l->mon->last_surface_ws_name, layer_surface->namespace,
|
|
||||||
sizeof(l->mon->last_surface_ws_name) - 1); // 最多拷贝255个字符
|
|
||||||
l->mon->last_surface_ws_name[sizeof(l->mon->last_surface_ws_name) - 1] =
|
|
||||||
'\0'; // 确保字符串以null结尾
|
|
||||||
|
|
||||||
// 计算几何位置
|
// 计算几何位置
|
||||||
struct wlr_box bounds;
|
struct wlr_box bounds;
|
||||||
@@ -3249,6 +3241,26 @@ void maplayersurfacenotify(struct wl_listener *listener, void *data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
target_box->x = box.x;
|
||||||
|
target_box->y = box.y;
|
||||||
|
target_box->width = box.width;
|
||||||
|
target_box->height = box.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
void maplayersurfacenotify(struct wl_listener *listener, void *data) {
|
||||||
|
int ji;
|
||||||
|
LayerSurface *l = wl_container_of(listener, l, map);
|
||||||
|
if (!l->mon)
|
||||||
|
return;
|
||||||
|
struct wlr_layer_surface_v1 *layer_surface = l->layer_surface;
|
||||||
|
strncpy(l->mon->last_surface_ws_name, layer_surface->namespace,
|
||||||
|
sizeof(l->mon->last_surface_ws_name) - 1); // 最多拷贝255个字符
|
||||||
|
l->mon->last_surface_ws_name[sizeof(l->mon->last_surface_ws_name) - 1] =
|
||||||
|
'\0'; // 确保字符串以null结尾
|
||||||
|
|
||||||
|
struct wlr_box box;
|
||||||
|
get_layer_target_geometry(l, &box);
|
||||||
|
|
||||||
// 更新几何位置
|
// 更新几何位置
|
||||||
l->geom = box;
|
l->geom = box;
|
||||||
l->noanim = 0;
|
l->noanim = 0;
|
||||||
@@ -3353,7 +3365,7 @@ void layer_set_pending_state(LayerSurface *l) {
|
|||||||
l->pending = l->geom;
|
l->pending = l->geom;
|
||||||
set_layer_open_animaiton(l, l->geom);
|
set_layer_open_animaiton(l, l->geom);
|
||||||
// 判断是否需要动画
|
// 判断是否需要动画
|
||||||
if (!animations || l->noanim ||
|
if (!animations || !layer_animations || l->noanim ||
|
||||||
l->layer_surface->current.layer ==
|
l->layer_surface->current.layer ==
|
||||||
ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND ||
|
ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND ||
|
||||||
l->layer_surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM) {
|
l->layer_surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM) {
|
||||||
@@ -7348,7 +7360,7 @@ void unmaplayersurfacenotify(struct wl_listener *listener, void *data) {
|
|||||||
|
|
||||||
void init_fadeout_layers(LayerSurface *l) {
|
void init_fadeout_layers(LayerSurface *l) {
|
||||||
|
|
||||||
if (!layer_animaitons || l->noanim) {
|
if (!layer_animations || l->noanim) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user