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.y = 0;
 | 
			
		||||
 | 
			
		||||
	if (strcmp(animation_type_close, "zoom") == 0 ||
 | 
			
		||||
		strcmp(animation_type_close, "fade") == 0) {
 | 
			
		||||
		fadeout_layer->current.x = 0;
 | 
			
		||||
		fadeout_layer->current.y = 0;
 | 
			
		||||
	} else {
 | 
			
		||||
	if ((!l->animation_type_close &&
 | 
			
		||||
		 strcmp(layer_animation_type_close, "slide") == 0) ||
 | 
			
		||||
		(l->animation_type_close &&
 | 
			
		||||
		 strcmp(l->animation_type_close, "slide") == 0)) {
 | 
			
		||||
		set_layer_dir_animaiton(l, &fadeout_layer->current);
 | 
			
		||||
		fadeout_layer->current.x = fadeout_layer->current.x - l->geom.x;
 | 
			
		||||
		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;
 | 
			
		||||
| 
						 | 
				
			
			@ -342,12 +344,15 @@ void layer_set_pending_state(LayerSurface *l) {
 | 
			
		|||
 | 
			
		||||
	l->pending = l->geom;
 | 
			
		||||
	if (l->animation.action == OPEN) {
 | 
			
		||||
		if (strcmp(animation_type_open, "fade") == 0 ||
 | 
			
		||||
			strcmp(animation_type_open, "zoom") == 0) {
 | 
			
		||||
		if ((!l->animation_type_open &&
 | 
			
		||||
			 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.y = l->geom.y;
 | 
			
		||||
		} else {
 | 
			
		||||
			set_layer_dir_animaiton(l, &l->animainit_geom);
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		l->animainit_geom = l->animation.current;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -42,6 +42,8 @@ typedef struct {
 | 
			
		|||
	float scroller_proportion;
 | 
			
		||||
	const char *animation_type_open;
 | 
			
		||||
	const char *animation_type_close;
 | 
			
		||||
	const char *layer_animation_type_open;
 | 
			
		||||
	const char *layer_animation_type_close;
 | 
			
		||||
	int isnoborder;
 | 
			
		||||
	int isopensilent;
 | 
			
		||||
	int isnamedscratchpad;
 | 
			
		||||
| 
						 | 
				
			
			@ -125,6 +127,8 @@ typedef struct {
 | 
			
		|||
 | 
			
		||||
typedef struct {
 | 
			
		||||
	char *layer_name; // 布局名称
 | 
			
		||||
	char *animation_type_open;
 | 
			
		||||
	char *animation_type_close;
 | 
			
		||||
	int noblur;
 | 
			
		||||
	int noanim;
 | 
			
		||||
	int noshadow;
 | 
			
		||||
| 
						 | 
				
			
			@ -135,6 +139,8 @@ typedef struct {
 | 
			
		|||
	int layer_animations;
 | 
			
		||||
	char animation_type_open[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_out;
 | 
			
		||||
	int tag_animation_direction;
 | 
			
		||||
| 
						 | 
				
			
			@ -859,6 +865,14 @@ void parse_config_line(Config *config, const char *line) {
 | 
			
		|||
		snprintf(config->animation_type_close,
 | 
			
		||||
				 sizeof(config->animation_type_close), "%.9s",
 | 
			
		||||
				 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) {
 | 
			
		||||
		config->animation_fade_in = atoi(value);
 | 
			
		||||
	} 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->animation_type_open = NULL;
 | 
			
		||||
		rule->animation_type_close = NULL;
 | 
			
		||||
		rule->noblur = 0;
 | 
			
		||||
		rule->noanim = 0;
 | 
			
		||||
		rule->noshadow = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -1353,6 +1369,10 @@ void parse_config_line(Config *config, const char *line) {
 | 
			
		|||
 | 
			
		||||
				if (strcmp(key, "layer_name") == 0) {
 | 
			
		||||
					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) {
 | 
			
		||||
					rule->noblur = CLAMP_INT(atoi(val), 0, 1);
 | 
			
		||||
				} else if (strcmp(key, "noanim") == 0) {
 | 
			
		||||
| 
						 | 
				
			
			@ -2056,7 +2076,12 @@ void free_config(void) {
 | 
			
		|||
	// 释放 layer_rules
 | 
			
		||||
	if (config.layer_rules) {
 | 
			
		||||
		for (int i = 0; i < config.layer_rules_count; i++) {
 | 
			
		||||
			free((void *)config.layer_rules[i].layer_name);
 | 
			
		||||
			if (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);
 | 
			
		||||
		config.layer_rules = NULL;
 | 
			
		||||
| 
						 | 
				
			
			@ -2122,6 +2147,10 @@ void override_config(void) {
 | 
			
		|||
	animation_type_open = config.animation_type_open;
 | 
			
		||||
	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)
 | 
			
		||||
	animation_duration_move =
 | 
			
		||||
		CLAMP_INT(config.animation_duration_move, 1, 50000);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,14 +8,16 @@
 | 
			
		|||
	 ((hex >> 8) & 0xFF) / 255.0f, (hex & 0xFF) / 255.0f}
 | 
			
		||||
 | 
			
		||||
/* animaion */
 | 
			
		||||
char *animation_type_open = "slide";	  // 是否启用动画 //slide,zoom
 | 
			
		||||
char *animation_type_close = "slide";	  // 是否启用动画 //slide,zoom
 | 
			
		||||
int animations = 1;						  // 是否启用动画
 | 
			
		||||
int layer_animations = 0;				  // 是否启用layer动画
 | 
			
		||||
int tag_animation_direction = HORIZONTAL; // 标签动画方向
 | 
			
		||||
int animation_fade_in = 1;				  // Enable animation fade in
 | 
			
		||||
int animation_fade_out = 1;				  // Enable animation fade out
 | 
			
		||||
float zoom_initial_ratio = 0.5;			  // 动画起始窗口比例
 | 
			
		||||
char *animation_type_open = "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 layer_animations = 0;					// 是否启用layer动画
 | 
			
		||||
int tag_animation_direction = HORIZONTAL;	// 标签动画方向
 | 
			
		||||
int animation_fade_in = 1;					// Enable animation fade in
 | 
			
		||||
int animation_fade_out = 1;					// Enable animation fade out
 | 
			
		||||
float zoom_initial_ratio = 0.5;				// 动画起始窗口比例
 | 
			
		||||
float fadein_begin_opacity = 0.5;  // Begin opac window ratio for animations
 | 
			
		||||
float fadeout_begin_opacity = 0.5; // Begin opac window ratio for animations
 | 
			
		||||
uint32_t animation_duration_move = 500;	 // Animation move speed
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										10
									
								
								src/maomao.c
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								src/maomao.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -377,6 +377,8 @@ typedef struct {
 | 
			
		|||
	int noblur;
 | 
			
		||||
	int noanim;
 | 
			
		||||
	int noshadow;
 | 
			
		||||
	char *animation_type_open;
 | 
			
		||||
	char *animation_type_close;
 | 
			
		||||
	bool need_output_flush;
 | 
			
		||||
} LayerSurface;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -2531,6 +2533,14 @@ void maplayersurfacenotify(struct wl_listener *listener, void *data) {
 | 
			
		|||
			if (config.layer_rules[ji].noshadow > 0) {
 | 
			
		||||
				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