1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-11 13:50:56 -05:00

fix(renderer): Fill background to the sub blocks

Paint the background on each sub block instead of the base surface.
Fixes the compositing ops.
This commit is contained in:
Michael Carlberg 2017-01-26 01:53:24 +01:00
parent b16c105514
commit 5283fbff01
3 changed files with 29 additions and 11 deletions

View file

@ -312,9 +312,7 @@ namespace cairo {
context& clip(const rect& r) { context& clip(const rect& r) {
*this << r; *this << r;
cairo_clip(m_c); return clip();
cairo_new_path(m_c);
return *this;
} }
context& reset_clip() { context& reset_clip() {

View file

@ -665,6 +665,7 @@ bool bar::on(const signals::eventqueue::start&) {
m_log.trace("bar: Draw empty bar"); m_log.trace("bar: Draw empty bar");
m_renderer->begin(m_opts.inner_area()); m_renderer->begin(m_opts.inner_area());
m_renderer->fill_background();
m_renderer->end(); m_renderer->end();
m_sig.emit(signals::ui::ready{}); m_sig.emit(signals::ui::ready{});

View file

@ -241,8 +241,6 @@ void renderer::begin(xcb_rectangle_t rect) {
static_cast<double>(m_rect.width), static_cast<double>(m_rect.width),
static_cast<double>(m_rect.height)}); static_cast<double>(m_rect.height)});
// clang-format on // clang-format on
fill_background();
} }
/** /**
@ -260,11 +258,28 @@ void renderer::end() {
m_log.trace_x("renderer: pop(%i)", static_cast<int>(m_align)); m_log.trace_x("renderer: pop(%i)", static_cast<int>(m_align));
m_context->pop(&m_blocks[m_align].pattern); m_context->pop(&m_blocks[m_align].pattern);
// Capture the concatenated block contents
// so that it can be masked with the corner pattern
if (m_cornermask != nullptr) {
m_context->push();
}
for (auto&& b : m_blocks) { for (auto&& b : m_blocks) {
if (block_w(b.first) && b.second.pattern != nullptr) { if (block_w(b.first) && b.second.pattern != nullptr) {
flush(b.first); flush(b.first);
} }
} }
if (m_cornermask != nullptr) {
cairo_pattern_t* pattern{nullptr};
m_context->pop(&pattern);
m_context->save();
{
*m_context << pattern;
m_context->mask(m_cornermask);
}
m_context->restore();
}
} }
m_context->restore(); m_context->restore();
@ -292,6 +307,13 @@ void renderer::flush(alignment a) {
{ {
*m_context << cairo::abspos{0.0, 0.0}; *m_context << cairo::abspos{0.0, 0.0};
*m_context << cairo::rect{m_rect.x + x, m_rect.y + y, w, h}; *m_context << cairo::rect{m_rect.x + x, m_rect.y + y, w, h};
m_context->clip();
*m_context << CAIRO_OPERATOR_CLEAR;
m_context->paint();
m_context->reset_clip();
*m_context << CAIRO_OPERATOR_OVER;
*m_context << cairo::translate{x, 0.0}; *m_context << cairo::translate{x, 0.0};
*m_context << m_blocks[a].pattern; *m_context << m_blocks[a].pattern;
@ -454,12 +476,7 @@ void renderer::fill_background() {
*m_context << m_bar.background; *m_context << m_bar.background;
} }
if (m_cornermask != nullptr) {
m_context->mask(m_cornermask);
} else {
m_context->paint(); m_context->paint();
}
m_context->restore(); m_context->restore();
} }
@ -672,6 +689,8 @@ bool renderer::on(const signals::parser::change_alignment& evt) {
m_blocks[m_align].y = 0.0; m_blocks[m_align].y = 0.0;
m_context->push(); m_context->push();
m_log.trace_x("renderer: push(%i)", static_cast<int>(m_align)); m_log.trace_x("renderer: push(%i)", static_cast<int>(m_align));
fill_background();
} }
return true; return true;
} }