diff --git a/LibGUI/GWidget.cpp b/LibGUI/GWidget.cpp index 4b308c52d0..287b9c6e45 100644 --- a/LibGUI/GWidget.cpp +++ b/LibGUI/GWidget.cpp @@ -139,7 +139,16 @@ void GWidget::update() if (m_has_pending_paint_event) return; m_has_pending_paint_event = true; - w->update(relative_rect()); + w->update(window_relative_rect()); +} + +Rect GWidget::window_relative_rect() const +{ + auto rect = relative_rect(); + for (auto* parent = parent_widget(); parent; parent = parent->parent_widget()) { + rect.move_by(parent->relative_position()); + } + return rect; } GWidget::HitTestResult GWidget::hit_test(int x, int y) diff --git a/LibGUI/GWidget.h b/LibGUI/GWidget.h index 68db8a36d9..cb40a6dfa0 100644 --- a/LibGUI/GWidget.h +++ b/LibGUI/GWidget.h @@ -31,6 +31,8 @@ public: Rect relative_rect() const { return m_relative_rect; } Point relative_position() const { return m_relative_rect.location(); } + Rect window_relative_rect() const; + int x() const { return m_relative_rect.x(); } int y() const { return m_relative_rect.y(); } int width() const { return m_relative_rect.width(); }