diff options
Diffstat (limited to 'swaybar/ipc.c')
-rw-r--r-- | swaybar/ipc.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/swaybar/ipc.c b/swaybar/ipc.c index a64aa1ab..03500bdf 100644 --- a/swaybar/ipc.c +++ b/swaybar/ipc.c | |||
@@ -1,4 +1,3 @@ | |||
1 | #define _POSIX_C_SOURCE 200809 | ||
2 | #include <limits.h> | 1 | #include <limits.h> |
3 | #include <poll.h> | 2 | #include <poll.h> |
4 | #include <stdio.h> | 3 | #include <stdio.h> |
@@ -147,8 +146,10 @@ static bool ipc_parse_config( | |||
147 | 146 | ||
148 | json_object *font = json_object_object_get(bar_config, "font"); | 147 | json_object *font = json_object_object_get(bar_config, "font"); |
149 | if (font) { | 148 | if (font) { |
150 | free(config->font); | 149 | pango_font_description_free(config->font_description); |
151 | config->font = parse_font(json_object_get_string(font)); | 150 | char *font_value = parse_font(json_object_get_string(font)); |
151 | config->font_description = pango_font_description_from_string(font_value); | ||
152 | free(font_value); | ||
152 | } | 153 | } |
153 | 154 | ||
154 | json_object *gaps = json_object_object_get(bar_config, "gaps"); | 155 | json_object *gaps = json_object_object_get(bar_config, "gaps"); |
@@ -424,12 +425,9 @@ bool ipc_initialize(struct swaybar *bar) { | |||
424 | } | 425 | } |
425 | free(res); | 426 | free(res); |
426 | 427 | ||
427 | struct swaybar_config *config = bar->config; | 428 | char *subscribe = |
428 | char subscribe[128]; // suitably large buffer | 429 | "[ \"barconfig_update\", \"bar_state_update\", \"mode\", \"workspace\" ]"; |
429 | len = snprintf(subscribe, 128, | 430 | len = strlen(subscribe); |
430 | "[ \"barconfig_update\" , \"bar_state_update\" %s %s ]", | ||
431 | config->binding_mode_indicator ? ", \"mode\"" : "", | ||
432 | config->workspace_buttons ? ", \"workspace\"" : ""); | ||
433 | free(ipc_single_command(bar->ipc_event_socketfd, | 431 | free(ipc_single_command(bar->ipc_event_socketfd, |
434 | IPC_SUBSCRIBE, subscribe, &len)); | 432 | IPC_SUBSCRIBE, subscribe, &len)); |
435 | return true; | 433 | return true; |
@@ -485,8 +483,7 @@ static bool handle_barconfig_update(struct swaybar *bar, const char *payload, | |||
485 | destroy_layer_surface(output); | 483 | destroy_layer_surface(output); |
486 | wl_list_remove(&output->link); | 484 | wl_list_remove(&output->link); |
487 | wl_list_insert(&bar->unused_outputs, &output->link); | 485 | wl_list_insert(&bar->unused_outputs, &output->link); |
488 | } else if (!oldcfg->font || !newcfg->font || | 486 | } 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 | 487 | output->height = 0; // force update height |
491 | } | 488 | } |
492 | } | 489 | } |
@@ -550,7 +547,7 @@ bool handle_ipc_readable(struct swaybar *bar) { | |||
550 | // The default depth of 32 is too small to represent some nested layouts, but | 547 | // The default depth of 32 is too small to represent some nested layouts, but |
551 | // we can't pass INT_MAX here because json-c (as of this writing) prefaults | 548 | // we can't pass INT_MAX here because json-c (as of this writing) prefaults |
552 | // all the memory for its stack. | 549 | // all the memory for its stack. |
553 | json_tokener *tok = json_tokener_new_ex(256); | 550 | json_tokener *tok = json_tokener_new_ex(JSON_MAX_DEPTH); |
554 | if (!tok) { | 551 | if (!tok) { |
555 | sway_log_errno(SWAY_ERROR, "failed to create tokener"); | 552 | sway_log_errno(SWAY_ERROR, "failed to create tokener"); |
556 | free_ipc_response(resp); | 553 | free_ipc_response(resp); |