Workspace::ensureStackingOrder can operate on QList<Client*> or QList<AbstractClient*>

Preparation for getting Client::transients() to be AbstractClient as
ensureStackingOrder is called on the transients.
This commit is contained in:
Martin Gräßlin 2015-09-14 09:20:05 +02:00
parent ba8d11b305
commit 4ad749e560
2 changed files with 22 additions and 6 deletions

View file

@ -617,18 +617,21 @@ void Workspace::blockStackingUpdates(bool block)
}
}
// Ensure list is in stacking order
ClientList Workspace::ensureStackingOrder(const ClientList& list) const
namespace {
template <class T>
QList<T*> ensureStackingOrderInList(const ToplevelList &stackingOrder, const QList<T*> &list)
{
static_assert(std::is_base_of<Toplevel, T>::value,
"U must be derived from T");
// TODO Q_ASSERT( block_stacking_updates == 0 );
if (list.count() < 2)
return list;
// TODO is this worth optimizing?
ClientList result = list;
for (ToplevelList::ConstIterator it = stacking_order.constBegin();
it != stacking_order.constEnd();
QList<T*> result = list;
for (auto it = stackingOrder.begin();
it != stackingOrder.end();
++it) {
Client *c = qobject_cast<Client*>(*it);
T *c = qobject_cast<T*>(*it);
if (!c) {
continue;
}
@ -637,6 +640,18 @@ ClientList Workspace::ensureStackingOrder(const ClientList& list) const
}
return result;
}
}
// Ensure list is in stacking order
ClientList Workspace::ensureStackingOrder(const ClientList& list) const
{
return ensureStackingOrderInList(stacking_order, list);
}
QList<AbstractClient*> Workspace::ensureStackingOrder(const QList<AbstractClient*> &list) const
{
return ensureStackingOrderInList(stacking_order, list);
}
// check whether a transient should be actually kept above its mainwindow
// there may be some special cases where this rule shouldn't be enfored

View file

@ -243,6 +243,7 @@ public:
const ToplevelList& stackingOrder() const;
ToplevelList xStackingOrder() const;
ClientList ensureStackingOrder(const ClientList& clients) const;
QList<AbstractClient*> ensureStackingOrder(const QList<AbstractClient*> &clients) const;
Client* topClientOnDesktop(int desktop, int screen, bool unconstrained = false,
bool only_normal = true) const;