added animation config
This commit is contained in:
		
							parent
							
								
									4c6826386d
								
							
						
					
					
						commit
						5bfa2e030e
					
				
					 9 changed files with 40 additions and 6 deletions
				
			
		
							
								
								
									
										10
									
								
								README.md
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								README.md
									
										
									
									
									
								
							|  | @ -25,6 +25,14 @@ Sway is an incredible window manager, and certainly one of the most well establi | ||||||
| 
 | 
 | ||||||
| ## New Configuration Options | ## New Configuration Options | ||||||
| 
 | 
 | ||||||
|  | + Fade in / out animations: `animation_duration <val>`: specifies the length of the animation in seconds | ||||||
|  | + Corner radius: `corner_radius <val>` | ||||||
|  | + Smart corner radius: `smart_corner_radius enable|disable` | ||||||
|  | + Window shadows: | ||||||
|  |     - `shadows enable|disable` | ||||||
|  |     - `shadows_on_csd enable|disable` (**Note**: The shadow might not fit some windows) | ||||||
|  |     - `shadow_blur_radius <integer value 0 - 100>` | ||||||
|  |     - `shadow_color <hex color with alpha> ex, #0000007F` | ||||||
| + Window blur: | + Window blur: | ||||||
|     - `blur enable|disable` |     - `blur enable|disable` | ||||||
|     - `blur_xray enable|disable`: this will set floating windows to blur based on the background, not the windows below. You probably want to set this to `disable` :) |     - `blur_xray enable|disable`: this will set floating windows to blur based on the background, not the windows below. You probably want to set this to `disable` :) | ||||||
|  | @ -58,7 +66,6 @@ Sway is an incredible window manager, and certainly one of the most well establi | ||||||
| 
 | 
 | ||||||
| ## Roadmap | ## Roadmap | ||||||
| 
 | 
 | ||||||
| + fade in / out animations |  | ||||||
| + window movement animations | + window movement animations | ||||||
| 
 | 
 | ||||||
