From 501270a76aea256fcf8ebe8330be3cbf96f64f22 Mon Sep 17 00:00:00 2001 From: Federico Angelilli Date: Fri, 15 Mar 2024 21:13:34 +0100 Subject: Fix improper width calculation --- src/draw.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/draw.c b/src/draw.c index 26b0cb0..c952309 100644 --- a/src/draw.c +++ b/src/draw.c @@ -247,10 +247,11 @@ void draw_compute_layout(Drawer *draw, Window *win, GList *btns) child->pl = pango_cairo_create_layout(window_get_context(win)); layout_text(child, draw->desc, height, radius); + child->width += child->line_w; draw->layouts = g_list_prepend(draw->layouts, child); - x += child->width + child->line_w * 2; + x += child->width; if (it->next != NULL) x += sep; } @@ -287,7 +288,8 @@ void draw_compute_layout(Drawer *draw, Window *win, GList *btns) btn->anim->layout_func = NULL; } - x += layout->width + layout->line_w * 2; + layout->width += layout->line_w; + x += layout->width; } prev = btn; @@ -315,12 +317,8 @@ void draw_compute_layout(Drawer *draw, Window *win, GList *btns) layout->x += center_off; } - // The width is off by 2 line width - int first_line_w = CAST(layout_start[PANGO_ALIGN_RIGHT]->data, Layout)->line_w; - int last_line_w = CAST(g_list_last(layout_start[PANGO_ALIGN_RIGHT])->data, Layout)->line_w; - int right = width - layout_width[PANGO_ALIGN_RIGHT]; - int right_off = right - MAX(layout_end[PANGO_ALIGN_LEFT], layout_end[PANGO_ALIGN_CENTER]) + first_line_w + last_line_w; + int right_off = right - MAX(layout_end[PANGO_ALIGN_LEFT], layout_end[PANGO_ALIGN_CENTER]); log_debug("Aligning right layout [x=%d, off=%d]", right, right_off); for (GList *it = layout_start[PANGO_ALIGN_RIGHT]; it != NULL; it = it->next) { -- cgit v1.2.3