diff --git a/src/tabbox/clientmodel.cpp b/src/tabbox/clientmodel.cpp index d46640cacc..07f44b84d8 100644 --- a/src/tabbox/clientmodel.cpp +++ b/src/tabbox/clientmodel.cpp @@ -177,6 +177,39 @@ void ClientModel::createFocusChainClientList(int desktop, } while (c && c != stop); } +void ClientModel::createStackingOrderClientList(int desktop, + const QSharedPointer &start, TabBoxClientList &stickyClients) +{ + // TODO: needs improvement + const TabBoxClientList stacking = tabBox->stackingOrder(); + auto c = stacking.first().toStrongRef(); + auto stop = c; + int index = 0; + while (c) { + QSharedPointer add = tabBox->clientToAddToList(c.data(), desktop); + if (!add.isNull()) { + if (start == add.data()) { + m_clientList.removeAll(add); + m_clientList.prepend(add); + } else { + m_clientList += add; + } + if (add.data()->isFirstInTabBox()) { + stickyClients << add; + } + } + if (index >= stacking.size() - 1) { + c = nullptr; + } else { + c = stacking[++index]; + } + + if (c == stop) { + break; + } + } +} + void ClientModel::createClientList(int desktop, bool partialReset) { auto start = tabBox->activeClient().toStrongRef(); @@ -198,34 +231,7 @@ void ClientModel::createClientList(int desktop, bool partialReset) break; } case TabBoxConfig::StackingOrderSwitching: { - // TODO: needs improvement - const TabBoxClientList stacking = tabBox->stackingOrder(); - auto c = stacking.first().toStrongRef(); - auto stop = c; - int index = 0; - while (c) { - QSharedPointer add = tabBox->clientToAddToList(c.data(), desktop); - if (!add.isNull()) { - if (start == add.data()) { - m_clientList.removeAll(add); - m_clientList.prepend(add); - } else { - m_clientList += add; - } - if (add.data()->isFirstInTabBox()) { - stickyClients << add; - } - } - if (index >= stacking.size() - 1) { - c = nullptr; - } else { - c = stacking[++index]; - } - - if (c == stop) { - break; - } - } + createStackingOrderClientList(desktop, start, stickyClients); break; } } diff --git a/src/tabbox/clientmodel.h b/src/tabbox/clientmodel.h index e0c2c39e9c..721f4a65f2 100644 --- a/src/tabbox/clientmodel.h +++ b/src/tabbox/clientmodel.h @@ -96,6 +96,8 @@ public Q_SLOTS: private: void createFocusChainClientList(int desktop, const QSharedPointer &start, TabBoxClientList &stickyClients); + void createStackingOrderClientList(int desktop, const QSharedPointer &start, + TabBoxClientList &stickyClients); TabBoxClientList m_clientList; };