| ## Compiling From Source | ## Compiling From Source | ||||||
|  | @ -127,4 +134,3 @@ We would also like to thank the talented artists in our community for contibutin | ||||||
| + spooky_skeleton for the swayfx logo, and [Basil](https://basil.cafe) for making some fine adjustments to it | + spooky_skeleton for the swayfx logo, and [Basil](https://basil.cafe) for making some fine adjustments to it | ||||||
| 
 | 
 | ||||||
| Lastly, we would like to thank you, the community, for enjoying and using window manager that we have spent so much time maintaining. | Lastly, we would like to thank you, the community, for enjoying and using window manager that we have spent so much time maintaining. | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -108,6 +108,7 @@ bool cmd_corner_radius_parse_value(char *arg, int* result); | ||||||
| sway_cmd cmd_exec_validate; | sway_cmd cmd_exec_validate; | ||||||
| sway_cmd cmd_exec_process; | sway_cmd cmd_exec_process; | ||||||
| 
 | 
 | ||||||
|  | sway_cmd cmd_animation_duration; | ||||||
| sway_cmd cmd_assign; | sway_cmd cmd_assign; | ||||||
| sway_cmd cmd_bar; | sway_cmd cmd_bar; | ||||||
| sway_cmd cmd_bindcode; | sway_cmd cmd_bindcode; | ||||||
|  |  | ||||||
|  | @ -479,6 +479,8 @@ struct blur_parameters { | ||||||
|  * The configuration struct. The result of loading a config file. |  * The configuration struct. The result of loading a config file. | ||||||
|  */ |  */ | ||||||
| struct sway_config { | struct sway_config { | ||||||
|  | 	float animation_duration; | ||||||
|  | 
 | ||||||
| 	int corner_radius; | 	int corner_radius; | ||||||
| 	bool smart_corner_radius; | 	bool smart_corner_radius; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -43,6 +43,7 @@ struct cmd_results *checkarg(int argc, const char *name, enum expected_args type | ||||||
| 
 | 
 | ||||||
| /* Keep alphabetized */ | /* Keep alphabetized */ | ||||||
| static const struct cmd_handler handlers[] = { | static const struct cmd_handler handlers[] = { | ||||||
|  | 	{ "animation_duration", cmd_animation_duration }, | ||||||
| 	{ "assign", cmd_assign }, | 	{ "assign", cmd_assign }, | ||||||
| 	{ "bar", cmd_bar }, | 	{ "bar", cmd_bar }, | ||||||
| 	{ "bindcode", cmd_bindcode }, | 	{ "bindcode", cmd_bindcode }, | ||||||
|  |  | ||||||
							
								
								
									
										21
									
								
								sway/commands/animation_duration.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								sway/commands/animation_duration.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,21 @@ | ||||||
|  | #include <string.h> | ||||||
|  | #include "sway/commands.h" | ||||||
|  | #include "sway/config.h" | ||||||
|  | #include "log.h" | ||||||
|  | 
 | ||||||
|  | struct cmd_results *cmd_animation_duration(int argc, char **argv) { | ||||||
|  | 	struct cmd_results *error = NULL; | ||||||
|  | 	if ((error = checkarg(argc, "animation_duration", EXPECTED_EQUAL_TO, 1))) { | ||||||
|  | 		return error; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	char *err; | ||||||
|  | 	float value = strtof(argv[0], &err); | ||||||
|  | 	if (*err || value < 0.0f || value > 1.0f) { | ||||||
|  | 		return cmd_results_new(CMD_FAILURE, "animation_duration value invalid"); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	config->animation_duration = value; | ||||||
|  | 
 | ||||||
|  | 	return cmd_results_new(CMD_SUCCESS, NULL); | ||||||
|  | } | ||||||
|  | @ -341,6 +341,8 @@ static void config_defaults(struct sway_config *config) { | ||||||
| 	color_to_rgba(config->border_colors.background, 0xFFFFFFFF); | 	color_to_rgba(config->border_colors.background, 0xFFFFFFFF); | ||||||
| 
 | 
 | ||||||
| 	// SwayFX defaults
 | 	// SwayFX defaults
 | ||||||
|  | 	config->animation_duration = 0; | ||||||
|  | 
 | ||||||
| 	config->corner_radius = 0; | 	config->corner_radius = 0; | ||||||
| 	config->smart_corner_radius = true; | 	config->smart_corner_radius = true; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -522,16 +522,13 @@ static bool scan_out_fullscreen_view(struct sway_output *output, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void containers_tick_alpha(list_t *containers, struct sway_output *output) { | static void containers_tick_alpha(list_t *containers, struct sway_output *output) { | ||||||
| 	// TODO: config for animation_duration
 |  | ||||||
| 	float animation_duration = 0.5; |  | ||||||
| 
 |  | ||||||
| 	float alpha_step; | 	float alpha_step; | ||||||
| 	for (int i = 0; i < containers->length; ++i) { | 	for (int i = 0; i < containers->length; ++i) { | ||||||
| 		struct sway_container *con = containers->items[i]; | 		struct sway_container *con = containers->items[i]; | ||||||
| 		if (con->pending.children) { | 		if (con->pending.children) { | ||||||
| 			containers_tick_alpha(con->pending.children, output); | 			containers_tick_alpha(con->pending.children, output); | ||||||
| 		} else if (con->alpha < con->target_alpha) { | 		} else if (con->alpha < con->target_alpha) { | ||||||
| 			alpha_step = (con->target_alpha * output->refresh_sec) / animation_duration; | 			alpha_step = (con->target_alpha * output->refresh_sec) / config->animation_duration; | ||||||
| 			// ensure that the alpha does not exceed the target_alpha
 | 			// ensure that the alpha does not exceed the target_alpha
 | ||||||
| 			con->alpha = MIN(con->alpha + alpha_step, con->target_alpha); | 			con->alpha = MIN(con->alpha + alpha_step, con->target_alpha); | ||||||
| 			output_damage_whole_container(output, con); | 			output_damage_whole_container(output, con); | ||||||
|  |  | ||||||
|  | @ -49,6 +49,7 @@ sway_sources = files( | ||||||
| 	'config/seat.c', | 	'config/seat.c', | ||||||
| 	'config/input.c', | 	'config/input.c', | ||||||
| 
 | 
 | ||||||
|  | 	'commands/animation_duration.c', | ||||||
| 	'commands/assign.c', | 	'commands/assign.c', | ||||||
| 	'commands/bar.c', | 	'commands/bar.c', | ||||||
| 	'commands/bind.c', | 	'commands/bind.c', | ||||||
|  |  | ||||||
|  | @ -378,6 +378,9 @@ set|plus|minus|toggle <amount> | ||||||
| The following commands may be used either in the configuration file or at | The following commands may be used either in the configuration file or at | ||||||
| runtime. | runtime. | ||||||
| 
 | 
 | ||||||
|  | *animation_duration <seconds>* | ||||||
|  | 	Specifies the length of the animation in seconds, between 0 and 1 second. | ||||||
|  | 
 | ||||||
| *assign* <criteria> [→] [workspace] [number] <workspace> | *assign* <criteria> [→] [workspace] [number] <workspace> | ||||||
| 	Assigns views matching _criteria_ (see *CRITERIA* for details) to | 	Assigns views matching _criteria_ (see *CRITERIA* for details) to | ||||||
| 	_workspace_. The → (U+2192) is optional and cosmetic. This command is | 	_workspace_. The → (U+2192) is optional and cosmetic. This command is | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue