summaryrefslogtreecommitdiff
path: root/LibGUI/GWidget.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-05-02 03:46:37 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-05-02 03:47:01 +0200
commit6d5507313e6449ae1081ec7812c07a9c0fa708f5 (patch)
tree5da29a218855955e255499d63e2746ddbbd074ec /LibGUI/GWidget.cpp
parentc3b7ace3e0d943326575b4d6d7b6a33e47d7242a (diff)
downloadserenity-6d5507313e6449ae1081ec7812c07a9c0fa708f5.zip
GWidget: Add set_updates_enabled() for temporarily suppressing updates.
Diffstat (limited to 'LibGUI/GWidget.cpp')
-rw-r--r--LibGUI/GWidget.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/LibGUI/GWidget.cpp b/LibGUI/GWidget.cpp
index 4b4cc35a52..fedecc8b74 100644
--- a/LibGUI/GWidget.cpp
+++ b/LibGUI/GWidget.cpp
@@ -283,6 +283,8 @@ void GWidget::leave_event(CEvent&)
void GWidget::update()
{
+ if (rect().is_empty())
+ return;
update(rect());
}
@@ -290,10 +292,17 @@ void GWidget::update(const Rect& rect)
{
if (!is_visible())
return;
- auto* w = window();
- if (!w)
- return;
- w->update(rect.translated(window_relative_rect().location()));
+
+ GWindow* window = m_window;
+ GWidget* parent = parent_widget();
+ while (parent) {
+ if (!parent->updates_enabled())
+ return;
+ window = parent->m_window;
+ parent = parent->parent_widget();
+ }
+ if (window)
+ window->update(rect.translated(window_relative_rect().location()));
}
Rect GWidget::window_relative_rect() const
@@ -516,3 +525,12 @@ void GWidget::unregister_local_shortcut_action(Badge<GAction>, GAction& action)
{
m_local_shortcut_actions.remove(action.shortcut());
}
+
+void GWidget::set_updates_enabled(bool enabled)
+{
+ if (m_updates_enabled == enabled)
+ return;
+ m_updates_enabled = enabled;
+ if (enabled)
+ update();
+}