From 93f322d262b3d216b78605c12759c390c0343886 Mon Sep 17 00:00:00 2001 From: Rachel Mant Date: Fri, 10 Jun 2022 16:49:13 -0400 Subject: [PATCH] Refactored out the FocusChainSwitching logic for the tabbox client model --- src/tabbox/clientmodel.cpp | 42 ++++++++++++++++++++++---------------- src/tabbox/clientmodel.h | 3 +++ 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/tabbox/clientmodel.cpp b/src/tabbox/clientmodel.cpp index 64d3f94e75..d46640cacc 100644 --- a/src/tabbox/clientmodel.cpp +++ b/src/tabbox/clientmodel.cpp @@ -154,6 +154,29 @@ void ClientModel::createClientList(bool partialReset) createClientList(tabBox->currentDesktop(), partialReset); } +void ClientModel::createFocusChainClientList(int desktop, + const QSharedPointer &start, TabBoxClientList &stickyClients) +{ + auto c = start; + if (!tabBox->isInFocusChain(c.data())) { + QSharedPointer firstClient = tabBox->firstClientFocusChain().toStrongRef(); + if (firstClient) { + c = firstClient; + } + } + auto stop = c; + do { + QSharedPointer add = tabBox->clientToAddToList(c.data(), desktop); + if (!add.isNull()) { + m_clientList += add; + if (add.data()->isFirstInTabBox()) { + stickyClients << add; + } + } + c = tabBox->nextClientFocusChain(c.data()); + } while (c && c != stop); +} + void ClientModel::createClientList(int desktop, bool partialReset) { auto start = tabBox->activeClient().toStrongRef(); @@ -171,24 +194,7 @@ void ClientModel::createClientList(int desktop, bool partialReset) switch (tabBox->config().clientSwitchingMode()) { case TabBoxConfig::FocusChainSwitching: { - auto c = start; - if (!tabBox->isInFocusChain(c.data())) { - QSharedPointer firstClient = tabBox->firstClientFocusChain().toStrongRef(); - if (firstClient) { - c = firstClient; - } - } - auto stop = c; - do { - QSharedPointer add = tabBox->clientToAddToList(c.data(), desktop); - if (!add.isNull()) { - m_clientList += add; - if (add.data()->isFirstInTabBox()) { - stickyClients << add; - } - } - c = tabBox->nextClientFocusChain(c.data()); - } while (c && c != stop); + createFocusChainClientList(desktop, start, stickyClients); break; } case TabBoxConfig::StackingOrderSwitching: { diff --git a/src/tabbox/clientmodel.h b/src/tabbox/clientmodel.h index 274b33ef85..e0c2c39e9c 100644 --- a/src/tabbox/clientmodel.h +++ b/src/tabbox/clientmodel.h @@ -94,6 +94,9 @@ public Q_SLOTS: void activate(int index); private: + void createFocusChainClientList(int desktop, const QSharedPointer &start, + TabBoxClientList &stickyClients); + TabBoxClientList m_clientList; };