aboutsummaryrefslogtreecommitdiffstats
path: root/sway/config.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-05-03 15:02:16 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-05-03 15:12:00 +1000
commit55b307cddfa453fc003350a642a68735bc36e50e (patch)
tree4cc54f1be82db862fa4896b5da1d52868a273161 /sway/config.c
parentRender titles (diff)
downloadsway-55b307cddfa453fc003350a642a68735bc36e50e.tar.gz
sway-55b307cddfa453fc003350a642a68735bc36e50e.tar.zst
sway-55b307cddfa453fc003350a642a68735bc36e50e.zip
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,
132 } 132 }
133} 133}
134 134
135int get_font_text_height(char *font) {
136 cairo_t *cairo = cairo_create(NULL);
137 int text_height;
138 get_text_size(cairo, font, NULL, &text_height, 1, false,
139 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
140 "abcdefghijklmnopqrstuvwxyz"
141 "!@#$%^&*([{|");
142 cairo_destroy(cairo);
143 return text_height;
144}
145
146static void set_color(float dest[static 4], uint32_t color) { 135static void set_color(float dest[static 4], uint32_t color) {
147 dest[0] = ((color >> 16) & 0xff) / 255.0; 136 dest[0] = ((color >> 16) & 0xff) / 255.0;
148 dest[1] = ((color >> 8) & 0xff) / 255.0; 137 dest[1] = ((color >> 8) & 0xff) / 255.0;
@@ -182,7 +171,7 @@ static void config_defaults(struct sway_config *config) {
182 config->default_layout = L_NONE; 171 config->default_layout = L_NONE;
183 config->default_orientation = L_NONE; 172 config->default_orientation = L_NONE;
184 if (!(config->font = strdup("monospace 10"))) goto cleanup; 173 if (!(config->font = strdup("monospace 10"))) goto cleanup;
185 config->font_height = get_font_text_height(config->font); 174 config->font_height = 0;
186 175
187 // floating view 176 // floating view
188 config->floating_maximum_width = 0; 177 config->floating_maximum_width = 0;
@@ -740,3 +729,20 @@ int workspace_output_cmp_workspace(const void *a, const void *b) {
740 const struct workspace_output *wsa = a, *wsb = b; 729 const struct workspace_output *wsa = a, *wsb = b;
741 return lenient_strcmp(wsa->workspace, wsb->workspace); 730 return lenient_strcmp(wsa->workspace, wsb->workspace);
742} 731}
732
733static void find_font_height_iterator(struct sway_container *container,
734 void *data) {
735 bool *recalculate = data;
736 if (*recalculate) {
737 container_calculate_title_height(container);
738 }
739 if (container->title_height > config->font_height) {
740 config->font_height = container->title_height;
741 }
742}
743
744void config_find_font_height(bool recalculate) {
745 config->font_height = 0;
746 container_for_each_descendant_dfs(&root_container,
747 find_font_height_iterator, &recalculate);
748}