aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar/render.c
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-12-10 12:25:17 -0500
committerLibravatar emersion <contact@emersion.fr>2018-12-12 10:23:57 +0100
commit549d9fe489a6a75ef486c67658b34649f4316873 (patch)
tree1542d0bf406633aac5b2fb0dcb980a962c897f48 /swaybar/render.c
parentswaybar: handle block->urgent (diff)
downloadsway-549d9fe489a6a75ef486c67658b34649f4316873.tar.gz
sway-549d9fe489a6a75ef486c67658b34649f4316873.tar.zst
sway-549d9fe489a6a75ef486c67658b34649f4316873.zip
swaybar: fix sep block width for mixed scales
When there are outputs with mixed scales, it was possible for swaybar to alter `block->separator_block_width` for an output with a higher scale, and use the changed value for a lower scale output. This caused there to be larger than normal separation between blocks on the lower scale outputs. The issue is more obvious the larger the scale difference between the highest scale output and the lowest scale output. This fixes the issue by using a local variable that is originally set to `block->separator_block_width` for rendering, but if it needs to be increased, the local variable is the only thing touched.
Diffstat (limited to 'swaybar/render.c')
-rw-r--r--swaybar/render.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/swaybar/render.c b/swaybar/render.c
index d78d7c90..96118c42 100644
--- a/swaybar/render.c
+++ b/swaybar/render.c
@@ -163,6 +163,7 @@ static uint32_t render_status_block(cairo_t *cairo,
163 } 163 }
164 164
165 int sep_width, sep_height; 165 int sep_width, sep_height;
166 int sep_block_width = block->separator_block_width;
166 if (!edge) { 167 if (!edge) {
167 if (config->sep_symbol) { 168 if (config->sep_symbol) {
168 get_text_size(cairo, config->font, &sep_width, &sep_height, NULL, 169 get_text_size(cairo, config->font, &sep_width, &sep_height, NULL,
@@ -172,11 +173,11 @@ static uint32_t render_status_block(cairo_t *cairo,
172 if (output->height < _ideal_surface_height) { 173 if (output->height < _ideal_surface_height) {
173 return _ideal_surface_height; 174 return _ideal_surface_height;
174 } 175 }
175 if (sep_width > block->separator_block_width) { 176 if (sep_width > sep_block_width) {
176 block->separator_block_width = sep_width + margin * 2; 177 sep_block_width = sep_width + margin * 2;
177 } 178 }
178 } 179 }
179 *x -= block->separator_block_width; 180 *x -= sep_block_width;
180 } else { 181 } else {
181 *x -= margin; 182 *x -= margin;
182 } 183 }
@@ -261,16 +262,14 @@ static uint32_t render_status_block(cairo_t *cairo,
261 cairo_set_source_u32(cairo, config->colors.separator); 262 cairo_set_source_u32(cairo, config->colors.separator);
262 } 263 }
263 if (config->sep_symbol) { 264 if (config->sep_symbol) {
264 offset = pos + (block->separator_block_width - sep_width) / 2; 265 offset = pos + (sep_block_width - sep_width) / 2;
265 cairo_move_to(cairo, offset, height / 2.0 - sep_height / 2.0); 266 cairo_move_to(cairo, offset, height / 2.0 - sep_height / 2.0);
266 pango_printf(cairo, config->font, output->scale, false, 267 pango_printf(cairo, config->font, output->scale, false,
267 "%s", config->sep_symbol); 268 "%s", config->sep_symbol);
268 } else { 269 } else {
269 cairo_set_line_width(cairo, 1); 270 cairo_set_line_width(cairo, 1);
270 cairo_move_to(cairo, 271 cairo_move_to(cairo, pos + sep_block_width / 2, margin);
271 pos + block->separator_block_width / 2, margin); 272 cairo_line_to(cairo, pos + sep_block_width / 2, height - margin);
272 cairo_line_to(cairo,
273 pos + block->separator_block_width / 2, height - margin);
274 cairo_stroke(cairo); 273 cairo_stroke(cairo);
275 } 274 }
276 } 275 }