2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2012-07-21 09:25:17 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2012 Martin Gräßlin <mgraesslin@kde.org>
|
2012-07-21 09:25:17 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2012-07-21 09:25:17 +00:00
|
|
|
#include "mock_tabboxhandler.h"
|
|
|
|
#include "mock_tabboxclient.h"
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2014-06-10 09:14:59 +00:00
|
|
|
MockTabBoxHandler::MockTabBoxHandler(QObject *parent)
|
|
|
|
: TabBoxHandler(parent)
|
2012-07-21 09:25:17 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
MockTabBoxHandler::~MockTabBoxHandler()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void MockTabBoxHandler::grabbedKeyEvent(QKeyEvent *event) const
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
QWeakPointer<TabBox::TabBoxClient> MockTabBoxHandler::activeClient() const
|
2012-07-21 09:25:17 +00:00
|
|
|
{
|
2012-08-19 17:32:56 +00:00
|
|
|
return m_activeClient;
|
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void MockTabBoxHandler::setActiveClient(const QWeakPointer<TabBox::TabBoxClient> &client)
|
2012-08-19 17:32:56 +00:00
|
|
|
{
|
|
|
|
m_activeClient = client;
|
2012-07-21 09:25:17 +00:00
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
QWeakPointer<TabBox::TabBoxClient> MockTabBoxHandler::clientToAddToList(TabBox::TabBoxClient *client, int desktop) const
|
2012-07-21 09:25:17 +00:00
|
|
|
{
|
2022-03-23 10:13:38 +00:00
|
|
|
QList<QSharedPointer<TabBox::TabBoxClient>>::const_iterator it = m_windows.constBegin();
|
2012-07-21 09:25:17 +00:00
|
|
|
for (; it != m_windows.constEnd(); ++it) {
|
2022-08-01 21:29:02 +00:00
|
|
|
if ((*it).get() == client) {
|
2022-03-23 10:13:38 +00:00
|
|
|
return QWeakPointer<TabBox::TabBoxClient>(*it);
|
2012-07-21 09:25:17 +00:00
|
|
|
}
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
return QWeakPointer<TabBox::TabBoxClient>();
|
2012-07-21 09:25:17 +00:00
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
QWeakPointer<TabBox::TabBoxClient> MockTabBoxHandler::nextClientFocusChain(TabBox::TabBoxClient *client) const
|
2012-07-21 09:25:17 +00:00
|
|
|
{
|
2022-03-23 10:13:38 +00:00
|
|
|
QList<QSharedPointer<TabBox::TabBoxClient>>::const_iterator it = m_windows.constBegin();
|
2012-07-21 09:25:17 +00:00
|
|
|
for (; it != m_windows.constEnd(); ++it) {
|
2022-08-01 21:29:02 +00:00
|
|
|
if ((*it).get() == client) {
|
2012-07-21 09:25:17 +00:00
|
|
|
++it;
|
|
|
|
if (it == m_windows.constEnd()) {
|
2022-03-23 10:13:38 +00:00
|
|
|
return QWeakPointer<TabBox::TabBoxClient>(m_windows.first());
|
2012-07-21 09:25:17 +00:00
|
|
|
} else {
|
2022-03-23 10:13:38 +00:00
|
|
|
return QWeakPointer<TabBox::TabBoxClient>(*it);
|
2012-07-21 09:25:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-09-05 18:55:07 +00:00
|
|
|
if (!m_windows.isEmpty()) {
|
2022-03-23 10:13:38 +00:00
|
|
|
return QWeakPointer<TabBox::TabBoxClient>(m_windows.last());
|
2012-09-05 18:55:07 +00:00
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
return QWeakPointer<TabBox::TabBoxClient>();
|
2012-07-21 09:25:17 +00:00
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
QWeakPointer<TabBox::TabBoxClient> MockTabBoxHandler::firstClientFocusChain() const
|
2012-08-19 17:32:56 +00:00
|
|
|
{
|
|
|
|
if (m_windows.isEmpty()) {
|
|
|
|
return QWeakPointer<TabBox::TabBoxClient>();
|
|
|
|
}
|
|
|
|
return m_windows.first();
|
|
|
|
}
|
|
|
|
|
2012-09-05 18:55:07 +00:00
|
|
|
bool MockTabBoxHandler::isInFocusChain(TabBox::TabBoxClient *client) const
|
|
|
|
{
|
|
|
|
if (!client) {
|
|
|
|
return false;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
QList<QSharedPointer<TabBox::TabBoxClient>>::const_iterator it = m_windows.constBegin();
|
2012-09-05 18:55:07 +00:00
|
|
|
for (; it != m_windows.constEnd(); ++it) {
|
2022-08-01 21:29:02 +00:00
|
|
|
if ((*it).get() == client) {
|
2012-09-05 18:55:07 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
QWeakPointer<TabBox::TabBoxClient> MockTabBoxHandler::createMockWindow(const QString &caption)
|
2012-07-21 09:25:17 +00:00
|
|
|
{
|
2022-03-23 10:13:38 +00:00
|
|
|
QSharedPointer<TabBox::TabBoxClient> client(new MockTabBoxClient(caption));
|
2012-07-21 09:25:17 +00:00
|
|
|
m_windows.append(client);
|
2012-08-19 17:32:56 +00:00
|
|
|
m_activeClient = client;
|
2022-03-23 10:13:38 +00:00
|
|
|
return QWeakPointer<TabBox::TabBoxClient>(client);
|
2012-07-21 09:25:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MockTabBoxHandler::closeWindow(TabBox::TabBoxClient *client)
|
|
|
|
{
|
2022-03-23 10:13:38 +00:00
|
|
|
QList<QSharedPointer<TabBox::TabBoxClient>>::iterator it = m_windows.begin();
|
2012-07-21 09:25:17 +00:00
|
|
|
for (; it != m_windows.end(); ++it) {
|
2022-08-01 21:29:02 +00:00
|
|
|
if ((*it).get() == client) {
|
2012-07-21 09:25:17 +00:00
|
|
|
m_windows.erase(it);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace KWin
|