diff --git a/src/components/bar.cpp b/src/components/bar.cpp index 70883382..a70a09ce 100644 --- a/src/components/bar.cpp +++ b/src/components/bar.cpp @@ -280,12 +280,20 @@ void bar::bootstrap_tray() { settings.width *= scale; settings.height_fill *= scale; - if (settings.align == alignment::RIGHT) { - settings.orig_x = m_opts.pos.x + m_opts.size.w - m_opts.borders.at(edge::RIGHT).size; - } else if (settings.align == alignment::LEFT) { - settings.orig_x = m_opts.pos.x + m_opts.borders.at(edge::LEFT).size; - } else if (settings.align == alignment::CENTER) { - settings.orig_x = m_opts.pos.x + m_opts.center.x - (settings.width / 2); + auto inner_area = m_opts.inner_area(true); + + switch (settings.align) { + case alignment::NONE: + break; + case alignment::LEFT: + settings.orig_x = inner_area.x; + break; + case alignment::CENTER: + settings.orig_x = inner_area.x + inner_area.width / 2 - settings.width / 2; + break; + case alignment::RIGHT: + settings.orig_x = inner_area.x + inner_area.width; + break; } // Set user-defined background color diff --git a/src/components/renderer.cpp b/src/components/renderer.cpp index e88a5149..ba50e0ac 100644 --- a/src/components/renderer.cpp +++ b/src/components/renderer.cpp @@ -210,27 +210,20 @@ void renderer::flush(bool clear) { // Calculate the area that was reserved so that we // can clear any previous content drawn at the same location - xcb_rectangle_t clear_area{0, 0, 0U, 0U}; + xcb_rectangle_t clear_area{r.x, r.y, r.width, r.height}; if (m_cleararea.size && m_cleararea.side == edge::RIGHT) { - clear_area.x = m_bar.size.w - m_cleararea.size - right.width; - clear_area.y = 0; + clear_area.x += r.width; + clear_area.y = top.height; clear_area.width = m_cleararea.size; - clear_area.height = m_bar.size.h; } else if (m_cleararea.size && m_cleararea.side == edge::LEFT) { clear_area.x = left.width; clear_area.y = top.height; clear_area.width = m_cleararea.size; - clear_area.height = m_rect.height; } else if (m_cleararea.size && m_cleararea.side == edge::TOP) { - clear_area.x = m_rect.x; - clear_area.y = m_rect.y; - clear_area.width = m_rect.width; clear_area.height = m_cleararea.size; - } else if (m_cleararea.size && m_cleararea.side == edge::TOP) { - clear_area.x = m_rect.x; - clear_area.y = m_rect.y + m_rect.height - m_cleararea.size; - clear_area.width = m_rect.width; + } else if (m_cleararea.size && m_cleararea.side == edge::BOTTOM) { + clear_area.y += r.height - m_cleararea.size; clear_area.height = m_cleararea.size; }