From 83252397e48561b629bfc9d4c0edd774361b65f3 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 12 Jan 2019 03:07:23 +0100 Subject: [PATCH] Ignore WindowManager invalidations inside already invalidated rects. --- Widgets/Rect.h | 8 ++++++++ Widgets/WindowManager.cpp | 9 +++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Widgets/Rect.h b/Widgets/Rect.h index f5e8f773fa..1d613f691e 100644 --- a/Widgets/Rect.h +++ b/Widgets/Rect.h @@ -63,6 +63,14 @@ public: return contains(point.x(), point.y()); } + bool contains(const Rect& other) const + { + return left() <= other.left() + && right() >= other.right() + && top() <= other.top() + && bottom() >= other.bottom(); + } + int left() const { return x(); } int right() const { return x() + width() - 1; } int top() const { return y(); } diff --git a/Widgets/WindowManager.cpp b/Widgets/WindowManager.cpp index f371772a45..a3eec92928 100644 --- a/Widgets/WindowManager.cpp +++ b/Widgets/WindowManager.cpp @@ -339,8 +339,13 @@ void WindowManager::invalidate() void WindowManager::invalidate(const Rect& rect) { - if (!rect.is_empty()) - m_invalidated_rects.append(rect); + if (rect.is_empty()) + return; + for (auto& r : m_invalidated_rects) { + if (r.contains(rect)) + return; + } + m_invalidated_rects.append(rect); } void WindowManager::invalidate(const Window& window)