aboutsummaryrefslogtreecommitdiff
path: root/src/draw.c
diff options
context:
space:
mode:
authorFederico Angelilli <code@fedang.net>2023-11-19 12:41:54 +0100
committerFederico Angelilli <code@fedang.net>2023-11-19 12:41:54 +0100
commita8a1c47f4c22497c983856c04c099058a42e518b (patch)
treece37bf013dbb6f39b035747356803187d83f4f76 /src/draw.c
parent6ac026b7a28dcf704a2d239184f75c81cbdae008 (diff)
Fix offset calculation for right aligned buttons
Diffstat (limited to 'src/draw.c')
-rw-r--r--src/draw.c8
1 files changed, 5 insertions, 3 deletions
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) {