mirror of
https://github.com/gwenhael-le-moine/sway-patched-tray-menu.git
synced 2024-12-28 22:23:42 +01: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
|
||||
* 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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue