mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05:00 
			
		
		
		
	Move code for re-arranging after font height change into a common place
This commit is contained in:
		
							parent
							
								
									da7d6642d3
								
							
						
					
					
						commit
						5d6d24e71a
					
				
					 5 changed files with 15 additions and 16 deletions
				
			
		| 
						 | 
					@ -465,8 +465,11 @@ void free_bar_config(struct bar_config *bar);
 | 
				
			||||||
 * Updates the value of config->font_height based on the max title height
 | 
					 * Updates the value of config->font_height based on the max title height
 | 
				
			||||||
 * reported by each container. If recalculate is true, the containers will
 | 
					 * reported by each container. If recalculate is true, the containers will
 | 
				
			||||||
 * recalculate their heights before reporting.
 | 
					 * recalculate their heights before reporting.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * If the height has changed, all containers will be rearranged to take on the
 | 
				
			||||||
 | 
					 * new size.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
void config_find_font_height(bool recalculate);
 | 
					void config_update_font_height(bool recalculate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Global config singleton. */
 | 
					/* Global config singleton. */
 | 
				
			||||||
extern struct sway_config *config;
 | 
					extern struct sway_config *config;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,7 +2,6 @@
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
#include "sway/commands.h"
 | 
					#include "sway/commands.h"
 | 
				
			||||||
#include "sway/config.h"
 | 
					#include "sway/config.h"
 | 
				
			||||||
#include "sway/tree/arrange.h"
 | 
					 | 
				
			||||||
#include "log.h"
 | 
					#include "log.h"
 | 
				
			||||||
#include "stringop.h"
 | 
					#include "stringop.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,9 +13,6 @@ struct cmd_results *cmd_font(int argc, char **argv) {
 | 
				
			||||||
	char *font = join_args(argv, argc);
 | 
						char *font = join_args(argv, argc);
 | 
				
			||||||
	free(config->font);
 | 
						free(config->font);
 | 
				
			||||||
	config->font = strdup(font);
 | 
						config->font = strdup(font);
 | 
				
			||||||
	config_find_font_height(true);
 | 
						config_update_font_height(true);
 | 
				
			||||||
	if (!config->reading) {
 | 
					 | 
				
			||||||
		arrange_root();
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return cmd_results_new(CMD_SUCCESS, NULL, NULL);
 | 
						return cmd_results_new(CMD_SUCCESS, NULL, NULL);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,7 +2,6 @@
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
#include "sway/commands.h"
 | 
					#include "sway/commands.h"
 | 
				
			||||||
#include "sway/config.h"
 | 
					#include "sway/config.h"
 | 
				
			||||||
#include "sway/tree/arrange.h"
 | 
					 | 
				
			||||||
#include "sway/tree/view.h"
 | 
					#include "sway/tree/view.h"
 | 
				
			||||||
#include "log.h"
 | 
					#include "log.h"
 | 
				
			||||||
#include "stringop.h"
 | 
					#include "stringop.h"
 | 
				
			||||||
| 
						 | 
					@ -25,7 +24,6 @@ struct cmd_results *cmd_title_format(int argc, char **argv) {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	view->title_format = format;
 | 
						view->title_format = format;
 | 
				
			||||||
	view_update_title(view, true);
 | 
						view_update_title(view, true);
 | 
				
			||||||
	config_find_font_height(true);
 | 
						config_update_font_height(true);
 | 
				
			||||||
	arrange_root();
 | 
					 | 
				
			||||||
	return cmd_results_new(CMD_SUCCESS, NULL, NULL);
 | 
						return cmd_results_new(CMD_SUCCESS, NULL, NULL);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -24,6 +24,7 @@
 | 
				
			||||||
#include "sway/input/seat.h"
 | 
					#include "sway/input/seat.h"
 | 
				
			||||||
#include "sway/commands.h"
 | 
					#include "sway/commands.h"
 | 
				
			||||||
#include "sway/config.h"
 | 
					#include "sway/config.h"
 | 
				
			||||||
 | 
					#include "sway/tree/arrange.h"
 | 
				
			||||||
#include "sway/tree/layout.h"
 | 
					#include "sway/tree/layout.h"
 | 
				
			||||||
#include "cairo.h"
 | 
					#include "cairo.h"
 | 
				
			||||||
#include "pango.h"
 | 
					#include "pango.h"
 | 
				
			||||||
| 
						 | 
					@ -741,8 +742,14 @@ static void find_font_height_iterator(struct sway_container *container,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void config_find_font_height(bool recalculate) {
 | 
					void config_update_font_height(bool recalculate) {
 | 
				
			||||||
 | 
						size_t prev_max_height = config->font_height;
 | 
				
			||||||
	config->font_height = 0;
 | 
						config->font_height = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	container_for_each_descendant_dfs(&root_container,
 | 
						container_for_each_descendant_dfs(&root_container,
 | 
				
			||||||
			find_font_height_iterator, &recalculate);
 | 
								find_font_height_iterator, &recalculate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (config->font_height != prev_max_height) {
 | 
				
			||||||
 | 
							arrange_root();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -601,10 +601,5 @@ void view_update_title(struct sway_view *view, bool force) {
 | 
				
			||||||
	container_calculate_title_height(view->swayc);
 | 
						container_calculate_title_height(view->swayc);
 | 
				
			||||||
	container_update_title_textures(view->swayc);
 | 
						container_update_title_textures(view->swayc);
 | 
				
			||||||
	container_notify_child_title_changed(view->swayc->parent);
 | 
						container_notify_child_title_changed(view->swayc->parent);
 | 
				
			||||||
 | 
						config_update_font_height(false);
 | 
				
			||||||
	size_t prev_max_height = config->font_height;
 | 
					 | 
				
			||||||
	config_find_font_height(false);
 | 
					 | 
				
			||||||
	if (config->font_height != prev_max_height) {
 | 
					 | 
				
			||||||
		arrange_root();
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue