Commit 756d4e6e authored by Vlad Zahorodnii's avatar Vlad Zahorodnii

Use explicit Chain type in the focus chain

Summary: The explicit Chain type makes code more cleaner.

Test Plan: Still compiles.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D14431
parent 85eec90c
......@@ -41,7 +41,7 @@ FocusChain::~FocusChain()
void FocusChain::remove(AbstractClient *client)
{
for (DesktopChains::iterator it = m_desktopFocusChains.begin();
for (auto it = m_desktopFocusChains.begin();
it != m_desktopFocusChains.end();
++it) {
it.value().removeAll(client);
......@@ -52,7 +52,7 @@ void FocusChain::remove(AbstractClient *client)
void FocusChain::resize(uint previousSize, uint newSize)
{
for (uint i = previousSize + 1; i <= newSize; ++i) {
m_desktopFocusChains.insert(i, QList<AbstractClient*>());
m_desktopFocusChains.insert(i, Chain());
}
for (uint i = previousSize; i > newSize; --i) {
m_desktopFocusChains.remove(i);
......@@ -66,7 +66,7 @@ AbstractClient *FocusChain::getForActivation(uint desktop) const
AbstractClient *FocusChain::getForActivation(uint desktop, int screen) const
{
DesktopChains::const_iterator it = m_desktopFocusChains.find(desktop);
auto it = m_desktopFocusChains.constFind(desktop);
if (it == m_desktopFocusChains.constEnd()) {
return NULL;
}
......@@ -92,7 +92,7 @@ void FocusChain::update(AbstractClient *client, FocusChain::Change change)
if (client->isOnAllDesktops()) {
// Now on all desktops, add it to focus chains it is not already in
for (DesktopChains::iterator it = m_desktopFocusChains.begin();
for (auto it = m_desktopFocusChains.begin();
it != m_desktopFocusChains.end();
++it) {
auto &chain = it.value();
......@@ -110,7 +110,7 @@ void FocusChain::update(AbstractClient *client, FocusChain::Change change)
}
} else {
// Now only on desktop, remove it anywhere else
for (DesktopChains::iterator it = m_desktopFocusChains.begin();
for (auto it = m_desktopFocusChains.begin();
it != m_desktopFocusChains.end();
++it) {
auto &chain = it.value();
......@@ -126,7 +126,7 @@ void FocusChain::update(AbstractClient *client, FocusChain::Change change)
updateClientInChain(client, change, m_mostRecentlyUsed);
}
void FocusChain::updateClientInChain(AbstractClient *client, FocusChain::Change change, QList< AbstractClient * >& chain)
void FocusChain::updateClientInChain(AbstractClient *client, FocusChain::Change change, Chain &chain)
{
if (change == MakeFirst) {
makeFirstInChain(client, chain);
......@@ -137,7 +137,7 @@ void FocusChain::updateClientInChain(AbstractClient *client, FocusChain::Change
}
}
void FocusChain::insertClientIntoChain(AbstractClient *client, QList< AbstractClient * >& chain)
void FocusChain::insertClientIntoChain(AbstractClient *client, Chain &chain)
{
if (chain.contains(client)) {
return;
......@@ -158,7 +158,7 @@ void FocusChain::moveAfterClient(AbstractClient *client, AbstractClient *referen
return;
}
for (DesktopChains::iterator it = m_desktopFocusChains.begin();
for (auto it = m_desktopFocusChains.begin();
it != m_desktopFocusChains.end();
++it) {
if (!client->isOnDesktop(it.key())) {
......@@ -169,7 +169,7 @@ void FocusChain::moveAfterClient(AbstractClient *client, AbstractClient *referen
moveAfterClientInChain(client, reference, m_mostRecentlyUsed);
}
void FocusChain::moveAfterClientInChain(AbstractClient *client, AbstractClient *reference, QList<AbstractClient *> &chain)
void FocusChain::moveAfterClientInChain(AbstractClient *client, AbstractClient *reference, Chain &chain)
{
if (!chain.contains(reference)) {
return;
......@@ -221,8 +221,8 @@ bool FocusChain::isUsableFocusCandidate(AbstractClient *c, AbstractClient *prev)
AbstractClient *FocusChain::nextForDesktop(AbstractClient *reference, uint desktop) const
{
DesktopChains::const_iterator it = m_desktopFocusChains.find(desktop);
if (it == m_desktopFocusChains.end()) {
auto it = m_desktopFocusChains.constFind(desktop);
if (it == m_desktopFocusChains.constEnd()) {
return NULL;
}
const auto &chain = it.value();
......@@ -235,7 +235,7 @@ AbstractClient *FocusChain::nextForDesktop(AbstractClient *reference, uint deskt
return NULL;
}
void FocusChain::makeFirstInChain(AbstractClient *client, QList< AbstractClient * >& chain)
void FocusChain::makeFirstInChain(AbstractClient *client, Chain &chain)
{
chain.removeAll(client);
if (client->isMinimized()) { // add it before the first minimized ...
......@@ -251,7 +251,7 @@ void FocusChain::makeFirstInChain(AbstractClient *client, QList< AbstractClient
}
}
void FocusChain::makeLastInChain(AbstractClient *client, QList< AbstractClient * >& chain)
void FocusChain::makeLastInChain(AbstractClient *client, Chain &chain)
{
chain.removeAll(client);
chain.prepend(client);
......@@ -259,8 +259,8 @@ void FocusChain::makeLastInChain(AbstractClient *client, QList< AbstractClient *
bool FocusChain::contains(AbstractClient *client, uint desktop) const
{
DesktopChains::const_iterator it = m_desktopFocusChains.find(desktop);
if (it == m_desktopFocusChains.end()) {
auto it = m_desktopFocusChains.constFind(desktop);
if (it == m_desktopFocusChains.constEnd()) {
return false;
}
return it.value().contains(client);
......
......@@ -189,6 +189,7 @@ public Q_SLOTS:
bool isUsableFocusCandidate(AbstractClient *c, AbstractClient *prev) const;
private:
using Chain = QList<AbstractClient*>;
/**
* @brief Makes @p client the first Client in the given focus @p chain.
*
......@@ -199,7 +200,7 @@ private:
* @param chain The focus chain to operate on
* @return void
**/
void makeFirstInChain(AbstractClient *client, QList<AbstractClient*> &chain);
void makeFirstInChain(AbstractClient *client, Chain &chain);
/**
* @brief Makes @p client the last Client in the given focus @p chain.
*
......@@ -210,13 +211,12 @@ private:
* @param chain The focus chain to operate on
* @return void
**/
void makeLastInChain(AbstractClient *client, QList<AbstractClient*> &chain);
void moveAfterClientInChain(AbstractClient *client, AbstractClient *reference, QList<AbstractClient*> &chain);
void updateClientInChain(AbstractClient *client, Change change, QList<AbstractClient*> &chain);
void insertClientIntoChain(AbstractClient *client, QList<AbstractClient*> &chain);
typedef QHash<uint, QList<AbstractClient*> > DesktopChains;
QList<AbstractClient*> m_mostRecentlyUsed;
DesktopChains m_desktopFocusChains;
void makeLastInChain(AbstractClient *client, Chain &chain);
void moveAfterClientInChain(AbstractClient *client, AbstractClient *reference, Chain &chain);
void updateClientInChain(AbstractClient *client, Change change, Chain &chain);
void insertClientIntoChain(AbstractClient *client, Chain &chain);
Chain m_mostRecentlyUsed;
QHash<uint, Chain> m_desktopFocusChains;
bool m_separateScreenFocus;
AbstractClient *m_activeClient;
uint m_currentDesktop;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment