From a8a1c47f4c22497c983856c04c099058a42e518b Mon Sep 17 00:00:00 2001 From: Federico Angelilli Date: Sun, 19 Nov 2023 12:41:54 +0100 Subject: Fix offset calculation for right aligned buttons --- src/draw.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/draw.c') diff --git a/src/draw.c b/src/draw.c index 310bca9..42b4acb 100644 --- a/src/draw.c +++ b/src/draw.c @@ -152,6 +152,9 @@ void draw_compute_layout(Drawable *draw, Window *win, GList *btns) int x = 0; int radius = height / 2; + int sep = 10 * scale; + int line_w = 1 * scale; + btns = g_list_sort(btns, align_compare); GList *adjust_center = NULL; @@ -191,7 +194,6 @@ void draw_compute_layout(Drawable *draw, Window *win, GList *btns) if (prev != NULL) { if (prev->align == btn->align) { - int sep = 10 * scale; x += sep; // Ugly update for layout layout->x = x; @@ -201,7 +203,6 @@ void draw_compute_layout(Drawable *draw, Window *win, GList *btns) } } - int line_w = 1 * scale; x += layout->width + line_w * 2; prev = btn; @@ -236,7 +237,8 @@ void draw_compute_layout(Drawable *draw, Window *win, GList *btns) } int right = width - widths[2]; - int right_off = right - start_xs[2]; + // The width is off by 2 line width + int right_off = right - start_xs[2] + 2 * line_w; log_debug("Aligning right layout [x=%d, off=%d]", right, right_off); for (GList *it = adjust_right; it != NULL; it = it->next) { -- cgit v1.2.3