diff --git a/Widgets/Painter.cpp b/Widgets/Painter.cpp index 41d284b2e1..a32471cee1 100644 --- a/Widgets/Painter.cpp +++ b/Widgets/Painter.cpp @@ -60,14 +60,31 @@ void Painter::draw_rect(const Rect& rect, Color color) int min_x = max(r.left(), m_clip_rect.left()); int max_x = min(r.right(), m_clip_rect.right()); - for (int y = min_y; y <= max_y; ++y) { - auto* bits = m_target->scanline(y); - if (y == r.top() || y == r.bottom()) { - fast_dword_fill(bits + min_x, color.value(), max_x - min_x + 1); - } else { - if (r.left() >= m_clip_rect.left() && r.left() <= m_clip_rect.right()) + if (r.top() >= min_y && r.top() <= max_y) { + fast_dword_fill(m_target->scanline(r.top()) + min_x, color.value(), max_x - min_x + 1); + ++min_y; + } + if (r.bottom() <= max_y && r.bottom() >= min_y) { + fast_dword_fill(m_target->scanline(r.bottom()) + min_x, color.value(), max_x - min_x + 1); + --max_y; + } + + bool draw_left_side = r.left() >= m_clip_rect.left() && r.left() <= m_clip_rect.right(); + bool draw_right_side = r.right() >= m_clip_rect.left() && r.right() <= m_clip_rect.right(); + + if (draw_left_side && draw_right_side) { + // Specialized loop when drawing both sides. + for (int y = min_y; y <= max_y; ++y) { + auto* bits = m_target->scanline(y); + bits[r.left()] = color.value(); + bits[r.right()] = color.value(); + } + } else { + for (int y = min_y; y <= max_y; ++y) { + auto* bits = m_target->scanline(y); + if (draw_left_side) bits[r.left()] = color.value(); - if (r.right() >= m_clip_rect.left() && r.right() <= m_clip_rect.right()) + if (draw_right_side) bits[r.right()] = color.value(); } } diff --git a/WindowServer/WSWindowManager.cpp b/WindowServer/WSWindowManager.cpp index 2ccd5e22ff..d9467facd8 100644 --- a/WindowServer/WSWindowManager.cpp +++ b/WindowServer/WSWindowManager.cpp @@ -158,9 +158,9 @@ void WSWindowManager::paintWindowFrame(WSWindow& window) auto titleColor = &window == activeWindow() ? m_activeWindowTitleColor : m_inactiveWindowTitleColor; auto borderColor = &window == activeWindow() ? m_activeWindowBorderColor : m_inactiveWindowBorderColor; + m_back_painter->fill_rect(titleBarRect, borderColor); m_back_painter->draw_rect(borderRect, Color::MidGray); m_back_painter->draw_rect(outerRect, borderColor); - m_back_painter->fill_rect(titleBarRect, borderColor); m_back_painter->draw_rect(inner_border_rect, borderColor); m_back_painter->draw_text(titleBarTitleRect, window.title(), Painter::TextAlignment::CenterLeft, titleColor); }