From 80e386fd97c0da00970f0acc007574151048cfbf Mon Sep 17 00:00:00 2001 From: Hugo Osvaldo Barrera Date: Fri, 1 Jul 2022 12:23:04 +0200 Subject: Reuse parsed PangoFontDescription Avoids parsing the configured font each time text is rendered. --- swaybar/ipc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'swaybar/ipc.c') 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( json_object *font = json_object_object_get(bar_config, "font"); if (font) { - free(config->font); - config->font = parse_font(json_object_get_string(font)); + pango_font_description_free(config->font_description); + char *font_value = parse_font(json_object_get_string(font)); + config->font_description = pango_font_description_from_string(font_value); + free(font_value); } 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, destroy_layer_surface(output); wl_list_remove(&output->link); wl_list_insert(&bar->unused_outputs, &output->link); - } else if (!oldcfg->font || !newcfg->font || - strcmp(oldcfg->font, newcfg->font) != 0) { + } else if (!pango_font_description_equal(oldcfg->font_description, newcfg->font_description)) { output->height = 0; // force update height } } -- cgit v1.2.3-54-g00ecf