Modern variant of forEachClient/forEachUnmanaged
Takes a std::function as argument which allows to pass a lambda function which gets executed for each client/unmanged: ws->forEachClient([](Client *client) { client->releaseWindow(); });
This commit is contained in:
parent
4b97fb542e
commit
b90c2c0e6a
1 changed files with 17 additions and 0 deletions
17
workspace.h
17
workspace.h
|
@ -32,6 +32,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
// X
|
// X
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
|
// std
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
// TODO: Cleanup the order of things in this .h file
|
// TODO: Cleanup the order of things in this .h file
|
||||||
|
|
||||||
|
@ -76,9 +78,11 @@ public:
|
||||||
template<typename T> Client* findClient(T predicate) const;
|
template<typename T> Client* findClient(T predicate) const;
|
||||||
template<typename T1, typename T2> void forEachClient(T1 procedure, T2 predicate);
|
template<typename T1, typename T2> void forEachClient(T1 procedure, T2 predicate);
|
||||||
template<typename T> void forEachClient(T procedure);
|
template<typename T> void forEachClient(T procedure);
|
||||||
|
void forEachClient(std::function<void (Client*)> func);
|
||||||
template<typename T> Unmanaged* findUnmanaged(T predicate) const;
|
template<typename T> Unmanaged* findUnmanaged(T predicate) const;
|
||||||
template<typename T1, typename T2> void forEachUnmanaged(T1 procedure, T2 predicate);
|
template<typename T1, typename T2> void forEachUnmanaged(T1 procedure, T2 predicate);
|
||||||
template<typename T> void forEachUnmanaged(T procedure);
|
template<typename T> void forEachUnmanaged(T procedure);
|
||||||
|
void forEachUnmanaged(std::function<void (Unmanaged*)> func);
|
||||||
|
|
||||||
QRect clientArea(clientAreaOption, const QPoint& p, int desktop) const;
|
QRect clientArea(clientAreaOption, const QPoint& p, int desktop) const;
|
||||||
QRect clientArea(clientAreaOption, const Client* c) const;
|
QRect clientArea(clientAreaOption, const Client* c) const;
|
||||||
|
@ -686,6 +690,13 @@ inline void Workspace::forEachClient(T1 procedure, T2 predicate)
|
||||||
procedure(*it);
|
procedure(*it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
void Workspace::forEachClient(std::function< void (Client*) > func)
|
||||||
|
{
|
||||||
|
std::for_each(clients.constBegin(), clients.constEnd(), func);
|
||||||
|
std::for_each(desktops.constBegin(), desktops.constEnd(), func);
|
||||||
|
}
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
inline void Workspace::forEachClient(T procedure)
|
inline void Workspace::forEachClient(T procedure)
|
||||||
{
|
{
|
||||||
|
@ -712,6 +723,12 @@ inline void Workspace::forEachUnmanaged(T procedure)
|
||||||
return forEachUnmanaged(procedure, TruePredicate());
|
return forEachUnmanaged(procedure, TruePredicate());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
void Workspace::forEachUnmanaged(std::function< void (Unmanaged*) > func)
|
||||||
|
{
|
||||||
|
std::for_each(unmanaged.constBegin(), unmanaged.constEnd(), func);
|
||||||
|
}
|
||||||
|
|
||||||
KWIN_COMPARE_PREDICATE(ClientMatchPredicate, Client, const Client*, cl == value);
|
KWIN_COMPARE_PREDICATE(ClientMatchPredicate, Client, const Client*, cl == value);
|
||||||
|
|
||||||
inline bool Workspace::hasClient(const Client* c)
|
inline bool Workspace::hasClient(const Client* c)
|
||||||
|
|
Loading…
Reference in a new issue