From a60a1a755598240f5a7705070179bfa707ad4c56 Mon Sep 17 00:00:00 2001 From: Federico Angelilli Date: Fri, 12 Jul 2024 23:32:17 +0200 Subject: Minor fixes and refactor --- src/config.c | 60 +++++++++++++++++++++++++++++------------------------------- src/layout.c | 14 ++++++++++++-- src/window.c | 6 +----- 3 files changed, 42 insertions(+), 38 deletions(-) diff --git a/src/config.c b/src/config.c index 1f2698b..9a2bc42 100644 --- a/src/config.c +++ b/src/config.c @@ -254,11 +254,9 @@ static config_status_t config_read_block(const config_block_t *info, block_t *bl const char *section, const char *key, const char *value) { config_status_t status = config_read_entry(block_entries, block, type, section, key, value); - - if (status == CONFIG_INVALID) - return status; - - return config_read_entry(info->entries, result, type, section, key, value); + return status != CONFIG_UNKNOWN + ? status + : config_read_entry(info->entries, result, type, section, key, value); } void config_init(config_t *config) @@ -373,33 +371,33 @@ void config_read(config_t *config, FILE *file) &type, section, key, value); else if (entries != NULL) status = config_read_entry(entries, result, &type, section, key, value); + else + goto skip_pair; - if (block != NULL || entries != NULL) { - switch (status) { - case CONFIG_SUCCESS: - break; - - case CONFIG_INVALID: - errors++; - log_value_error("Invalid entry", - "s:section", section, - "s:key", key, - "s:value", value, - "s:type", type, - "i:line", ini.line); - break; - - case CONFIG_UNKNOWN: - log_value_warn("Unknown entry", - "s:section", section, - "s:key", key, - "s:value", value, - "i:line", ini.line); - break; - - default: - unreachable(); - } + switch (status) { + case CONFIG_SUCCESS: + break; + + case CONFIG_INVALID: + errors++; + log_value_error("Invalid entry", + "s:section", section, + "s:key", key, + "s:value", value, + "s:type", type, + "i:line", ini.line); + break; + + case CONFIG_UNKNOWN: + log_value_warn("Unknown entry", + "s:section", section, + "s:key", key, + "s:value", value, + "i:line", ini.line); + break; + + default: + unreachable(); } skip_pair: diff --git a/src/layout.c b/src/layout.c index 0b0f826..6b6590e 100644 --- a/src/layout.c +++ b/src/layout.c @@ -8,10 +8,10 @@ void layout_init(layout_t *layout, block_t *block, layout_info_t info) { - assert(!block->hidden); - memset(layout, 0, sizeof(layout_t)); + assert(!block->hidden); + layout->block = block; layout->x = info.x_offset; layout->y = 0; @@ -35,6 +35,16 @@ void layout_init(layout_t *layout, block_t *block, layout_info_t info) if (layout->n_children > 0) { layout_t *last = &layout->children[layout->n_children - 1]; layout->width = last->x + last->width - x_offset; + + // NOTE: Temporary solution to make blocks not overlapping correctly + // less noticeable + if (layout->children[0].x_padding == 0) { + layout->x += 1; + layout->width -= 1; + } + + if (last->x_padding == 0) + layout->width -= 1; } } else if (block->type == BLOCK_TEXT) { layout->pl = pango_layout_new(info.context); diff --git a/src/window.c b/src/window.c index 717d90b..24ecd07 100644 --- a/src/window.c +++ b/src/window.c @@ -192,11 +192,7 @@ static void window_reshape(window_t *window) window->height); cairo_t *cr = cairo_create(surface); - - // TODO: Fix antialiasing situation - //cairo_set_antialias(cr, CAIRO_ANTIALIAS_GOOD); - - cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE); + cairo_set_antialias(cr, CAIRO_ANTIALIAS_GOOD); cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); cairo_set_source_rgba(cr, 0, 0, 0, 0); -- cgit v1.2.3