From ab206a5f8e3423ae3f634a7c639e2da0aeb9777d Mon Sep 17 00:00:00 2001
From: Patrick Ziegler
Date: Mon, 11 Apr 2022 21:30:24 +0200
Subject: [PATCH] fix: No overlines/underlines being drawn when using offsets
(#2685)
---
CHANGELOG.md | 1 +
include/components/renderer.hpp | 2 +-
src/components/renderer.cpp | 18 +++++++++++++++---
3 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b25bcdb0..6f2524d2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `custom/script`: Output clearing when `exec-if` fails ([`#2674`](https://github.com/polybar/polybar/issues/2674))
- `internal/battery`: `poll-interval` not working ([`#2649`](https://github.com/polybar/polybar/issues/2649), [`#2677`](https://github.com/polybar/polybar/pull/2677))
- ipc: Polybar failing to open IPC channel after another user already ran polybar, if `XDG_RUNTIME_DIR` is not set ([`#2683`](https://github.com/polybar/polybar/issues/2683), [`#2684`](https://github.com/polybar/polybar/pull/2684))
+- No overlines/underlines being drawn when using offsets ([`#2685`](https://github.com/polybar/polybar/pull/2685))
## [3.6.2] - 2022-04-03
### Fixed
diff --git a/include/components/renderer.hpp b/include/components/renderer.hpp
index 5dfc998a..c399b7e8 100644
--- a/include/components/renderer.hpp
+++ b/include/components/renderer.hpp
@@ -72,7 +72,7 @@ class renderer : public renderer_interface,
void fill_overline(rgba color, double x, double w);
void fill_underline(rgba color, double x, double w);
void fill_borders();
- void draw_offset(rgba color, double x, double w);
+ void draw_offset(const tags::context& ctxt, rgba color, double x, double w);
double block_x(alignment a) const;
double block_y(alignment a) const;
diff --git a/src/components/renderer.cpp b/src/components/renderer.cpp
index 4da65ec9..493f5ef6 100644
--- a/src/components/renderer.cpp
+++ b/src/components/renderer.cpp
@@ -728,8 +728,12 @@ void renderer::render_text(const tags::context& ctxt, const string&& contents) {
}
}
-void renderer::draw_offset(rgba color, double x, double w) {
- if (w > 0 && color != m_bar.background) {
+void renderer::draw_offset(const tags::context& ctxt, rgba color, double x, double w) {
+ if (w <= 0) {
+ return;
+ }
+
+ if (color != m_bar.background) {
m_log.trace_x("renderer: offset(x=%f, w=%f)", x, w);
m_context->save();
*m_context << m_comp_bg;
@@ -739,6 +743,14 @@ void renderer::draw_offset(rgba color, double x, double w) {
m_context->fill();
m_context->restore();
}
+
+ if (ctxt.has_underline()) {
+ fill_underline(ctxt.get_ul(), x, w);
+ }
+
+ if (ctxt.has_overline()) {
+ fill_overline(ctxt.get_ol(), x, w);
+ }
}
void renderer::render_offset(const tags::context& ctxt, const extent_val offset) {
@@ -746,7 +758,7 @@ void renderer::render_offset(const tags::context& ctxt, const extent_val offset)
int offset_width = units_utils::extent_to_pixel(offset, m_bar.dpi_x);
rgba bg = ctxt.get_bg();
- draw_offset(bg, m_blocks[m_align].x, offset_width);
+ draw_offset(ctxt, bg, m_blocks[m_align].x, offset_width);
increase_x(offset_width);
}