aboutsummaryrefslogtreecommitdiff
path: root/sway/config.c
diff options
context:
space:
mode:
authorRyan Dwyer <ryandwyer1@gmail.com>2018-05-03 15:02:16 +1000
committerRyan Dwyer <ryandwyer1@gmail.com>2018-05-03 15:12:00 +1000
commit55b307cddfa453fc003350a642a68735bc36e50e (patch)
tree4cc54f1be82db862fa4896b5da1d52868a273161 /sway/config.c
parentb667298a0a1efead7949715a31ec86fe3b8b1cda (diff)
Calculate config->font_height based on existing container titles
Diffstat (limited to 'sway/config.c')
-rw-r--r--sway/config.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/sway/config.c b/sway/config.c
index 60b62bbc..0ad9c3a2 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -132,17 +132,6 @@ static void destroy_removed_seats(struct sway_config *old_config,
}
}
-int get_font_text_height(char *font) {
- cairo_t *cairo = cairo_create(NULL);
- int text_height;
- get_text_size(cairo, font, NULL, &text_height, 1, false,
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz"
- "!@#$%^&*([{|");
- cairo_destroy(cairo);
- return text_height;
-}
-
static void set_color(float dest[static 4], uint32_t color) {
dest[0] = ((color >> 16) & 0xff) / 255.0;
dest[1] = ((color >> 8) & 0xff) / 255.0;
@@ -182,7 +171,7 @@ static void config_defaults(struct sway_config *config) {
config->default_layout = L_NONE;
config->default_orientation = L_NONE;
if (!(config->font = strdup("monospace 10"))) goto cleanup;
- config->font_height = get_font_text_height(config->font);
+ config->font_height = 0;
// floating view
config->floating_maximum_width = 0;
@@ -740,3 +729,20 @@ int workspace_output_cmp_workspace(const void *a, const void *b) {
const struct workspace_output *wsa = a, *wsb = b;
return lenient_strcmp(wsa->workspace, wsb->workspace);
}
+
+static void find_font_height_iterator(struct sway_container *container,
+ void *data) {
+ bool *recalculate = data;
+ if (*recalculate) {
+ container_calculate_title_height(container);
+ }
+ if (container->title_height > config->font_height) {
+ config->font_height = container->title_height;
+ }
+}
+
+void config_find_font_height(bool recalculate) {
+ config->font_height = 0;
+ container_for_each_descendant_dfs(&root_container,
+ find_font_height_iterator, &recalculate);
+}