diff options
-rw-r--r-- | include/sway/config.h | 5 | ||||
-rw-r--r-- | sway/commands/font.c | 6 | ||||
-rw-r--r-- | sway/commands/title_format.c | 4 | ||||
-rw-r--r-- | sway/config.c | 9 | ||||
-rw-r--r-- | sway/tree/view.c | 7 |
5 files changed, 15 insertions, 16 deletions
diff --git a/include/sway/config.h b/include/sway/config.h index db942c3f..fa40ef4e 100644 --- a/include/sway/config.h +++ b/include/sway/config.h @@ -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 * reported by each container. If recalculate is true, the containers will * 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. */ extern struct sway_config *config; diff --git a/sway/commands/font.c b/sway/commands/font.c index 38ad8880..8e0b51e3 100644 --- a/sway/commands/font.c +++ b/sway/commands/font.c @@ -2,7 +2,6 @@ #include <string.h> #include "sway/commands.h" #include "sway/config.h" -#include "sway/tree/arrange.h" #include "log.h" #include "stringop.h" @@ -14,9 +13,6 @@ struct cmd_results *cmd_font(int argc, char **argv) { char *font = join_args(argv, argc); free(config->font); config->font = strdup(font); - config_find_font_height(true); - if (!config->reading) { - arrange_root(); - } + config_update_font_height(true); return cmd_results_new(CMD_SUCCESS, NULL, NULL); } diff --git a/sway/commands/title_format.c b/sway/commands/title_format.c index 26ddb2f4..3d1c578c 100644 --- a/sway/commands/title_format.c +++ b/sway/commands/title_format.c @@ -2,7 +2,6 @@ #include <string.h> #include "sway/commands.h" #include "sway/config.h" -#include "sway/tree/arrange.h" #include "sway/tree/view.h" #include "log.h" #include "stringop.h" @@ -25,7 +24,6 @@ struct cmd_results *cmd_title_format(int argc, char **argv) { } view->title_format = format; view_update_title(view, true); - config_find_font_height(true); - arrange_root(); + config_update_font_height(true); return cmd_results_new(CMD_SUCCESS, NULL, NULL); } diff --git a/sway/config.c b/sway/config.c index 2e5eab2b..a14f4ec6 100644 --- a/sway/config.c +++ b/sway/config.c @@ -24,6 +24,7 @@ #include "sway/input/seat.h" #include "sway/commands.h" #include "sway/config.h" +#include "sway/tree/arrange.h" #include "sway/tree/layout.h" #include "cairo.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; + container_for_each_descendant_dfs(&root_container, find_font_height_iterator, &recalculate); + + if (config->font_height != prev_max_height) { + arrange_root(); + } } diff --git a/sway/tree/view.c b/sway/tree/view.c index 386144f6..851348d8 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -601,10 +601,5 @@ void view_update_title(struct sway_view *view, bool force) { container_calculate_title_height(view->swayc); container_update_title_textures(view->swayc); container_notify_child_title_changed(view->swayc->parent); - - size_t prev_max_height = config->font_height; - config_find_font_height(false); - if (config->font_height != prev_max_height) { - arrange_root(); - } + config_update_font_height(false); } |