aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Gräßlin <[email protected]>2016-11-17 10:34:11 +0100
committerMartin Gräßlin <[email protected]>2016-11-25 07:37:28 +0100
commitec2d862d4e98b5942fcb9c83487fec30336de8b8 (patch)
tree350ee3b5ddcacf50e95ed92671e808ee750e72b7
parent966775d609f41842e8788e3caec12702240e3926 (diff)
Port Compositor::windowRepaintsPending to use std::any_of
Summary: While investigating a repaint issue I had a hard time to work with the code and decided to change it to a more modern variant. Instead of duplicating the same logic for each of the lists it's now moved into a dedicated templated method which used std::any_of. Which is exactly the algorithm we need: if there is any window with a non empty repaints region it should return true. Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D3397
-rw-r--r--composite.cpp40
1 files changed, 24 insertions, 16 deletions
diff --git a/composite.cpp b/composite.cpp
index 41b948e..3005d22 100644
--- a/composite.cpp
+++ b/composite.cpp
@@ -772,32 +772,40 @@ void Compositor::performCompositing()
}
}
+template <class T>
+static bool repaintsPending(const QList<T*> &windows)
+{
+ return std::any_of(windows.begin(), windows.end(), [] (T *t) { return !t->repaints().isEmpty(); });
+}
+
bool Compositor::windowRepaintsPending() const
{
- foreach (Toplevel * c, Workspace::self()->clientList())
- if (!c->repaints().isEmpty())
+ if (repaintsPending(Workspace::self()->clientList())) {
return true;
- foreach (Toplevel * c, Workspace::self()->desktopList())
- if (!c->repaints().isEmpty())
+ }
+ if (repaintsPending(Workspace::self()->desktopList())) {
return true;
- foreach (Toplevel * c, Workspace::self()->unmanagedList())
- if (!c->repaints().isEmpty())
+ }
+ if (repaintsPending(Workspace::self()->unmanagedList())) {
return true;
- foreach (Toplevel * c, Workspace::self()->deletedList())
- if (!c->repaints().isEmpty())
+ }
+ if (repaintsPending(Workspace::self()->deletedList())) {
return true;
+ }
if (auto w = waylandServer()) {
const auto &clients = w->clients();
- for (auto c : clients) {
- if (c->readyForPainting() && !c->repaints().isEmpty()) {
- return true;
- }
+ auto test = [] (ShellClient *c) {
+ return c->readyForPainting() && !c->repaints().isEmpty();
+ };
+ if (std::any_of(clients.begin(), clients.end(), test)) {
+ return true;
}
const auto &internalClients = w->internalClients();
- for (auto c : internalClients) {
- if (c->isShown(true) && !c->repaints().isEmpty()) {
- return true;
- }
+ auto internalTest = [] (ShellClient *c) {
+ return c->isShown(true) && !c->repaints().isEmpty();
+ };
+ if (std::any_of(internalClients.begin(), internalClients.end(), internalTest)) {
+ return true;
}
}
return false;