diff --git a/src/background.c b/src/background.c index 7618798..074bce4 100644 --- a/src/background.c +++ b/src/background.c @@ -95,9 +95,11 @@ static bool background_set_yoffset(struct background* background, int offset) { return true; } -void background_calculate_bounds(struct background* background, uint32_t x, uint32_t y) { +void background_calculate_bounds(struct background* background, uint32_t x, uint32_t y, uint32_t width, uint32_t height) { background->bounds.origin.x = x; background->bounds.origin.y = y - background->bounds.size.height / 2; + background->bounds.size.width = width; + background->bounds.size.height = height; if (background->image.enabled) image_calculate_bounds(&background->image, x, y); diff --git a/src/background.h b/src/background.h index 5d404c7..9d3debc 100644 --- a/src/background.h +++ b/src/background.h @@ -20,7 +20,7 @@ struct background { }; void background_init(struct background* background); -void background_calculate_bounds(struct background* background, uint32_t x, uint32_t y); +void background_calculate_bounds(struct background* background, uint32_t x, uint32_t y, uint32_t width, uint32_t height); bool background_set_height(struct background* background, uint32_t height); diff --git a/src/bar_item.c b/src/bar_item.c index 6d4fe3a..85d0f4d 100644 --- a/src/bar_item.c +++ b/src/bar_item.c @@ -593,15 +593,16 @@ uint32_t bar_item_calculate_bounds(struct bar_item* bar_item, uint32_t bar_heigh } if (bar_item->background.enabled) { - bar_item->background.bounds.size.height = bar_item->background.overrides_height - ? bar_item->background.bounds.size.height - : (bar_height - - (g_bar_manager.background.border_width + 1)); + uint32_t height = bar_item->background.overrides_height + ? bar_item->background.bounds.size.height + : (bar_height + - (g_bar_manager.background.border_width + 1)); - bar_item->background.bounds.size.width = bar_item_length; background_calculate_bounds(&bar_item->background, x, - content_y + bar_item->y_offset ); + content_y + bar_item->y_offset, + bar_item_length, + height ); } return bar_item_length; diff --git a/src/group.c b/src/group.c index 3d22506..f7c324e 100644 --- a/src/group.c +++ b/src/group.c @@ -96,12 +96,11 @@ void group_destroy(struct group* group) { } void group_calculate_bounds(struct group* group, struct bar* bar, uint32_t x, uint32_t y, bool rtl) { - background_calculate_bounds(&group->members[0]->background, x, y); - group->members[0]->background.bounds.size.width = group_get_length(group, bar); - group->members[0]->background.bounds.origin.x = x; - group->members[0]->background.bounds.origin.y = y - - group->members[0]->background.bounds.size.height / 2 - + group->members[0]->y_offset; + background_calculate_bounds(&group->members[0]->background, + x, + y + group->members[0]->y_offset, + group_get_length(group, bar), + group->members[0]->background.bounds.size.height); } void group_draw(struct group* group, CGContextRef context) { diff --git a/src/text.c b/src/text.c index e41cb4e..5ed4b81 100644 --- a/src/text.c +++ b/src/text.c @@ -253,11 +253,15 @@ void text_calculate_bounds(struct text* text, uint32_t x, uint32_t y) { - text->line.descent) / 2)); if (text->background.enabled) { - text->background.bounds.size.width = text_get_length(text, false); - text->background.bounds.size.height = text->background.overrides_height - ? text->background.bounds.size.height - : text->bounds.size.height; - background_calculate_bounds(&text->background, x, y); + uint32_t height = text->background.overrides_height + ? text->background.bounds.size.height + : text->bounds.size.height; + + background_calculate_bounds(&text->background, + x, + y, + text_get_length(text, false), + height ); } }