diff options
author | Nathan Schulte <nmschulte@gmail.com> | 2021-09-15 05:07:07 -0500 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2021-09-20 09:53:32 +0200 |
commit | 033061aee602a54f65340e2a300054d2790c22ea (patch) | |
tree | 79aa689ba0523caeecd25e8d20320d60de8632b0 /swaybar/render.c | |
parent | Drop hardcoded font metric values (diff) | |
download | sway-033061aee602a54f65340e2a300054d2790c22ea.tar.gz sway-033061aee602a54f65340e2a300054d2790c22ea.tar.zst sway-033061aee602a54f65340e2a300054d2790c22ea.zip |
swaybar: properly draw blocks with transparent black border
while the draw itself is a no-op, alignment must still be accounted
this requires more signalling about the blocks (border_set; was the
border set?)
Diffstat (limited to 'swaybar/render.c')
-rw-r--r-- | swaybar/render.c | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/swaybar/render.c b/swaybar/render.c index 65cacd39..92b73f4c 100644 --- a/swaybar/render.c +++ b/swaybar/render.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include "swaybar/ipc.h" | 14 | #include "swaybar/ipc.h" |
15 | #include "swaybar/render.h" | 15 | #include "swaybar/render.h" |
16 | #include "swaybar/status_line.h" | 16 | #include "swaybar/status_line.h" |
17 | #include "log.h" | ||
17 | #if HAVE_TRAY | 18 | #if HAVE_TRAY |
18 | #include "swaybar/tray/tray.h" | 19 | #include "swaybar/tray/tray.h" |
19 | #endif | 20 | #endif |
@@ -215,11 +216,11 @@ static uint32_t render_status_block(struct render_context *ctx, | |||
215 | } | 216 | } |
216 | 217 | ||
217 | *x -= width; | 218 | *x -= width; |
218 | if ((block->border || block->urgent) && block->border_left > 0) { | 219 | if ((block->border_set || block->urgent) && block->border_left > 0) { |
219 | *x -= (block->border_left + margin); | 220 | *x -= (block->border_left + margin); |
220 | block_width += block->border_left + margin; | 221 | block_width += block->border_left + margin; |
221 | } | 222 | } |
222 | if ((block->border || block->urgent) && block->border_right > 0) { | 223 | if ((block->border_set || block->urgent) && block->border_right > 0) { |
223 | *x -= (block->border_right + margin); | 224 | *x -= (block->border_right + margin); |
224 | block_width += block->border_right + margin; | 225 | block_width += block->border_right + margin; |
225 | } | 226 | } |
@@ -273,18 +274,20 @@ static uint32_t render_status_block(struct render_context *ctx, | |||
273 | 274 | ||
274 | uint32_t border_color = block->urgent | 275 | uint32_t border_color = block->urgent |
275 | ? config->colors.urgent_workspace.border : block->border; | 276 | ? config->colors.urgent_workspace.border : block->border; |
276 | if (border_color && block->border_top > 0) { | 277 | if (block->border_set || block->urgent) { |
277 | render_sharp_line(cairo, border_color, x_pos, y_pos, | 278 | if (block->border_top > 0) { |
278 | block_width, block->border_top); | 279 | render_sharp_line(cairo, border_color, x_pos, y_pos, |
279 | } | 280 | block_width, block->border_top); |
280 | if (border_color && block->border_bottom > 0) { | 281 | } |
281 | render_sharp_line(cairo, border_color, x_pos, | 282 | if (block->border_bottom > 0) { |
282 | y_pos + render_height - block->border_bottom, | 283 | render_sharp_line(cairo, border_color, x_pos, |
283 | block_width, block->border_bottom); | 284 | y_pos + render_height - block->border_bottom, |
284 | } | 285 | block_width, block->border_bottom); |
285 | if (border_color && block->border_left > 0) { | 286 | } |
286 | render_sharp_line(cairo, border_color, x_pos, y_pos, | 287 | if (block->border_left > 0) { |
287 | block->border_left, render_height); | 288 | render_sharp_line(cairo, border_color, x_pos, y_pos, |
289 | block->border_left, render_height); | ||
290 | } | ||
288 | x_pos += block->border_left + margin; | 291 | x_pos += block->border_left + margin; |
289 | } | 292 | } |
290 | 293 | ||
@@ -307,10 +310,12 @@ static uint32_t render_status_block(struct render_context *ctx, | |||
307 | render_text(cairo, config->font, 1, block->markup, "%s", text); | 310 | render_text(cairo, config->font, 1, block->markup, "%s", text); |
308 | x_pos += width; | 311 | x_pos += width; |
309 | 312 | ||
310 | if (border_color && block->border_right > 0) { | 313 | if (block->border_set || block->urgent) { |
311 | x_pos += margin; | 314 | x_pos += margin; |
312 | render_sharp_line(cairo, border_color, x_pos, y_pos, | 315 | if (block->border_right > 0) { |
313 | block->border_right, render_height); | 316 | render_sharp_line(cairo, border_color, x_pos, y_pos, |
317 | block->border_right, render_height); | ||
318 | } | ||
314 | x_pos += block->border_right; | 319 | x_pos += block->border_right; |
315 | } | 320 | } |
316 | 321 | ||
@@ -375,10 +380,10 @@ static void predict_status_block_pos(cairo_t *cairo, | |||
375 | } | 380 | } |
376 | 381 | ||
377 | *x -= width; | 382 | *x -= width; |
378 | if ((block->border || block->urgent) && block->border_left > 0) { | 383 | if ((block->border_set || block->urgent) && block->border_left > 0) { |
379 | *x -= (block->border_left + margin); | 384 | *x -= (block->border_left + margin); |
380 | } | 385 | } |
381 | if ((block->border || block->urgent) && block->border_right > 0) { | 386 | if ((block->border_set || block->urgent) && block->border_right > 0) { |
382 | *x -= (block->border_right + margin); | 387 | *x -= (block->border_right + margin); |
383 | } | 388 | } |
384 | 389 | ||