From c14feee90ace3d455e47e07c5f8b210a2773533e Mon Sep 17 00:00:00 2001 From: Dimitris Triantafyllidis Date: Thu, 3 Sep 2020 03:30:38 +0300 Subject: [PATCH] Fix swaynag off-by-one issues in button positions Button positions are off in both the x and y directions. This can be easily seen if we set the thickness of button borders to 1 and set all the other margins, paddings, border thicknesses and button gaps to 0. Then, in the y direction, there is an one-pixel gap between the top of swaynag and the top button borders, while the bottom button borders are invisible. In the x direction, the right border of the dismiss button is invisible, while the borders of adjacent buttons overlap by one pixel. Fixed by removing the explicit one-pixel offsets in the assignment statements for button->x and button-y in the render_button function. --- swaynag/render.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/swaynag/render.c b/swaynag/render.c index f6507e67b..498a5f32a 100644 --- a/swaynag/render.c +++ b/swaynag/render.c @@ -184,8 +184,8 @@ static uint32_t render_button(cairo_t *cairo, struct swaynag *swaynag, return ideal_surface_height; } - button->x = *x - border - text_width - padding * 2 + 1; - button->y = (int)(ideal_height - text_height) / 2 - padding + 1; + button->x = *x - border - text_width - padding * 2; + button->y = (int)(ideal_height - text_height) / 2 - padding; button->width = text_width + padding * 2; button->height = text_height + padding * 2;