2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2012-11-16 07:23:47 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2012 Martin Gräßlin <mgraesslin@kde.org>
|
2012-11-16 07:23:47 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2021-02-09 18:18:36 +00:00
|
|
|
#include "input.h"
|
|
|
|
#include "virtualdesktops.h"
|
2012-11-16 07:23:47 +00:00
|
|
|
// KDE
|
2014-03-17 15:24:10 +00:00
|
|
|
#include <KConfigGroup>
|
2012-11-16 07:23:47 +00:00
|
|
|
|
2013-09-09 03:32:49 +00:00
|
|
|
#include <QAction>
|
2023-07-03 19:28:19 +00:00
|
|
|
#include <QSignalSpy>
|
|
|
|
#include <QTest>
|
2012-11-16 07:23:47 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
namespace KWin
|
|
|
|
{
|
2012-11-16 07:23:47 +00:00
|
|
|
|
2013-07-10 09:45:51 +00:00
|
|
|
InputRedirection *InputRedirection::s_self = nullptr;
|
|
|
|
|
2013-07-15 09:34:36 +00:00
|
|
|
void InputRedirection::registerAxisShortcut(Qt::KeyboardModifiers modifiers, PointerAxisDirection axis, QAction *action)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-01-25 16:06:32 +00:00
|
|
|
void InputRedirection::registerTouchpadSwipeShortcut(SwipeDirection direction, uint32_t fingerCount, QAction *onUp, std::function<void(qreal)> progressCallback)
|
2017-03-18 10:00:30 +00:00
|
|
|
{
|
2022-03-22 22:34:52 +00:00
|
|
|
}
|
2022-09-11 10:14:11 +00:00
|
|
|
|
2023-01-25 16:06:32 +00:00
|
|
|
void InputRedirection::registerTouchpadPinchShortcut(PinchDirection direction, uint32_t fingerCount, QAction *onUp, std::function<void(qreal)> progressCallback)
|
2022-09-11 10:14:11 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-01-25 16:06:32 +00:00
|
|
|
void InputRedirection::registerTouchscreenSwipeShortcut(SwipeDirection direction, uint32_t fingerCount, QAction *action, std::function<void(qreal)> progressCallback)
|
2022-09-11 10:14:11 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-11-16 07:23:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(Qt::Orientation)
|
|
|
|
|
|
|
|
using namespace KWin;
|
|
|
|
|
|
|
|
class TestVirtualDesktops : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2013-07-22 14:07:39 +00:00
|
|
|
private Q_SLOTS:
|
2012-11-16 07:23:47 +00:00
|
|
|
void init();
|
|
|
|
void cleanup();
|
|
|
|
void count_data();
|
|
|
|
void count();
|
|
|
|
void navigationWrapsAround_data();
|
|
|
|
void navigationWrapsAround();
|
|
|
|
void current_data();
|
|
|
|
void current();
|
|
|
|
void currentChangeOnCountChange_data();
|
|
|
|
void currentChangeOnCountChange();
|
|
|
|
void next_data();
|
|
|
|
void next();
|
|
|
|
void previous_data();
|
|
|
|
void previous();
|
|
|
|
void left_data();
|
|
|
|
void left();
|
|
|
|
void right_data();
|
|
|
|
void right();
|
|
|
|
void above_data();
|
|
|
|
void above();
|
|
|
|
void below_data();
|
|
|
|
void below();
|
|
|
|
void updateGrid_data();
|
|
|
|
void updateGrid();
|
|
|
|
void updateLayout_data();
|
|
|
|
void updateLayout();
|
|
|
|
void name_data();
|
|
|
|
void name();
|
|
|
|
void switchToShortcuts();
|
Fix changing the number of rows via the dbus protocol
Summary:
* save changes to the config files when the layout is saved
* :name() works even if netrootinfo isn't there
* as soon a rootinfo is set, connect all the desktops with name changes
Test Plan:
* tested with the kcm to add, remove and rename desktops, all of that works
* setting the number of rows still only partly works: kwin notices it but
the pager doesn't notice, a plasma restart is needed
Reviewers: #plasma, #kwin, hein, davidedmundson, graesslin
Reviewed By: #plasma, #kwin, hein, davidedmundson, graesslin
Subscribers: zzag, graesslin, davidedmundson, ngraham, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D17265
2019-01-09 09:10:28 +00:00
|
|
|
void changeRows();
|
2012-11-16 07:23:47 +00:00
|
|
|
void load();
|
|
|
|
void save();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void addDirectionColumns();
|
2022-11-18 20:12:09 +00:00
|
|
|
void testDirection(const QString &actionName, VirtualDesktopManager::Direction direction);
|
2012-11-16 07:23:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void TestVirtualDesktops::init()
|
|
|
|
{
|
|
|
|
VirtualDesktopManager::create();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestVirtualDesktops::cleanup()
|
|
|
|
{
|
|
|
|
delete VirtualDesktopManager::self();
|
|
|
|
}
|
|
|
|
|
|
|
|
static const uint s_countInitValue = 2;
|
|
|
|
|
|
|
|
void TestVirtualDesktops::count_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<uint>("request");
|
|
|
|
QTest::addColumn<uint>("result");
|
|
|
|
QTest::addColumn<bool>("signal");
|
|
|
|
QTest::addColumn<bool>("removedSignal");
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
QTest::newRow("Minimum") << (uint)1 << (uint)1 << true << true;
|
2012-11-16 07:23:47 +00:00
|
|
|
QTest::newRow("Below Minimum") << (uint)0 << (uint)1 << true << true;
|
2022-03-23 10:13:38 +00:00
|
|
|
QTest::newRow("Normal Value") << (uint)10 << (uint)10 << true << false;
|
|
|
|
QTest::newRow("Maximum") << VirtualDesktopManager::maximum() << VirtualDesktopManager::maximum() << true << false;
|
2012-11-16 07:23:47 +00:00
|
|
|
QTest::newRow("Above Maximum") << VirtualDesktopManager::maximum() + 1 << VirtualDesktopManager::maximum() << true << false;
|
2022-03-23 10:13:38 +00:00
|
|
|
QTest::newRow("Unchanged") << s_countInitValue << s_countInitValue << false << false;
|
2012-11-16 07:23:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestVirtualDesktops::count()
|
|
|
|
{
|
|
|
|
VirtualDesktopManager *vds = VirtualDesktopManager::self();
|
|
|
|
QCOMPARE(vds->count(), (uint)0);
|
|
|
|
// start with a useful desktop count
|
|
|
|
vds->setCount(s_countInitValue);
|
|
|
|
|
2019-07-29 19:45:19 +00:00
|
|
|
QSignalSpy spy(vds, &VirtualDesktopManager::countChanged);
|
|
|
|
QSignalSpy desktopsRemoved(vds, &VirtualDesktopManager::desktopRemoved);
|
2012-11-16 07:23:47 +00:00
|
|
|
|
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
|
|
|
auto vdToRemove = vds->desktops().last();
|
2019-07-29 19:45:19 +00:00
|
|
|
|
2012-11-16 07:23:47 +00:00
|
|
|
QFETCH(uint, request);
|
|
|
|
QFETCH(uint, result);
|
|
|
|
QFETCH(bool, signal);
|
|
|
|
QFETCH(bool, removedSignal);
|
|
|
|
vds->setCount(request);
|
|
|
|
QCOMPARE(vds->count(), result);
|
|
|
|
QCOMPARE(spy.isEmpty(), !signal);
|
|
|
|
if (!spy.isEmpty()) {
|
|
|
|
QList<QVariant> arguments = spy.takeFirst();
|
|
|
|
QCOMPARE(arguments.count(), 2);
|
|
|
|
QCOMPARE(arguments.at(0).type(), QVariant::UInt);
|
|
|
|
QCOMPARE(arguments.at(1).type(), QVariant::UInt);
|
|
|
|
QCOMPARE(arguments.at(0).toUInt(), s_countInitValue);
|
|
|
|
QCOMPARE(arguments.at(1).toUInt(), result);
|
|
|
|
}
|
|
|
|
QCOMPARE(desktopsRemoved.isEmpty(), !removedSignal);
|
|
|
|
if (!desktopsRemoved.isEmpty()) {
|
|
|
|
QList<QVariant> arguments = desktopsRemoved.takeFirst();
|
|
|
|
QCOMPARE(arguments.count(), 1);
|
2022-03-23 10:13:38 +00:00
|
|
|
QCOMPARE(arguments.at(0).value<KWin::VirtualDesktop *>(), vdToRemove);
|
2012-11-16 07:23:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestVirtualDesktops::navigationWrapsAround_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<bool>("init");
|
|
|
|
QTest::addColumn<bool>("request");
|
|
|
|
QTest::addColumn<bool>("result");
|
|
|
|
QTest::addColumn<bool>("signal");
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
QTest::newRow("enable") << false << true << true << true;
|
|
|
|
QTest::newRow("disable") << true << false << false << true;
|
|
|
|
QTest::newRow("keep enabled") << true << true << true << false;
|
2012-11-16 07:23:47 +00:00
|
|
|
QTest::newRow("keep disabled") << false << false << false << false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestVirtualDesktops::navigationWrapsAround()
|
|
|
|
{
|
|
|
|
VirtualDesktopManager *vds = VirtualDesktopManager::self();
|
|
|
|
QCOMPARE(vds->isNavigationWrappingAround(), false);
|
|
|
|
QFETCH(bool, init);
|
|
|
|
QFETCH(bool, request);
|
|
|
|
QFETCH(bool, result);
|
|
|
|
QFETCH(bool, signal);
|
|
|
|
|
|
|
|
// set to init value
|
|
|
|
vds->setNavigationWrappingAround(init);
|
|
|
|
QCOMPARE(vds->isNavigationWrappingAround(), init);
|
|
|
|
|
2019-07-29 19:45:19 +00:00
|
|
|
QSignalSpy spy(vds, &VirtualDesktopManager::navigationWrappingAroundChanged);
|
2012-11-16 07:23:47 +00:00
|
|
|
vds->setNavigationWrappingAround(request);
|
|
|
|
QCOMPARE(vds->isNavigationWrappingAround(), result);
|
|
|
|
QCOMPARE(spy.isEmpty(), !signal);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestVirtualDesktops::current_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<uint>("count");
|
|
|
|
QTest::addColumn<uint>("init");
|
|
|
|
QTest::addColumn<uint>("request");
|
|
|
|
QTest::addColumn<uint>("result");
|
|
|
|
QTest::addColumn<bool>("signal");
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
QTest::newRow("lower") << (uint)4 << (uint)3 << (uint)2 << (uint)2 << true;
|
|
|
|
QTest::newRow("higher") << (uint)4 << (uint)1 << (uint)2 << (uint)2 << true;
|
|
|
|
QTest::newRow("maximum") << (uint)4 << (uint)1 << (uint)4 << (uint)4 << true;
|
2012-11-16 07:23:47 +00:00
|
|
|
QTest::newRow("above maximum") << (uint)4 << (uint)1 << (uint)5 << (uint)1 << false;
|
2022-03-23 10:13:38 +00:00
|
|
|
QTest::newRow("minimum") << (uint)4 << (uint)2 << (uint)1 << (uint)1 << true;
|
2012-11-16 07:23:47 +00:00
|
|
|
QTest::newRow("below minimum") << (uint)4 << (uint)2 << (uint)0 << (uint)2 << false;
|
2022-03-23 10:13:38 +00:00
|
|
|
QTest::newRow("unchanged") << (uint)4 << (uint)2 << (uint)2 << (uint)2 << false;
|
2012-11-16 07:23:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestVirtualDesktops::current()
|
|
|
|
{
|
|
|
|
VirtualDesktopManager *vds = VirtualDesktopManager::self();
|
|
|
|
QCOMPARE(vds->current(), (uint)0);
|
|
|
|
QFETCH(uint, count);
|
|
|
|
QFETCH(uint, init);
|
2023-02-24 15:14:04 +00:00
|
|
|
vds->setCount(count);
|
|
|
|
vds->setCurrent(init);
|
2012-11-16 07:23:47 +00:00
|
|
|
QCOMPARE(vds->current(), init);
|
|
|
|
|
2019-07-29 19:45:19 +00:00
|
|
|
QSignalSpy spy(vds, &VirtualDesktopManager::currentChanged);
|
2012-11-16 07:23:47 +00:00
|
|
|
|
|
|
|
QFETCH(uint, request);
|
|
|
|
QFETCH(uint, result);
|
|
|
|
QFETCH(bool, signal);
|
|
|
|
QCOMPARE(vds->setCurrent(request), signal);
|
|
|
|
QCOMPARE(vds->current(), result);
|
|
|
|
QCOMPARE(spy.isEmpty(), !signal);
|
|
|
|
if (!spy.isEmpty()) {
|
|
|
|
QList<QVariant> arguments = spy.takeFirst();
|
|
|
|
QCOMPARE(arguments.count(), 2);
|
2023-02-23 17:37:46 +00:00
|
|
|
|
|
|
|
VirtualDesktop *previous = arguments.at(0).value<VirtualDesktop *>();
|
|
|
|
QCOMPARE(previous->x11DesktopNumber(), init);
|
|
|
|
|
|
|
|
VirtualDesktop *current = arguments.at(1).value<VirtualDesktop *>();
|
|
|
|
QCOMPARE(current->x11DesktopNumber(), result);
|
2012-11-16 07:23:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestVirtualDesktops::currentChangeOnCountChange_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<uint>("initCount");
|
|
|
|
QTest::addColumn<uint>("initCurrent");
|
|
|
|
QTest::addColumn<uint>("request");
|
|
|
|
QTest::addColumn<uint>("current");
|
|
|
|
QTest::addColumn<bool>("signal");
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
QTest::newRow("increment") << (uint)4 << (uint)2 << (uint)5 << (uint)2 << false;
|
|
|
|
QTest::newRow("increment on last") << (uint)4 << (uint)4 << (uint)5 << (uint)4 << false;
|
|
|
|
QTest::newRow("decrement") << (uint)4 << (uint)2 << (uint)3 << (uint)2 << false;
|
2012-11-16 07:23:47 +00:00
|
|
|
QTest::newRow("decrement on second last") << (uint)4 << (uint)3 << (uint)3 << (uint)3 << false;
|
2022-03-23 10:13:38 +00:00
|
|
|
QTest::newRow("decrement on last") << (uint)4 << (uint)4 << (uint)3 << (uint)3 << true;
|
|
|
|
QTest::newRow("multiple decrement") << (uint)4 << (uint)2 << (uint)1 << (uint)1 << true;
|
2012-11-16 07:23:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestVirtualDesktops::currentChangeOnCountChange()
|
|
|
|
{
|
|
|
|
VirtualDesktopManager *vds = VirtualDesktopManager::self();
|
|
|
|
QFETCH(uint, initCount);
|
|
|
|
QFETCH(uint, initCurrent);
|
|
|
|
vds->setCount(initCount);
|
|
|
|
vds->setCurrent(initCurrent);
|
|
|
|
|
2019-07-29 19:45:19 +00:00
|
|
|
QSignalSpy spy(vds, &VirtualDesktopManager::currentChanged);
|
2012-11-16 07:23:47 +00:00
|
|
|
|
|
|
|
QFETCH(uint, request);
|
|
|
|
QFETCH(uint, current);
|
|
|
|
QFETCH(bool, signal);
|
|
|
|
|
|
|
|
vds->setCount(request);
|
|
|
|
QCOMPARE(vds->current(), current);
|
|
|
|
QCOMPARE(spy.isEmpty(), !signal);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestVirtualDesktops::addDirectionColumns()
|
|
|
|
{
|
|
|
|
QTest::addColumn<uint>("initCount");
|
|
|
|
QTest::addColumn<uint>("initCurrent");
|
|
|
|
QTest::addColumn<bool>("wrap");
|
|
|
|
QTest::addColumn<uint>("result");
|
|
|
|
}
|
|
|
|
|
2022-11-18 20:12:09 +00:00
|
|
|
void TestVirtualDesktops::testDirection(const QString &actionName, VirtualDesktopManager::Direction direction)
|
2012-11-16 07:23:47 +00:00
|
|
|
{
|
|
|
|
VirtualDesktopManager *vds = VirtualDesktopManager::self();
|
|
|
|
QFETCH(uint, initCount);
|
|
|
|
QFETCH(uint, initCurrent);
|
|
|
|
vds->setCount(initCount);
|
|
|
|
vds->setCurrent(initCurrent);
|
|
|
|
|
|
|
|
QFETCH(bool, wrap);
|
|
|
|
QFETCH(uint, result);
|
2022-11-18 20:12:09 +00:00
|
|
|
QCOMPARE(vds->inDirection(nullptr, direction, wrap)->x11DesktopNumber(), result);
|
2012-11-16 07:23:47 +00:00
|
|
|
|
|
|
|
vds->setNavigationWrappingAround(wrap);
|
2014-01-07 12:45:25 +00:00
|
|
|
vds->initShortcuts();
|
2022-03-23 10:13:38 +00:00
|
|
|
QAction *action = vds->findChild<QAction *>(actionName);
|
2012-11-16 07:23:47 +00:00
|
|
|
QVERIFY(action);
|
|
|
|
action->trigger();
|
|
|
|
QCOMPARE(vds->current(), result);
|
2022-11-18 20:12:09 +00:00
|
|
|
QCOMPARE(vds->inDirection(initCurrent, direction, wrap), result);
|
2012-11-16 07:23:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestVirtualDesktops::next_data()
|
|
|
|
{
|
|
|
|
addDirectionColumns();
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
QTest::newRow("one desktop, wrap") << (uint)1 << (uint)1 << true << (uint)1;
|
|
|
|
QTest::newRow("one desktop, no wrap") << (uint)1 << (uint)1 << false << (uint)1;
|
|
|
|
QTest::newRow("desktops, wrap") << (uint)4 << (uint)1 << true << (uint)2;
|
|
|
|
QTest::newRow("desktops, no wrap") << (uint)4 << (uint)1 << false << (uint)2;
|
|
|
|
QTest::newRow("desktops at end, wrap") << (uint)4 << (uint)4 << true << (uint)1;
|
2012-11-16 07:23:47 +00:00
|
|
|
QTest::newRow("desktops at end, no wrap") << (uint)4 << (uint)4 << false << (uint)4;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestVirtualDesktops::next()
|
|
|
|
{
|
2022-11-18 20:12:09 +00:00
|
|
|
testDirection(QStringLiteral("Switch to Next Desktop"), VirtualDesktopManager::Direction::Next);
|
2012-11-16 07:23:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestVirtualDesktops::previous_data()
|
|
|
|
{
|
|
|
|
addDirectionColumns();
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
QTest::newRow("one desktop, wrap") << (uint)1 << (uint)1 << true << (uint)1;
|
|
|
|
QTest::newRow("one desktop, no wrap") << (uint)1 << (uint)1 << false << (uint)1;
|
|
|
|
QTest::newRow("desktops, wrap") << (uint)4 << (uint)3 << true << (uint)2;
|
|
|
|
QTest::newRow("desktops, no wrap") << (uint)4 << (uint)3 << false << (uint)2;
|
|
|
|
QTest::newRow("desktops at start, wrap") << (uint)4 << (uint)1 << true << (uint)4;
|
2012-11-16 07:23:47 +00:00
|
|
|
QTest::newRow("desktops at start, no wrap") << (uint)4 << (uint)1 << false << (uint)1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestVirtualDesktops::previous()
|
|
|
|
{
|
2022-11-18 20:12:09 +00:00
|
|
|
testDirection(QStringLiteral("Switch to Previous Desktop"), VirtualDesktopManager::Direction::Previous);
|
2012-11-16 07:23:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestVirtualDesktops::left_data()
|
|
|
|
{
|
|
|
|
addDirectionColumns();
|
2022-03-23 10:13:38 +00:00
|
|
|
QTest::newRow("one desktop, wrap") << (uint)1 << (uint)1 << true << (uint)1;
|
|
|
|
QTest::newRow("one desktop, no wrap") << (uint)1 << (uint)1 << false << (uint)1;
|
|
|
|
QTest::newRow("desktops, wrap, 1st row") << (uint)4 << (uint)2 << true << (uint)1;
|
2012-11-16 07:23:47 +00:00
|
|
|
QTest::newRow("desktops, no wrap, 1st row") << (uint)4 << (uint)2 << false << (uint)1;
|
2022-03-23 10:13:38 +00:00
|
|
|
QTest::newRow("desktops, wrap, 2nd row") << (uint)4 << (uint)4 << true << (uint)3;
|
2012-11-16 07:23:47 +00:00
|
|
|
QTest::newRow("desktops, no wrap, 2nd row") << (uint)4 << (uint)4 << false << (uint)3;
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
QTest::newRow("desktops at start, wrap, 1st row") << (uint)4 << (uint)1 << true << (uint)2;
|
2012-11-16 07:23:47 +00:00
|
|
|
QTest::newRow("desktops at start, no wrap, 1st row") << (uint)4 << (uint)1 << false << (uint)1;
|
2022-03-23 10:13:38 +00:00
|
|
|
QTest::newRow("desktops at start, wrap, 2nd row") << (uint)4 << (uint)3 << true << (uint)4;
|
2012-11-16 07:23:47 +00:00
|
|
|
QTest::newRow("desktops at start, no wrap, 2nd row") << (uint)4 << (uint)3 << false << (uint)3;
|
|
|
|
|
|
|
|
QTest::newRow("non symmetric, start") << (uint)5 << (uint)5 << false << (uint)4;
|
|
|
|
QTest::newRow("non symmetric, end, no wrap") << (uint)5 << (uint)4 << false << (uint)4;
|
|
|
|
QTest::newRow("non symmetric, end, wrap") << (uint)5 << (uint)4 << true << (uint)5;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestVirtualDesktops::left()
|
|
|
|
{
|
2022-11-18 20:12:09 +00:00
|
|
|
testDirection(QStringLiteral("Switch One Desktop to the Left"), VirtualDesktopManager::Direction::Left);
|
2012-11-16 07:23:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestVirtualDesktops::right_data()
|
|
|
|
{
|
|
|
|
addDirectionColumns();
|
2022-03-23 10:13:38 +00:00
|
|
|
QTest::newRow("one desktop, wrap") << (uint)1 << (uint)1 << true << (uint)1;
|
|
|
|
QTest::newRow("one desktop, no wrap") << (uint)1 << (uint)1 << false << (uint)1;
|
|
|
|
QTest::newRow("desktops, wrap, 1st row") << (uint)4 << (uint)1 << true << (uint)2;
|
2012-11-16 07:23:47 +00:00
|
|
|
QTest::newRow("desktops, no wrap, 1st row") << (uint)4 << (uint)1 << false << (uint)2;
|
2022-03-23 10:13:38 +00:00
|
|
|
QTest::newRow("desktops, wrap, 2nd row") << (uint)4 << (uint)3 << true << (uint)4;
|
2012-11-16 07:23:47 +00:00
|
|
|
QTest::newRow("desktops, no wrap, 2nd row") << (uint)4 << (uint)3 << false << (uint)4;
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
QTest::newRow("desktops at start, wrap, 1st row") << (uint)4 << (uint)2 << true << (uint)1;
|
2012-11-16 07:23:47 +00:00
|
|
|
QTest::newRow("desktops at start, no wrap, 1st row") << (uint)4 << (uint)2 << false << (uint)2;
|
2022-03-23 10:13:38 +00:00
|
|
|
QTest::newRow("desktops at start, wrap, 2nd row") << (uint)4 << (uint)4 << true << (uint)3;
|
2012-11-16 07:23:47 +00:00
|
|
|
QTest::newRow("desktops at start, no wrap, 2nd row") << (uint)4 << (uint)4 << false << (uint)4;
|
|
|
|
|
|
|
|
QTest::newRow("non symmetric, start") << (uint)5 << (uint)4 << false << (uint)5;
|
|
|
|
QTest::newRow("non symmetric, end, no wrap") << (uint)5 << (uint)5 << false << (uint)5;
|
|
|
|
QTest::newRow("non symmetric, end, wrap") << (uint)5 << (uint)5 << true << (uint)4;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestVirtualDesktops::right()
|
|
|
|
{
|
2022-11-18 20:12:09 +00:00
|
|
|
testDirection(QStringLiteral("Switch One Desktop to the Right"), VirtualDesktopManager::Direction::Right);
|
2012-11-16 07:23:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestVirtualDesktops::above_data()
|
|
|
|
{
|
|
|
|
addDirectionColumns();
|
2022-03-23 10:13:38 +00:00
|
|
|
QTest::newRow("one desktop, wrap") << (uint)1 << (uint)1 << true << (uint)1;
|
|
|
|
QTest::newRow("one desktop, no wrap") << (uint)1 << (uint)1 << false << (uint)1;
|
|
|
|
QTest::newRow("desktops, wrap, 1st column") << (uint)4 << (uint)3 << true << (uint)1;
|
2012-11-16 07:23:47 +00:00
|
|
|
QTest::newRow("desktops, no wrap, 1st column") << (uint)4 << (uint)3 << false << (uint)1;
|
2022-03-23 10:13:38 +00:00
|
|
|
QTest::newRow("desktops, wrap, 2nd column") << (uint)4 << (uint)4 << true << (uint)2;
|
2012-11-16 07:23:47 +00:00
|
|
|
QTest::newRow("desktops, no wrap, 2nd column") << (uint)4 << (uint)4 << false << (uint)2;
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
QTest::newRow("desktops at start, wrap, 1st column") << (uint)4 << (uint)1 << true << (uint)3;
|
2012-11-16 07:23:47 +00:00
|
|
|
QTest::newRow("desktops at start, no wrap, 1st column") << (uint)4 << (uint)1 << false << (uint)1;
|
2022-03-23 10:13:38 +00:00
|
|
|
QTest::newRow("desktops at start, wrap, 2nd column") << (uint)4 << (uint)2 << true << (uint)4;
|
2012-11-16 07:23:47 +00:00
|
|
|
QTest::newRow("desktops at start, no wrap, 2nd column") << (uint)4 << (uint)2 << false << (uint)2;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestVirtualDesktops::above()
|
|
|
|
{
|
2022-11-18 20:12:09 +00:00
|
|
|
testDirection(QStringLiteral("Switch One Desktop Up"), VirtualDesktopManager::Direction::Up);
|
2012-11-16 07:23:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestVirtualDesktops::below_data()
|
|
|
|
{
|
|
|
|
addDirectionColumns();
|
2022-03-23 10:13:38 +00:00
|
|
|
QTest::newRow("one desktop, wrap") << (uint)1 << (uint)1 << true << (uint)1;
|
|
|
|
QTest::newRow("one desktop, no wrap") << (uint)1 << (uint)1 << false << (uint)1;
|
|
|
|
QTest::newRow("desktops, wrap, 1st column") << (uint)4 << (uint)1 << true << (uint)3;
|
2012-11-16 07:23:47 +00:00
|
|
|
QTest::newRow("desktops, no wrap, 1st column") << (uint)4 << (uint)1 << false << (uint)3;
|
2022-03-23 10:13:38 +00:00
|
|
|
QTest::newRow("desktops, wrap, 2nd column") << (uint)4 << (uint)2 << true << (uint)4;
|
2012-11-16 07:23:47 +00:00
|
|
|
QTest::newRow("desktops, no wrap, 2nd column") << (uint)4 << (uint)2 << false << (uint)4;
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
QTest::newRow("desktops at start, wrap, 1st column") << (uint)4 << (uint)3 << true << (uint)1;
|
2012-11-16 07:23:47 +00:00
|
|
|
QTest::newRow("desktops at start, no wrap, 1st column") << (uint)4 << (uint)3 << false << (uint)3;
|
2022-03-23 10:13:38 +00:00
|
|
|
QTest::newRow("desktops at start, wrap, 2nd column") << (uint)4 << (uint)4 << true << (uint)2;
|
2012-11-16 07:23:47 +00:00
|
|
|
QTest::newRow("desktops at start, no wrap, 2nd column") << (uint)4 << (uint)4 << false << (uint)4;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestVirtualDesktops::below()
|
|
|
|
{
|
2022-11-18 20:12:09 +00:00
|
|
|
testDirection(QStringLiteral("Switch One Desktop Down"), VirtualDesktopManager::Direction::Down);
|
2012-11-16 07:23:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestVirtualDesktops::updateGrid_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<uint>("initCount");
|
|
|
|
QTest::addColumn<QSize>("size");
|
|
|
|
QTest::addColumn<QPoint>("coords");
|
|
|
|
QTest::addColumn<uint>("desktop");
|
2024-01-30 09:57:08 +00:00
|
|
|
|
|
|
|
QTest::newRow("one desktop, h") << (uint)1 << QSize(1, 1) << QPoint(0, 0) << (uint)1;
|
|
|
|
QTest::newRow("one desktop, h, 0") << (uint)1 << QSize(1, 1) << QPoint(1, 0) << (uint)0;
|
|
|
|
|
|
|
|
QTest::newRow("two desktops, h, 1") << (uint)2 << QSize(2, 1) << QPoint(0, 0) << (uint)1;
|
|
|
|
QTest::newRow("two desktops, h, 2") << (uint)2 << QSize(2, 1) << QPoint(1, 0) << (uint)2;
|
|
|
|
QTest::newRow("two desktops, h, 3") << (uint)2 << QSize(2, 1) << QPoint(0, 1) << (uint)0;
|
|
|
|
QTest::newRow("two desktops, h, 4") << (uint)2 << QSize(2, 1) << QPoint(2, 0) << (uint)0;
|
|
|
|
|
|
|
|
QTest::newRow("four desktops, h, one row, 1") << (uint)4 << QSize(4, 1) << QPoint(0, 0) << (uint)1;
|
|
|
|
QTest::newRow("four desktops, h, one row, 2") << (uint)4 << QSize(4, 1) << QPoint(1, 0) << (uint)2;
|
|
|
|
QTest::newRow("four desktops, h, one row, 3") << (uint)4 << QSize(4, 1) << QPoint(2, 0) << (uint)3;
|
|
|
|
QTest::newRow("four desktops, h, one row, 4") << (uint)4 << QSize(4, 1) << QPoint(3, 0) << (uint)4;
|
|
|
|
|
|
|
|
QTest::newRow("four desktops, h, grid, 1") << (uint)4 << QSize(2, 2) << QPoint(0, 0) << (uint)1;
|
|
|
|
QTest::newRow("four desktops, h, grid, 2") << (uint)4 << QSize(2, 2) << QPoint(1, 0) << (uint)2;
|
|
|
|
QTest::newRow("four desktops, h, grid, 3") << (uint)4 << QSize(2, 2) << QPoint(0, 1) << (uint)3;
|
|
|
|
QTest::newRow("four desktops, h, grid, 4") << (uint)4 << QSize(2, 2) << QPoint(1, 1) << (uint)4;
|
|
|
|
QTest::newRow("four desktops, h, grid, 0/3") << (uint)4 << QSize(2, 2) << QPoint(0, 3) << (uint)0;
|
|
|
|
|
|
|
|
QTest::newRow("three desktops, h, grid, 1") << (uint)3 << QSize(2, 2) << QPoint(0, 0) << (uint)1;
|
|
|
|
QTest::newRow("three desktops, h, grid, 2") << (uint)3 << QSize(2, 2) << QPoint(1, 0) << (uint)2;
|
|
|
|
QTest::newRow("three desktops, h, grid, 3") << (uint)3 << QSize(2, 2) << QPoint(0, 1) << (uint)3;
|
|
|
|
QTest::newRow("three desktops, h, grid, 4") << (uint)3 << QSize(2, 2) << QPoint(1, 1) << (uint)0;
|
2012-11-16 07:23:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestVirtualDesktops::updateGrid()
|
|
|
|
{
|
|
|
|
VirtualDesktopManager *vds = VirtualDesktopManager::self();
|
|
|
|
QFETCH(uint, initCount);
|
|
|
|
vds->setCount(initCount);
|
|
|
|
VirtualDesktopGrid grid;
|
|
|
|
|
|
|
|
QFETCH(QSize, size);
|
2016-11-10 13:02:14 +00:00
|
|
|
QCOMPARE(vds->desktops().count(), int(initCount));
|
2024-01-30 09:57:08 +00:00
|
|
|
grid.update(size, vds->desktops());
|
2012-11-16 07:23:47 +00:00
|
|
|
QCOMPARE(grid.size(), size);
|
|
|
|
QCOMPARE(grid.width(), size.width());
|
|
|
|
QCOMPARE(grid.height(), size.height());
|
|
|
|
QFETCH(QPoint, coords);
|
|
|
|
QFETCH(uint, desktop);
|
2016-11-10 13:02:14 +00:00
|
|
|
QCOMPARE(grid.at(coords), vds->desktopForX11Id(desktop));
|
2012-11-16 07:23:47 +00:00
|
|
|
if (desktop != 0) {
|
|
|
|
QCOMPARE(grid.gridCoords(desktop), coords);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestVirtualDesktops::updateLayout_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<uint>("desktop");
|
|
|
|
QTest::addColumn<QSize>("result");
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
QTest::newRow("01") << (uint)1 << QSize(1, 1);
|
|
|
|
QTest::newRow("02") << (uint)2 << QSize(1, 2);
|
|
|
|
QTest::newRow("03") << (uint)3 << QSize(2, 2);
|
|
|
|
QTest::newRow("04") << (uint)4 << QSize(2, 2);
|
|
|
|
QTest::newRow("05") << (uint)5 << QSize(3, 2);
|
|
|
|
QTest::newRow("06") << (uint)6 << QSize(3, 2);
|
|
|
|
QTest::newRow("07") << (uint)7 << QSize(4, 2);
|
|
|
|
QTest::newRow("08") << (uint)8 << QSize(4, 2);
|
|
|
|
QTest::newRow("09") << (uint)9 << QSize(5, 2);
|
2012-11-16 07:23:47 +00:00
|
|
|
QTest::newRow("10") << (uint)10 << QSize(5, 2);
|
|
|
|
QTest::newRow("11") << (uint)11 << QSize(6, 2);
|
|
|
|
QTest::newRow("12") << (uint)12 << QSize(6, 2);
|
|
|
|
QTest::newRow("13") << (uint)13 << QSize(7, 2);
|
|
|
|
QTest::newRow("14") << (uint)14 << QSize(7, 2);
|
|
|
|
QTest::newRow("15") << (uint)15 << QSize(8, 2);
|
|
|
|
QTest::newRow("16") << (uint)16 << QSize(8, 2);
|
|
|
|
QTest::newRow("17") << (uint)17 << QSize(9, 2);
|
|
|
|
QTest::newRow("18") << (uint)18 << QSize(9, 2);
|
|
|
|
QTest::newRow("19") << (uint)19 << QSize(10, 2);
|
|
|
|
QTest::newRow("20") << (uint)20 << QSize(10, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestVirtualDesktops::updateLayout()
|
|
|
|
{
|
|
|
|
VirtualDesktopManager *vds = VirtualDesktopManager::self();
|
2019-07-29 19:45:19 +00:00
|
|
|
QSignalSpy spy(vds, &VirtualDesktopManager::layoutChanged);
|
2012-11-16 07:23:47 +00:00
|
|
|
// call update layout - implicitly through setCount
|
|
|
|
QFETCH(uint, desktop);
|
|
|
|
QFETCH(QSize, result);
|
|
|
|
vds->setCount(desktop);
|
|
|
|
QCOMPARE(vds->grid().size(), result);
|
|
|
|
QCOMPARE(spy.count(), 1);
|
|
|
|
const QVariantList &arguments = spy.at(0);
|
|
|
|
QCOMPARE(arguments.at(0).toInt(), result.width());
|
|
|
|
QCOMPARE(arguments.at(1).toInt(), result.height());
|
|
|
|
// calling update layout again should not change anything
|
|
|
|
vds->updateLayout();
|
|
|
|
QCOMPARE(vds->grid().size(), result);
|
|
|
|
QCOMPARE(spy.count(), 2);
|
|
|
|
const QVariantList &arguments2 = spy.at(1);
|
|
|
|
QCOMPARE(arguments2.at(0).toInt(), result.width());
|
|
|
|
QCOMPARE(arguments2.at(1).toInt(), result.height());
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestVirtualDesktops::name_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<uint>("initCount");
|
|
|
|
QTest::addColumn<uint>("desktop");
|
|
|
|
QTest::addColumn<QString>("desktopName");
|
|
|
|
|
2021-08-30 23:45:00 +00:00
|
|
|
QTest::newRow("desktop 1") << (uint)5 << (uint)1 << "Desktop 1";
|
|
|
|
QTest::newRow("desktop 2") << (uint)5 << (uint)2 << "Desktop 2";
|
|
|
|
QTest::newRow("desktop 3") << (uint)5 << (uint)3 << "Desktop 3";
|
|
|
|
QTest::newRow("desktop 4") << (uint)5 << (uint)4 << "Desktop 4";
|
|
|
|
QTest::newRow("desktop 5") << (uint)5 << (uint)5 << "Desktop 5";
|
2012-11-16 07:23:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestVirtualDesktops::name()
|
|
|
|
{
|
|
|
|
VirtualDesktopManager *vds = VirtualDesktopManager::self();
|
|
|
|
QFETCH(uint, initCount);
|
|
|
|
vds->setCount(initCount);
|
|
|
|
QFETCH(uint, desktop);
|
|
|
|
|
2021-08-25 17:09:33 +00:00
|
|
|
const VirtualDesktop *vd = vds->desktopForX11Id(desktop);
|
|
|
|
QTEST(vd->name(), "desktopName");
|
2012-11-16 07:23:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestVirtualDesktops::switchToShortcuts()
|
|
|
|
{
|
|
|
|
VirtualDesktopManager *vds = VirtualDesktopManager::self();
|
|
|
|
vds->setCount(vds->maximum());
|
|
|
|
vds->setCurrent(vds->maximum());
|
|
|
|
QCOMPARE(vds->current(), vds->maximum());
|
2014-01-07 12:45:25 +00:00
|
|
|
vds->initShortcuts();
|
2013-07-23 05:02:52 +00:00
|
|
|
const QString toDesktop = QStringLiteral("Switch to Desktop %1");
|
2022-03-23 10:13:38 +00:00
|
|
|
for (uint i = 1; i <= vds->maximum(); ++i) {
|
2012-11-16 07:23:47 +00:00
|
|
|
const QString desktop(toDesktop.arg(i));
|
2022-03-23 10:13:38 +00:00
|
|
|
QAction *action = vds->findChild<QAction *>(desktop);
|
2012-11-16 07:23:47 +00:00
|
|
|
QVERIFY2(action, desktop.toUtf8().constData());
|
|
|
|
action->trigger();
|
|
|
|
QCOMPARE(vds->current(), i);
|
|
|
|
}
|
|
|
|
// invoke switchTo not from a QAction
|
|
|
|
QMetaObject::invokeMethod(vds, "slotSwitchTo");
|
|
|
|
// should still be on max
|
|
|
|
QCOMPARE(vds->current(), vds->maximum());
|
|
|
|
}
|
|
|
|
|
Fix changing the number of rows via the dbus protocol
Summary:
* save changes to the config files when the layout is saved
* :name() works even if netrootinfo isn't there
* as soon a rootinfo is set, connect all the desktops with name changes
Test Plan:
* tested with the kcm to add, remove and rename desktops, all of that works
* setting the number of rows still only partly works: kwin notices it but
the pager doesn't notice, a plasma restart is needed
Reviewers: #plasma, #kwin, hein, davidedmundson, graesslin
Reviewed By: #plasma, #kwin, hein, davidedmundson, graesslin
Subscribers: zzag, graesslin, davidedmundson, ngraham, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D17265
2019-01-09 09:10:28 +00:00
|
|
|
void TestVirtualDesktops::changeRows()
|
|
|
|
{
|
|
|
|
VirtualDesktopManager *vds = VirtualDesktopManager::self();
|
|
|
|
|
|
|
|
vds->setCount(4);
|
|
|
|
vds->setRows(4);
|
|
|
|
QCOMPARE(vds->rows(), 4);
|
|
|
|
|
|
|
|
vds->setRows(5);
|
|
|
|
QCOMPARE(vds->rows(), 4);
|
|
|
|
|
|
|
|
vds->setCount(2);
|
|
|
|
QCOMPARE(vds->rows(), 2);
|
|
|
|
}
|
|
|
|
|
2012-11-16 07:23:47 +00:00
|
|
|
void TestVirtualDesktops::load()
|
|
|
|
{
|
|
|
|
VirtualDesktopManager *vds = VirtualDesktopManager::self();
|
|
|
|
// no config yet, load should not change anything
|
|
|
|
vds->load();
|
|
|
|
QCOMPARE(vds->count(), (uint)0);
|
|
|
|
// empty config should create one desktop
|
|
|
|
KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
|
|
|
|
vds->setConfig(config);
|
|
|
|
vds->load();
|
|
|
|
QCOMPARE(vds->count(), (uint)1);
|
|
|
|
// setting a sensible number
|
2023-11-27 13:11:22 +00:00
|
|
|
config->group(QStringLiteral("Desktops")).writeEntry("Number", 4);
|
2012-11-16 07:23:47 +00:00
|
|
|
vds->load();
|
|
|
|
QCOMPARE(vds->count(), (uint)4);
|
2020-07-23 22:21:09 +00:00
|
|
|
|
|
|
|
// setting the config value and reloading should update
|
2023-11-27 13:11:22 +00:00
|
|
|
config->group(QStringLiteral("Desktops")).writeEntry("Number", 5);
|
2012-11-16 07:23:47 +00:00
|
|
|
vds->load();
|
|
|
|
QCOMPARE(vds->count(), (uint)5);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestVirtualDesktops::save()
|
|
|
|
{
|
|
|
|
VirtualDesktopManager *vds = VirtualDesktopManager::self();
|
|
|
|
vds->setCount(4);
|
|
|
|
// no config yet, just to ensure it actually works
|
|
|
|
vds->save();
|
|
|
|
KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
|
|
|
|
vds->setConfig(config);
|
|
|
|
|
|
|
|
// now save should create the group "Desktops"
|
2023-11-27 13:11:22 +00:00
|
|
|
QCOMPARE(config->hasGroup(QStringLiteral("Desktops")), false);
|
2012-11-16 07:23:47 +00:00
|
|
|
vds->save();
|
2023-11-27 13:11:22 +00:00
|
|
|
QCOMPARE(config->hasGroup(QStringLiteral("Desktops")), true);
|
|
|
|
KConfigGroup desktops = config->group(QStringLiteral("Desktops"));
|
2012-11-16 07:23:47 +00:00
|
|
|
QCOMPARE(desktops.readEntry<int>("Number", 1), 4);
|
|
|
|
QCOMPARE(desktops.hasKey("Name_1"), false);
|
|
|
|
QCOMPARE(desktops.hasKey("Name_2"), false);
|
|
|
|
QCOMPARE(desktops.hasKey("Name_3"), false);
|
|
|
|
QCOMPARE(desktops.hasKey("Name_4"), false);
|
|
|
|
}
|
|
|
|
|
|
|
|
QTEST_MAIN(TestVirtualDesktops)
|
|
|
|
#include "test_virtual_desktops.moc"
|