diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-01-20 07:56:48 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-01-20 07:59:19 +0100 |
commit | a9e60fc80068af8ee3ef293d1287ab71f98197f2 (patch) | |
tree | 275ea475f8c74021838a5d300060e451c6580607 /LibGUI | |
parent | ea6678b7b321295024a34167c32b4b801f57311d (diff) | |
download | serenity-a9e60fc80068af8ee3ef293d1287ab71f98197f2.zip |
LibGUI: Only redraw the dirty rect in GWidget.
There is some trouble here with the asynchronous nature of WindowServer
and the single per-window backing store we're drawing into. If we start
repainting a widget with a pending invalidation, that invalidation might
get flushed by the WindowServer mid-paint.
Diffstat (limited to 'LibGUI')
-rw-r--r-- | LibGUI/GWidget.cpp | 2 | ||||
-rw-r--r-- | LibGUI/GWindow.cpp | 12 | ||||
-rw-r--r-- | LibGUI/GWindow.h | 2 |
3 files changed, 9 insertions, 7 deletions
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<GPaintEvent&>(event); - if (paint_event.rect().is_empty()) { - m_main_widget->paintEvent(*make<GPaintEvent>(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<GPaintEvent>(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(); } |