aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFederico Angelilli <code@fedang.net>2024-03-15 21:13:34 +0100
committerFederico Angelilli <code@fedang.net>2024-03-15 21:13:34 +0100
commit501270a76aea256fcf8ebe8330be3cbf96f64f22 (patch)
tree7320ab547a720291efd58f2ee39a43fc347e983a /src
parent7f88db5f34c37c804a7bb69fccb2c7dee86dfe98 (diff)
Fix improper width calculation
Diffstat (limited to 'src')
-rw-r--r--src/draw.c12
1 files changed, 5 insertions, 7 deletions
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) {