diff options
author | Hugo Osvaldo Barrera <hugo@barrera.io> | 2022-07-01 12:23:04 +0200 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2022-07-01 13:05:58 +0200 |
commit | 80e386fd97c0da00970f0acc007574151048cfbf (patch) | |
tree | df11d53184b20e3f1afe86b8272420349fd9b552 /swaybar/ipc.c | |
parent | Reject font values that are invalid for pango (diff) | |
download | sway-80e386fd97c0da00970f0acc007574151048cfbf.tar.gz sway-80e386fd97c0da00970f0acc007574151048cfbf.tar.zst sway-80e386fd97c0da00970f0acc007574151048cfbf.zip |
Reuse parsed PangoFontDescription
Avoids parsing the configured font each time text is rendered.
Diffstat (limited to 'swaybar/ipc.c')
-rw-r--r-- | swaybar/ipc.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/swaybar/ipc.c b/swaybar/ipc.c index 2cb235bf..9d81a9fb 100644 --- a/swaybar/ipc.c +++ b/swaybar/ipc.c | |||
@@ -147,8 +147,10 @@ static bool ipc_parse_config( | |||
147 | 147 | ||
148 | json_object *font = json_object_object_get(bar_config, "font"); | 148 | json_object *font = json_object_object_get(bar_config, "font"); |
149 | if (font) { | 149 | if (font) { |
150 | free(config->font); | 150 | pango_font_description_free(config->font_description); |
151 | config->font = parse_font(json_object_get_string(font)); | 151 | char *font_value = parse_font(json_object_get_string(font)); |
152 | config->font_description = pango_font_description_from_string(font_value); | ||
153 | free(font_value); | ||
152 | } | 154 | } |
153 | 155 | ||
154 | json_object *gaps = json_object_object_get(bar_config, "gaps"); | 156 | json_object *gaps = json_object_object_get(bar_config, "gaps"); |
@@ -485,8 +487,7 @@ static bool handle_barconfig_update(struct swaybar *bar, const char *payload, | |||
485 | destroy_layer_surface(output); | 487 | destroy_layer_surface(output); |
486 | wl_list_remove(&output->link); | 488 | wl_list_remove(&output->link); |
487 | wl_list_insert(&bar->unused_outputs, &output->link); | 489 | wl_list_insert(&bar->unused_outputs, &output->link); |
488 | } else if (!oldcfg->font || !newcfg->font || | 490 | } else if (!pango_font_description_equal(oldcfg->font_description, newcfg->font_description)) { |
489 | strcmp(oldcfg->font, newcfg->font) != 0) { | ||
490 | output->height = 0; // force update height | 491 | output->height = 0; // force update height |
491 | } | 492 | } |
492 | } | 493 | } |