Commit e0bbf5c8 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii

Use std::transform in libkwineffects implementation part

Summary:
Don't use raw loops, instead, use appropriate algorithm from STL to map
a list of toplevels to a list of EffectWindow.

Test Plan:
Tested Cover switch, Flip switch, Dialog parent, and Dim inactive effect.
They all still work.

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: graesslin, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D13821
parent e0088b9c
......@@ -1078,10 +1078,12 @@ void EffectsHandlerImpl::setTabBoxDesktop(int desktop)
EffectWindowList EffectsHandlerImpl::currentTabBoxWindowList() const
{
#ifdef KWIN_BUILD_TABBOX
EffectWindowList ret;
const auto clients = TabBox::TabBox::self()->currentClientList();
for (auto c : clients)
ret.append(c->effectWindow());
EffectWindowList ret;
ret.reserve(clients.size());
std::transform(std::cbegin(clients), std::cend(clients),
std::back_inserter(ret),
[](auto client) { return client->effectWindow(); });
return ret;
#else
return EffectWindowList();
......@@ -1700,10 +1702,12 @@ template <typename T>
EffectWindowList getMainWindows(Toplevel *toplevel)
{
T *c = static_cast<T*>(toplevel);
EffectWindowList ret;
const auto mainclients = c->mainClients();
for (auto tmp : mainclients)
ret.append(tmp->effectWindow());
EffectWindowList ret;
ret.reserve(mainclients.size());
std::transform(std::cbegin(mainclients), std::cend(mainclients),
std::back_inserter(ret),
[](auto client) { return client->effectWindow(); });
return ret;
}
......@@ -1818,9 +1822,12 @@ void EffectWindowImpl::unreferencePreviousWindowPixmap()
EffectWindowList EffectWindowGroupImpl::members() const
{
const auto memberList = group->members();
EffectWindowList ret;
for (Toplevel * c : group->members())
ret.append(c->effectWindow());
ret.reserve(memberList.size());
std::transform(std::cbegin(memberList), std::cend(memberList),
std::back_inserter(ret),
[](auto toplevel) { return toplevel->effectWindow(); });
return ret;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment