Refactored out the FocusChainSwitching logic for the tabbox client model

This commit is contained in:
Rachel Mant 2022-06-10 16:49:13 -04:00 committed by Vlad Zahorodnii
parent 7e1617c280
commit 93f322d262
2 changed files with 27 additions and 18 deletions

View file

@ -154,23 +154,9 @@ void ClientModel::createClientList(bool partialReset)
createClientList(tabBox->currentDesktop(), partialReset); createClientList(tabBox->currentDesktop(), partialReset);
} }
void ClientModel::createClientList(int desktop, bool partialReset) void ClientModel::createFocusChainClientList(int desktop,
const QSharedPointer<TabBoxClient> &start, TabBoxClientList &stickyClients)
{ {
auto start = tabBox->activeClient().toStrongRef();
// TODO: new clients are not added at correct position
if (partialReset && !m_clientList.isEmpty()) {
QSharedPointer<TabBoxClient> firstClient = m_clientList.constFirst();
if (firstClient) {
start = firstClient;
}
}
beginResetModel();
m_clientList.clear();
QList<QWeakPointer<TabBoxClient>> stickyClients;
switch (tabBox->config().clientSwitchingMode()) {
case TabBoxConfig::FocusChainSwitching: {
auto c = start; auto c = start;
if (!tabBox->isInFocusChain(c.data())) { if (!tabBox->isInFocusChain(c.data())) {
QSharedPointer<TabBoxClient> firstClient = tabBox->firstClientFocusChain().toStrongRef(); QSharedPointer<TabBoxClient> firstClient = tabBox->firstClientFocusChain().toStrongRef();
@ -189,6 +175,26 @@ void ClientModel::createClientList(int desktop, bool partialReset)
} }
c = tabBox->nextClientFocusChain(c.data()); c = tabBox->nextClientFocusChain(c.data());
} while (c && c != stop); } while (c && c != stop);
}
void ClientModel::createClientList(int desktop, bool partialReset)
{
auto start = tabBox->activeClient().toStrongRef();
// TODO: new clients are not added at correct position
if (partialReset && !m_clientList.isEmpty()) {
QSharedPointer<TabBoxClient> firstClient = m_clientList.constFirst();
if (firstClient) {
start = firstClient;
}
}
beginResetModel();
m_clientList.clear();
QList<QWeakPointer<TabBoxClient>> stickyClients;
switch (tabBox->config().clientSwitchingMode()) {
case TabBoxConfig::FocusChainSwitching: {
createFocusChainClientList(desktop, start, stickyClients);
break; break;
} }
case TabBoxConfig::StackingOrderSwitching: { case TabBoxConfig::StackingOrderSwitching: {

View file

@ -94,6 +94,9 @@ public Q_SLOTS:
void activate(int index); void activate(int index);
private: private:
void createFocusChainClientList(int desktop, const QSharedPointer<TabBoxClient> &start,
TabBoxClientList &stickyClients);
TabBoxClientList m_clientList; TabBoxClientList m_clientList;
}; };