diff --git a/LibGUI/GWidget.cpp b/LibGUI/GWidget.cpp index 62caf4cc7f..57236f363f 100644 --- a/LibGUI/GWidget.cpp +++ b/LibGUI/GWidget.cpp @@ -61,7 +61,7 @@ void GWidget::paintEvent(GPaintEvent& event) { if (fillWithBackgroundColor()) { Painter painter(*this); - painter.fill_rect(rect(), backgroundColor()); + painter.fill_rect(event.rect(), backgroundColor()); } for (auto* ch : children()) { auto* child = (GWidget*)ch; diff --git a/LibGUI/GWindow.cpp b/LibGUI/GWindow.cpp index 93d2dd9c54..53899e45ec 100644 --- a/LibGUI/GWindow.cpp +++ b/LibGUI/GWindow.cpp @@ -102,12 +102,12 @@ void GWindow::event(GEvent& event) if (!m_main_widget) return; auto& paint_event = static_cast(event); - if (paint_event.rect().is_empty()) { - m_main_widget->paintEvent(*make(m_main_widget->rect())); - } else { - m_main_widget->event(event); - } - int rc = gui_invalidate_window(m_window_id, nullptr); + auto rect = paint_event.rect(); + if (rect.is_empty()) + rect = m_main_widget->rect(); + m_main_widget->event(*make(rect)); + GUI_Rect gui_rect = rect; + int rc = gui_invalidate_window(m_window_id, &gui_rect); ASSERT(rc == 0); } diff --git a/LibGUI/GWindow.h b/LibGUI/GWindow.h index ece4b14cc3..08e79daea6 100644 --- a/LibGUI/GWindow.h +++ b/LibGUI/GWindow.h @@ -37,6 +37,8 @@ public: void close(); + GWidget* main_widget() { return m_main_widget; } + const GWidget* main_widget() const { return m_main_widget; } void set_main_widget(GWidget*); GraphicsBitmap* backing() { return m_backing.ptr(); } diff --git a/SharedGraphics/Painter.cpp b/SharedGraphics/Painter.cpp index 48e52f245b..c3e9d54d00 100644 --- a/SharedGraphics/Painter.cpp +++ b/SharedGraphics/Painter.cpp @@ -31,7 +31,7 @@ Painter::Painter(GWidget& widget) #ifdef DEBUG_WIDGET_UNDERDRAW // If the widget is not opaque, let's not mess it up with debugging color. - if (widget.fillWithBackgroundColor()) + if (widget.fillWithBackgroundColor() && m_window->main_widget() != &widget) fill_rect(widget.rect(), Color::Red); #endif }