mirror of
				https://github.com/DreamMaoMao/maomaowm.git
				synced 2025-11-03 09:01:47 -05:00 
			
		
		
		
	feat: layer open and close type set support
This commit is contained in:
		
							parent
							
								
									43dba2151e
								
							
						
					
					
						commit
						02d70831b5
					
				
					 4 changed files with 64 additions and 18 deletions
				
			
		| 
						 | 
					@ -318,14 +318,16 @@ void init_fadeout_layers(LayerSurface *l) {
 | 
				
			||||||
	fadeout_layer->animation.initial.x = 0;
 | 
						fadeout_layer->animation.initial.x = 0;
 | 
				
			||||||
	fadeout_layer->animation.initial.y = 0;
 | 
						fadeout_layer->animation.initial.y = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (strcmp(animation_type_close, "zoom") == 0 ||
 | 
						if ((!l->animation_type_close &&
 | 
				
			||||||
		strcmp(animation_type_close, "fade") == 0) {
 | 
							 strcmp(layer_animation_type_close, "slide") == 0) ||
 | 
				
			||||||
		fadeout_layer->current.x = 0;
 | 
							(l->animation_type_close &&
 | 
				
			||||||
		fadeout_layer->current.y = 0;
 | 
							 strcmp(l->animation_type_close, "slide") == 0)) {
 | 
				
			||||||
	} else {
 | 
					 | 
				
			||||||
		set_layer_dir_animaiton(l, &fadeout_layer->current);
 | 
							set_layer_dir_animaiton(l, &fadeout_layer->current);
 | 
				
			||||||
		fadeout_layer->current.x = fadeout_layer->current.x - l->geom.x;
 | 
							fadeout_layer->current.x = fadeout_layer->current.x - l->geom.x;
 | 
				
			||||||
		fadeout_layer->current.y = fadeout_layer->current.y - l->geom.y;
 | 
							fadeout_layer->current.y = fadeout_layer->current.y - l->geom.y;
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							fadeout_layer->current.x = 0;
 | 
				
			||||||
 | 
							fadeout_layer->current.y = 0;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	fadeout_layer->animation.passed_frames = 0;
 | 
						fadeout_layer->animation.passed_frames = 0;
 | 
				
			||||||
| 
						 | 
					@ -342,12 +344,15 @@ void layer_set_pending_state(LayerSurface *l) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	l->pending = l->geom;
 | 
						l->pending = l->geom;
 | 
				
			||||||
	if (l->animation.action == OPEN) {
 | 
						if (l->animation.action == OPEN) {
 | 
				
			||||||
		if (strcmp(animation_type_open, "fade") == 0 ||
 | 
							if ((!l->animation_type_open &&
 | 
				
			||||||
			strcmp(animation_type_open, "zoom") == 0) {
 | 
								 strcmp(layer_animation_type_open, "slide") == 0) ||
 | 
				
			||||||
 | 
								(l->animation_type_open &&
 | 
				
			||||||
 | 
								 strcmp(l->animation_type_open, "slide") == 0)) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								set_layer_dir_animaiton(l, &l->animainit_geom);
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
			l->animainit_geom.x = l->geom.x;
 | 
								l->animainit_geom.x = l->geom.x;
 | 
				
			||||||
			l->animainit_geom.y = l->geom.y;
 | 
								l->animainit_geom.y = l->geom.y;
 | 
				
			||||||
		} else {
 | 
					 | 
				
			||||||
			set_layer_dir_animaiton(l, &l->animainit_geom);
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		l->animainit_geom = l->animation.current;
 | 
							l->animainit_geom = l->animation.current;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -42,6 +42,8 @@ typedef struct {
 | 
				
			||||||
	float scroller_proportion;
 | 
						float scroller_proportion;
 | 
				
			||||||
	const char *animation_type_open;
 | 
						const char *animation_type_open;
 | 
				
			||||||
	const char *animation_type_close;
 | 
						const char *animation_type_close;
 | 
				
			||||||
 | 
						const char *layer_animation_type_open;
 | 
				
			||||||
 | 
						const char *layer_animation_type_close;
 | 
				
			||||||
	int isnoborder;
 | 
						int isnoborder;
 | 
				
			||||||
	int isopensilent;
 | 
						int isopensilent;
 | 
				
			||||||
	int isnamedscratchpad;
 | 
						int isnamedscratchpad;
 | 
				
			||||||
| 
						 | 
					@ -125,6 +127,8 @@ typedef struct {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct {
 | 
					typedef struct {
 | 
				
			||||||
	char *layer_name; // 布局名称
 | 
						char *layer_name; // 布局名称
 | 
				
			||||||
 | 
						char *animation_type_open;
 | 
				
			||||||
 | 
						char *animation_type_close;
 | 
				
			||||||
	int noblur;
 | 
						int noblur;
 | 
				
			||||||
	int noanim;
 | 
						int noanim;
 | 
				
			||||||
	int noshadow;
 | 
						int noshadow;
 | 
				
			||||||
| 
						 | 
					@ -135,6 +139,8 @@ typedef struct {
 | 
				
			||||||
	int layer_animations;
 | 
						int layer_animations;
 | 
				
			||||||
	char animation_type_open[10];
 | 
						char animation_type_open[10];
 | 
				
			||||||
	char animation_type_close[10];
 | 
						char animation_type_close[10];
 | 
				
			||||||
 | 
						char layer_animation_type_open[10];
 | 
				
			||||||
 | 
						char layer_animation_type_close[10];
 | 
				
			||||||
	int animation_fade_in;
 | 
						int animation_fade_in;
 | 
				
			||||||
	int animation_fade_out;
 | 
						int animation_fade_out;
 | 
				
			||||||
	int tag_animation_direction;
 | 
						int tag_animation_direction;
 | 
				
			||||||
| 
						 | 
					@ -859,6 +865,14 @@ void parse_config_line(Config *config, const char *line) {
 | 
				
			||||||
		snprintf(config->animation_type_close,
 | 
							snprintf(config->animation_type_close,
 | 
				
			||||||
				 sizeof(config->animation_type_close), "%.9s",
 | 
									 sizeof(config->animation_type_close), "%.9s",
 | 
				
			||||||
				 value); // string limit to 9 char
 | 
									 value); // string limit to 9 char
 | 
				
			||||||
 | 
						} else if (strcmp(key, "layer_animation_type_open") == 0) {
 | 
				
			||||||
 | 
							snprintf(config->layer_animation_type_open,
 | 
				
			||||||
 | 
									 sizeof(config->layer_animation_type_open), "%.9s",
 | 
				
			||||||
 | 
									 value); // string limit to 9 char
 | 
				
			||||||
 | 
						} else if (strcmp(key, "layer_animation_type_close") == 0) {
 | 
				
			||||||
 | 
							snprintf(config->layer_animation_type_close,
 | 
				
			||||||
 | 
									 sizeof(config->layer_animation_type_close), "%.9s",
 | 
				
			||||||
 | 
									 value); // string limit to 9 char
 | 
				
			||||||
	} else if (strcmp(key, "animation_fade_in") == 0) {
 | 
						} else if (strcmp(key, "animation_fade_in") == 0) {
 | 
				
			||||||
		config->animation_fade_in = atoi(value);
 | 
							config->animation_fade_in = atoi(value);
 | 
				
			||||||
	} else if (strcmp(key, "animation_fade_out") == 0) {
 | 
						} else if (strcmp(key, "animation_fade_out") == 0) {
 | 
				
			||||||
| 
						 | 
					@ -1336,6 +1350,8 @@ void parse_config_line(Config *config, const char *line) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// 设置默认值
 | 
							// 设置默认值
 | 
				
			||||||
		rule->layer_name = NULL;
 | 
							rule->layer_name = NULL;
 | 
				
			||||||
 | 
							rule->animation_type_open = NULL;
 | 
				
			||||||
 | 
							rule->animation_type_close = NULL;
 | 
				
			||||||
		rule->noblur = 0;
 | 
							rule->noblur = 0;
 | 
				
			||||||
		rule->noanim = 0;
 | 
							rule->noanim = 0;
 | 
				
			||||||
		rule->noshadow = 0;
 | 
							rule->noshadow = 0;
 | 
				
			||||||
| 
						 | 
					@ -1353,6 +1369,10 @@ void parse_config_line(Config *config, const char *line) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				if (strcmp(key, "layer_name") == 0) {
 | 
									if (strcmp(key, "layer_name") == 0) {
 | 
				
			||||||
					rule->layer_name = strdup(val);
 | 
										rule->layer_name = strdup(val);
 | 
				
			||||||
 | 
									} else if (strcmp(key, "animation_type_open") == 0) {
 | 
				
			||||||
 | 
										rule->animation_type_open = strdup(val);
 | 
				
			||||||
 | 
									} else if (strcmp(key, "animation_type_close") == 0) {
 | 
				
			||||||
 | 
										rule->animation_type_close = strdup(val);
 | 
				
			||||||
				} else if (strcmp(key, "noblur") == 0) {
 | 
									} else if (strcmp(key, "noblur") == 0) {
 | 
				
			||||||
					rule->noblur = CLAMP_INT(atoi(val), 0, 1);
 | 
										rule->noblur = CLAMP_INT(atoi(val), 0, 1);
 | 
				
			||||||
				} else if (strcmp(key, "noanim") == 0) {
 | 
									} else if (strcmp(key, "noanim") == 0) {
 | 
				
			||||||
| 
						 | 
					@ -2056,7 +2076,12 @@ void free_config(void) {
 | 
				
			||||||
	// 释放 layer_rules
 | 
						// 释放 layer_rules
 | 
				
			||||||
	if (config.layer_rules) {
 | 
						if (config.layer_rules) {
 | 
				
			||||||
		for (int i = 0; i < config.layer_rules_count; i++) {
 | 
							for (int i = 0; i < config.layer_rules_count; i++) {
 | 
				
			||||||
 | 
								if (config.layer_rules[i].layer_name)
 | 
				
			||||||
				free((void *)config.layer_rules[i].layer_name);
 | 
									free((void *)config.layer_rules[i].layer_name);
 | 
				
			||||||
 | 
								if (config.layer_rules[i].animation_type_open)
 | 
				
			||||||
 | 
									free((void *)config.layer_rules[i].animation_type_open);
 | 
				
			||||||
 | 
								if (config.layer_rules[i].animation_type_close)
 | 
				
			||||||
 | 
									free((void *)config.layer_rules[i].animation_type_close);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		free(config.layer_rules);
 | 
							free(config.layer_rules);
 | 
				
			||||||
		config.layer_rules = NULL;
 | 
							config.layer_rules = NULL;
 | 
				
			||||||
| 
						 | 
					@ -2122,6 +2147,10 @@ void override_config(void) {
 | 
				
			||||||
	animation_type_open = config.animation_type_open;
 | 
						animation_type_open = config.animation_type_open;
 | 
				
			||||||
	animation_type_close = config.animation_type_close;
 | 
						animation_type_close = config.animation_type_close;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// layer打开关闭动画类型
 | 
				
			||||||
 | 
						layer_animation_type_open = config.layer_animation_type_open;
 | 
				
			||||||
 | 
						layer_animation_type_close = config.layer_animation_type_close;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// 动画时间限制在合理范围(1-50000ms)
 | 
						// 动画时间限制在合理范围(1-50000ms)
 | 
				
			||||||
	animation_duration_move =
 | 
						animation_duration_move =
 | 
				
			||||||
		CLAMP_INT(config.animation_duration_move, 1, 50000);
 | 
							CLAMP_INT(config.animation_duration_move, 1, 50000);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,6 +10,8 @@
 | 
				
			||||||
/* animaion */
 | 
					/* animaion */
 | 
				
			||||||
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
 | 
				
			||||||
 | 
					char *layer_animation_type_open = "slide";	// 是否启用layer动画 //slide,zoom
 | 
				
			||||||
 | 
					char *layer_animation_type_close = "slide"; // 是否启用layer动画 //slide,zoom
 | 
				
			||||||
int animations = 1;							// 是否启用动画
 | 
					int animations = 1;							// 是否启用动画
 | 
				
			||||||
int layer_animations = 0;					// 是否启用layer动画
 | 
					int layer_animations = 0;					// 是否启用layer动画
 | 
				
			||||||
int tag_animation_direction = HORIZONTAL;	// 标签动画方向
 | 
					int tag_animation_direction = HORIZONTAL;	// 标签动画方向
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										10
									
								
								src/maomao.c
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								src/maomao.c
									
										
									
									
									
								
							| 
						 | 
					@ -377,6 +377,8 @@ typedef struct {
 | 
				
			||||||
	int noblur;
 | 
						int noblur;
 | 
				
			||||||
	int noanim;
 | 
						int noanim;
 | 
				
			||||||
	int noshadow;
 | 
						int noshadow;
 | 
				
			||||||
 | 
						char *animation_type_open;
 | 
				
			||||||
 | 
						char *animation_type_close;
 | 
				
			||||||
	bool need_output_flush;
 | 
						bool need_output_flush;
 | 
				
			||||||
} LayerSurface;
 | 
					} LayerSurface;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2531,6 +2533,14 @@ void maplayersurfacenotify(struct wl_listener *listener, void *data) {
 | 
				
			||||||
			if (config.layer_rules[ji].noshadow > 0) {
 | 
								if (config.layer_rules[ji].noshadow > 0) {
 | 
				
			||||||
				l->noshadow = 1;
 | 
									l->noshadow = 1;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
								if (config.layer_rules[ji].animation_type_open) {
 | 
				
			||||||
 | 
									l->animation_type_open =
 | 
				
			||||||
 | 
										config.layer_rules[ji].animation_type_open;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								if (config.layer_rules[ji].animation_type_close) {
 | 
				
			||||||
 | 
									l->animation_type_close =
 | 
				
			||||||
 | 
										config.layer_rules[ji].animation_type_close;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue