2017-10-07 15:09:07 +03:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2017 Martin Flöser <mgraesslin@kde.org>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
|
|
|
#include "kwin_wayland_test.h"
|
|
|
|
#include "platform.h"
|
|
|
|
#include "rules.h"
|
|
|
|
#include "screens.h"
|
|
|
|
#include "shell_client.h"
|
|
|
|
#include "virtualdesktops.h"
|
|
|
|
#include "wayland_server.h"
|
2018-02-11 20:27:34 +03:00
|
|
|
#include "workspace.h"
|
2017-10-07 15:09:07 +03:00
|
|
|
|
|
|
|
#include <KWayland/Client/surface.h>
|
2018-03-12 20:06:33 +03:00
|
|
|
#include <KWayland/Client/xdgshell.h>
|
2017-10-07 15:09:07 +03:00
|
|
|
|
|
|
|
using namespace KWin;
|
|
|
|
using namespace KWayland::Client;
|
|
|
|
|
|
|
|
static const QString s_socketName = QStringLiteral("wayland_test_kwin_shell_client_rules-0");
|
|
|
|
|
|
|
|
|
|
|
|
class TestShellClientRules : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
private Q_SLOTS:
|
|
|
|
void initTestCase();
|
|
|
|
void init();
|
|
|
|
void cleanup();
|
|
|
|
|
|
|
|
void testApplyInitialDesktop_data();
|
|
|
|
void testApplyInitialDesktop();
|
2017-10-07 18:57:10 +03:00
|
|
|
void testApplyInitialMinimize_data();
|
|
|
|
void testApplyInitialMinimize();
|
2018-01-13 21:58:43 +03:00
|
|
|
void testApplyInitialSkipTaskbar_data();
|
|
|
|
void testApplyInitialSkipTaskbar();
|
|
|
|
void testApplyInitialSkipPager_data();
|
|
|
|
void testApplyInitialSkipPager();
|
|
|
|
void testApplyInitialSkipSwitcher_data();
|
|
|
|
void testApplyInitialSkipSwitcher();
|
2018-01-14 11:45:02 +03:00
|
|
|
void testApplyInitialKeepAbove_data();
|
|
|
|
void testApplyInitialKeepAbove();
|
|
|
|
void testApplyInitialKeepBelow_data();
|
|
|
|
void testApplyInitialKeepBelow();
|
2018-01-14 16:51:37 +03:00
|
|
|
void testApplyInitialShortcut_data();
|
|
|
|
void testApplyInitialShortcut();
|
2018-03-11 19:13:32 +03:00
|
|
|
void testApplyInitialDesktopfile_data();
|
|
|
|
void testApplyInitialDesktopfile();
|
2018-02-11 20:27:34 +03:00
|
|
|
void testOpacityActive_data();
|
|
|
|
void testOpacityActive();
|
2018-03-12 20:06:33 +03:00
|
|
|
void testMatchAfterNameChange();
|
2017-10-07 15:09:07 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
void TestShellClientRules::initTestCase()
|
|
|
|
{
|
|
|
|
qRegisterMetaType<KWin::ShellClient*>();
|
|
|
|
qRegisterMetaType<KWin::AbstractClient*>();
|
|
|
|
|
|
|
|
QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated);
|
|
|
|
QVERIFY(workspaceCreatedSpy.isValid());
|
|
|
|
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
|
2018-03-19 14:05:57 +03:00
|
|
|
QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2));
|
2017-10-07 15:09:07 +03:00
|
|
|
QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit()));
|
|
|
|
|
|
|
|
kwinApp()->start();
|
|
|
|
QVERIFY(workspaceCreatedSpy.wait());
|
|
|
|
QCOMPARE(screens()->count(), 2);
|
|
|
|
QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024));
|
|
|
|
QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024));
|
|
|
|
waylandServer()->initWorkspace();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestShellClientRules::init()
|
|
|
|
{
|
2017-10-07 18:57:10 +03:00
|
|
|
VirtualDesktopManager::self()->setCurrent(VirtualDesktopManager::self()->desktops().first());
|
2017-10-07 15:09:07 +03:00
|
|
|
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Decoration));
|
|
|
|
|
|
|
|
screens()->setCurrent(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestShellClientRules::cleanup()
|
|
|
|
{
|
|
|
|
Test::destroyWaylandConnection();
|
|
|
|
}
|
|
|
|
|
2018-01-13 21:58:43 +03:00
|
|
|
#define TEST_DATA( name ) \
|
|
|
|
void TestShellClientRules::name##_data() \
|
|
|
|
{ \
|
|
|
|
QTest::addColumn<Test::ShellSurfaceType>("type"); \
|
|
|
|
QTest::addColumn<int>("ruleNumber"); \
|
|
|
|
QTest::newRow("wlShell|Force") << Test::ShellSurfaceType::WlShell << 2; \
|
|
|
|
QTest::newRow("xdgShellV5|Force") << Test::ShellSurfaceType::XdgShellV5 << 2; \
|
|
|
|
QTest::newRow("xdgShellV6|Force") << Test::ShellSurfaceType::XdgShellV6 << 2; \
|
|
|
|
QTest::newRow("wlShell|Apply") << Test::ShellSurfaceType::WlShell << 3; \
|
|
|
|
QTest::newRow("xdgShellV5|Apply") << Test::ShellSurfaceType::XdgShellV5 << 3; \
|
|
|
|
QTest::newRow("xdgShellV6|Apply") << Test::ShellSurfaceType::XdgShellV6 << 3; \
|
|
|
|
QTest::newRow("wlShell|ApplyNow") << Test::ShellSurfaceType::WlShell << 5; \
|
|
|
|
QTest::newRow("xdgShellV5|ApplyNow") << Test::ShellSurfaceType::XdgShellV5 << 5; \
|
|
|
|
QTest::newRow("xdgShellV6|ApplyNow") << Test::ShellSurfaceType::XdgShellV6 << 5; \
|
|
|
|
QTest::newRow("wlShell|ForceTemporarily") << Test::ShellSurfaceType::WlShell << 6; \
|
|
|
|
QTest::newRow("xdgShellV5|ForceTemporarily") << Test::ShellSurfaceType::XdgShellV5 << 6; \
|
|
|
|
QTest::newRow("xdgShellV6|ForceTemporarily") << Test::ShellSurfaceType::XdgShellV6 << 6; \
|
2017-10-07 15:09:07 +03:00
|
|
|
}
|
|
|
|
|
2018-02-11 20:27:34 +03:00
|
|
|
#define TEST_FORCE_DATA( name ) \
|
|
|
|
void TestShellClientRules::name##_data() \
|
|
|
|
{ \
|
|
|
|
QTest::addColumn<Test::ShellSurfaceType>("type"); \
|
|
|
|
QTest::addColumn<int>("ruleNumber"); \
|
|
|
|
QTest::newRow("wlShell|Force") << Test::ShellSurfaceType::WlShell << 2; \
|
|
|
|
QTest::newRow("xdgShellV5|Force") << Test::ShellSurfaceType::XdgShellV5 << 2; \
|
|
|
|
QTest::newRow("xdgShellV6|Force") << Test::ShellSurfaceType::XdgShellV6 << 2; \
|
|
|
|
QTest::newRow("wlShell|ForceTemporarily") << Test::ShellSurfaceType::WlShell << 6; \
|
|
|
|
QTest::newRow("xdgShellV5|ForceTemporarily") << Test::ShellSurfaceType::XdgShellV5 << 6; \
|
|
|
|
QTest::newRow("xdgShellV6|ForceTemporarily") << Test::ShellSurfaceType::XdgShellV6 << 6; \
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-01-13 21:58:43 +03:00
|
|
|
TEST_DATA(testApplyInitialDesktop)
|
|
|
|
|
2017-10-07 15:09:07 +03:00
|
|
|
void TestShellClientRules::testApplyInitialDesktop()
|
|
|
|
{
|
|
|
|
// ensure we have two desktops and are on first desktop
|
|
|
|
VirtualDesktopManager::self()->setCount(2);
|
|
|
|
VirtualDesktopManager::self()->setCurrent(VirtualDesktopManager::self()->desktops().first());
|
|
|
|
|
|
|
|
// install the temporary rule
|
|
|
|
QFETCH(int, ruleNumber);
|
|
|
|
QString rule = QStringLiteral("desktop=2\ndesktoprule=%1").arg(ruleNumber);
|
|
|
|
QMetaObject::invokeMethod(RuleBook::self(), "temporaryRulesMessage", Q_ARG(QString, rule));
|
|
|
|
|
|
|
|
QScopedPointer<Surface> surface(Test::createSurface());
|
|
|
|
QFETCH(Test::ShellSurfaceType, type);
|
|
|
|
QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data()));
|
|
|
|
|
|
|
|
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
|
|
|
QVERIFY(c);
|
|
|
|
QCOMPARE(c->desktop(), 2);
|
2017-10-07 18:57:10 +03:00
|
|
|
QCOMPARE(c->isMinimized(), false);
|
|
|
|
QCOMPARE(c->isActive(), true);
|
2018-01-13 21:58:43 +03:00
|
|
|
QCOMPARE(c->skipTaskbar(), false);
|
|
|
|
QCOMPARE(c->skipPager(), false);
|
|
|
|
QCOMPARE(c->skipSwitcher(), false);
|
2018-01-14 11:45:02 +03:00
|
|
|
QCOMPARE(c->keepAbove(), false);
|
|
|
|
QCOMPARE(c->keepBelow(), false);
|
2018-01-14 16:51:37 +03:00
|
|
|
QCOMPARE(c->shortcut(), QKeySequence());
|
2017-10-07 18:57:10 +03:00
|
|
|
}
|
|
|
|
|
2018-01-13 21:58:43 +03:00
|
|
|
TEST_DATA(testApplyInitialMinimize)
|
|
|
|
|
|
|
|
void TestShellClientRules::testApplyInitialMinimize()
|
2017-10-07 18:57:10 +03:00
|
|
|
{
|
2018-01-13 21:58:43 +03:00
|
|
|
// install the temporary rule
|
|
|
|
QFETCH(int, ruleNumber);
|
|
|
|
QString rule = QStringLiteral("minimize=1\nminimizerule=%1").arg(ruleNumber);
|
|
|
|
QMetaObject::invokeMethod(RuleBook::self(), "temporaryRulesMessage", Q_ARG(QString, rule));
|
2017-10-07 18:57:10 +03:00
|
|
|
|
2018-01-13 21:58:43 +03:00
|
|
|
QScopedPointer<Surface> surface(Test::createSurface());
|
|
|
|
QFETCH(Test::ShellSurfaceType, type);
|
|
|
|
QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data()));
|
2017-10-07 18:57:10 +03:00
|
|
|
|
2018-01-13 21:58:43 +03:00
|
|
|
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
|
|
|
QVERIFY(c);
|
|
|
|
QCOMPARE(c->desktop(), 1);
|
|
|
|
QCOMPARE(c->isMinimized(), true);
|
|
|
|
QCOMPARE(c->isActive(), false);
|
|
|
|
c->setMinimized(false);
|
|
|
|
QCOMPARE(c->isMinimized(), false);
|
|
|
|
QCOMPARE(c->skipTaskbar(), false);
|
|
|
|
QCOMPARE(c->skipPager(), false);
|
|
|
|
QCOMPARE(c->skipSwitcher(), false);
|
2018-01-14 11:45:02 +03:00
|
|
|
QCOMPARE(c->keepAbove(), false);
|
|
|
|
QCOMPARE(c->keepBelow(), false);
|
2018-01-14 16:51:37 +03:00
|
|
|
QCOMPARE(c->shortcut(), QKeySequence());
|
2018-01-13 21:58:43 +03:00
|
|
|
}
|
2017-10-07 18:57:10 +03:00
|
|
|
|
2018-01-13 21:58:43 +03:00
|
|
|
TEST_DATA(testApplyInitialSkipTaskbar)
|
2017-10-07 18:57:10 +03:00
|
|
|
|
2018-01-13 21:58:43 +03:00
|
|
|
void TestShellClientRules::testApplyInitialSkipTaskbar()
|
|
|
|
{
|
|
|
|
// install the temporary rule
|
|
|
|
QFETCH(int, ruleNumber);
|
|
|
|
QString rule = QStringLiteral("skiptaskbar=true\nskiptaskbarrule=%1").arg(ruleNumber);
|
|
|
|
QMetaObject::invokeMethod(RuleBook::self(), "temporaryRulesMessage", Q_ARG(QString, rule));
|
|
|
|
|
|
|
|
QScopedPointer<Surface> surface(Test::createSurface());
|
|
|
|
QFETCH(Test::ShellSurfaceType, type);
|
|
|
|
QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data()));
|
|
|
|
|
|
|
|
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
|
|
|
QVERIFY(c);
|
|
|
|
QCOMPARE(c->desktop(), 1);
|
|
|
|
QCOMPARE(c->isMinimized(), false);
|
|
|
|
QCOMPARE(c->isActive(), true);
|
|
|
|
QCOMPARE(c->skipTaskbar(), true);
|
|
|
|
QCOMPARE(c->skipPager(), false);
|
|
|
|
QCOMPARE(c->skipSwitcher(), false);
|
2018-01-14 11:45:02 +03:00
|
|
|
QCOMPARE(c->keepAbove(), false);
|
|
|
|
QCOMPARE(c->keepBelow(), false);
|
2018-01-14 16:51:37 +03:00
|
|
|
QCOMPARE(c->shortcut(), QKeySequence());
|
2017-10-07 18:57:10 +03:00
|
|
|
}
|
|
|
|
|
2018-01-13 21:58:43 +03:00
|
|
|
TEST_DATA(testApplyInitialSkipPager)
|
|
|
|
|
|
|
|
void TestShellClientRules::testApplyInitialSkipPager()
|
2017-10-07 18:57:10 +03:00
|
|
|
{
|
|
|
|
// install the temporary rule
|
|
|
|
QFETCH(int, ruleNumber);
|
2018-01-13 21:58:43 +03:00
|
|
|
QString rule = QStringLiteral("skippager=true\nskippagerrule=%1").arg(ruleNumber);
|
|
|
|
QMetaObject::invokeMethod(RuleBook::self(), "temporaryRulesMessage", Q_ARG(QString, rule));
|
|
|
|
|
|
|
|
QScopedPointer<Surface> surface(Test::createSurface());
|
|
|
|
QFETCH(Test::ShellSurfaceType, type);
|
|
|
|
QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data()));
|
|
|
|
|
|
|
|
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
|
|
|
QVERIFY(c);
|
|
|
|
QCOMPARE(c->desktop(), 1);
|
|
|
|
QCOMPARE(c->isMinimized(), false);
|
|
|
|
QCOMPARE(c->isActive(), true);
|
|
|
|
QCOMPARE(c->skipTaskbar(), false);
|
|
|
|
QCOMPARE(c->skipPager(), true);
|
|
|
|
QCOMPARE(c->skipSwitcher(), false);
|
2018-01-14 11:45:02 +03:00
|
|
|
QCOMPARE(c->keepAbove(), false);
|
|
|
|
QCOMPARE(c->keepBelow(), false);
|
2018-01-14 16:51:37 +03:00
|
|
|
QCOMPARE(c->shortcut(), QKeySequence());
|
2018-01-13 21:58:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_DATA(testApplyInitialSkipSwitcher)
|
|
|
|
|
|
|
|
void TestShellClientRules::testApplyInitialSkipSwitcher()
|
|
|
|
{
|
|
|
|
// install the temporary rule
|
|
|
|
QFETCH(int, ruleNumber);
|
|
|
|
QString rule = QStringLiteral("skipswitcher=true\nskipswitcherrule=%1").arg(ruleNumber);
|
2017-10-07 18:57:10 +03:00
|
|
|
QMetaObject::invokeMethod(RuleBook::self(), "temporaryRulesMessage", Q_ARG(QString, rule));
|
|
|
|
|
|
|
|
QScopedPointer<Surface> surface(Test::createSurface());
|
|
|
|
QFETCH(Test::ShellSurfaceType, type);
|
|
|
|
QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data()));
|
|
|
|
|
|
|
|
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
|
|
|
QVERIFY(c);
|
|
|
|
QCOMPARE(c->desktop(), 1);
|
|
|
|
QCOMPARE(c->isMinimized(), false);
|
2018-01-13 21:58:43 +03:00
|
|
|
QCOMPARE(c->isActive(), true);
|
|
|
|
QCOMPARE(c->skipTaskbar(), false);
|
|
|
|
QCOMPARE(c->skipPager(), false);
|
|
|
|
QCOMPARE(c->skipSwitcher(), true);
|
2018-01-14 11:45:02 +03:00
|
|
|
QCOMPARE(c->keepAbove(), false);
|
|
|
|
QCOMPARE(c->keepBelow(), false);
|
2018-01-14 16:51:37 +03:00
|
|
|
QCOMPARE(c->shortcut(), QKeySequence());
|
2018-01-14 11:45:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_DATA(testApplyInitialKeepAbove)
|
|
|
|
|
|
|
|
void TestShellClientRules::testApplyInitialKeepAbove()
|
|
|
|
{
|
|
|
|
// install the temporary rule
|
|
|
|
QFETCH(int, ruleNumber);
|
|
|
|
QString rule = QStringLiteral("above=true\naboverule=%1").arg(ruleNumber);
|
|
|
|
QMetaObject::invokeMethod(RuleBook::self(), "temporaryRulesMessage", Q_ARG(QString, rule));
|
|
|
|
|
|
|
|
QScopedPointer<Surface> surface(Test::createSurface());
|
|
|
|
QFETCH(Test::ShellSurfaceType, type);
|
|
|
|
QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data()));
|
|
|
|
|
|
|
|
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
|
|
|
QVERIFY(c);
|
|
|
|
QCOMPARE(c->desktop(), 1);
|
|
|
|
QCOMPARE(c->isMinimized(), false);
|
|
|
|
QCOMPARE(c->isActive(), true);
|
|
|
|
QCOMPARE(c->skipTaskbar(), false);
|
|
|
|
QCOMPARE(c->skipPager(), false);
|
|
|
|
QCOMPARE(c->skipSwitcher(), false);
|
|
|
|
QCOMPARE(c->keepAbove(), true);
|
|
|
|
QCOMPARE(c->keepBelow(), false);
|
2018-01-14 16:51:37 +03:00
|
|
|
QCOMPARE(c->shortcut(), QKeySequence());
|
2018-01-14 11:45:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_DATA(testApplyInitialKeepBelow)
|
|
|
|
|
|
|
|
void TestShellClientRules::testApplyInitialKeepBelow()
|
|
|
|
{
|
|
|
|
// install the temporary rule
|
|
|
|
QFETCH(int, ruleNumber);
|
|
|
|
QString rule = QStringLiteral("below=true\nbelowrule=%1").arg(ruleNumber);
|
|
|
|
QMetaObject::invokeMethod(RuleBook::self(), "temporaryRulesMessage", Q_ARG(QString, rule));
|
|
|
|
|
|
|
|
QScopedPointer<Surface> surface(Test::createSurface());
|
|
|
|
QFETCH(Test::ShellSurfaceType, type);
|
|
|
|
QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data()));
|
|
|
|
|
|
|
|
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
|
|
|
QVERIFY(c);
|
|
|
|
QCOMPARE(c->desktop(), 1);
|
|
|
|
QCOMPARE(c->isMinimized(), false);
|
|
|
|
QCOMPARE(c->isActive(), true);
|
|
|
|
QCOMPARE(c->skipTaskbar(), false);
|
|
|
|
QCOMPARE(c->skipPager(), false);
|
|
|
|
QCOMPARE(c->skipSwitcher(), false);
|
|
|
|
QCOMPARE(c->keepAbove(), false);
|
|
|
|
QCOMPARE(c->keepBelow(), true);
|
2018-01-14 16:51:37 +03:00
|
|
|
QCOMPARE(c->shortcut(), QKeySequence());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_DATA(testApplyInitialShortcut)
|
|
|
|
|
|
|
|
void TestShellClientRules::testApplyInitialShortcut()
|
|
|
|
{
|
|
|
|
// install the temporary rule
|
|
|
|
QFETCH(int, ruleNumber);
|
|
|
|
const QKeySequence sequence{Qt::ControlModifier + Qt::ShiftModifier + Qt::MetaModifier + Qt::AltModifier + Qt::Key_Space};
|
|
|
|
QString rule = QStringLiteral("shortcut=%1\nshortcutrule=%2").arg(sequence.toString()).arg(ruleNumber);
|
|
|
|
QMetaObject::invokeMethod(RuleBook::self(), "temporaryRulesMessage", Q_ARG(QString, rule));
|
|
|
|
|
|
|
|
QScopedPointer<Surface> surface(Test::createSurface());
|
|
|
|
QFETCH(Test::ShellSurfaceType, type);
|
|
|
|
QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data()));
|
|
|
|
|
|
|
|
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
|
|
|
QVERIFY(c);
|
|
|
|
QCOMPARE(c->desktop(), 1);
|
|
|
|
QCOMPARE(c->isMinimized(), false);
|
|
|
|
QCOMPARE(c->isActive(), true);
|
|
|
|
QCOMPARE(c->skipTaskbar(), false);
|
|
|
|
QCOMPARE(c->skipPager(), false);
|
|
|
|
QCOMPARE(c->skipSwitcher(), false);
|
|
|
|
QCOMPARE(c->keepAbove(), false);
|
|
|
|
QCOMPARE(c->keepBelow(), false);
|
|
|
|
QCOMPARE(c->shortcut(), sequence);
|
2017-10-07 15:09:07 +03:00
|
|
|
}
|
|
|
|
|
2018-03-11 19:13:32 +03:00
|
|
|
TEST_DATA(testApplyInitialDesktopfile)
|
|
|
|
|
|
|
|
void TestShellClientRules::testApplyInitialDesktopfile()
|
|
|
|
{
|
|
|
|
// install the temporary rule
|
|
|
|
QFETCH(int, ruleNumber);
|
|
|
|
QString rule = QStringLiteral("desktopfile=org.kde.kwin\ndesktopfilerule=%1").arg(ruleNumber);
|
|
|
|
QMetaObject::invokeMethod(RuleBook::self(), "temporaryRulesMessage", Q_ARG(QString, rule));
|
|
|
|
|
|
|
|
QScopedPointer<Surface> surface(Test::createSurface());
|
|
|
|
QFETCH(Test::ShellSurfaceType, type);
|
|
|
|
QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data()));
|
|
|
|
|
|
|
|
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
|
|
|
QVERIFY(c);
|
|
|
|
QCOMPARE(c->desktop(), 1);
|
|
|
|
QCOMPARE(c->isMinimized(), false);
|
|
|
|
QCOMPARE(c->isActive(), true);
|
|
|
|
QCOMPARE(c->skipTaskbar(), false);
|
|
|
|
QCOMPARE(c->skipPager(), false);
|
|
|
|
QCOMPARE(c->skipSwitcher(), false);
|
|
|
|
QCOMPARE(c->keepAbove(), false);
|
|
|
|
QCOMPARE(c->keepBelow(), false);
|
|
|
|
QCOMPARE(c->shortcut(), QKeySequence());
|
|
|
|
QCOMPARE(c->desktopFileName(), QByteArrayLiteral("org.kde.kwin"));
|
|
|
|
}
|
|
|
|
|
2018-02-11 20:27:34 +03:00
|
|
|
TEST_FORCE_DATA(testOpacityActive)
|
|
|
|
|
|
|
|
void TestShellClientRules::testOpacityActive()
|
|
|
|
{
|
|
|
|
KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
|
|
|
|
config->group("General").writeEntry("count", 1);
|
|
|
|
|
|
|
|
auto group = config->group("1");
|
|
|
|
group.writeEntry("opacityactive", 90);
|
|
|
|
group.writeEntry("opacityinactive", 80);
|
|
|
|
QFETCH(int, ruleNumber);
|
|
|
|
group.writeEntry("opacityactiverule", ruleNumber);
|
|
|
|
group.writeEntry("opacityinactiverule", ruleNumber);
|
|
|
|
group.sync();
|
|
|
|
|
|
|
|
RuleBook::self()->setConfig(config);
|
|
|
|
workspace()->slotReconfigure();
|
|
|
|
|
|
|
|
QScopedPointer<Surface> surface(Test::createSurface());
|
|
|
|
QFETCH(Test::ShellSurfaceType, type);
|
|
|
|
QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data()));
|
|
|
|
|
|
|
|
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
|
|
|
QVERIFY(c);
|
|
|
|
QVERIFY(c->isActive());
|
|
|
|
QCOMPARE(c->opacity(), 0.9);
|
|
|
|
|
|
|
|
// open a second window
|
|
|
|
QScopedPointer<Surface> surface2(Test::createSurface());
|
|
|
|
QScopedPointer<QObject> shellSurface2(Test::createShellSurface(type, surface2.data()));
|
|
|
|
|
|
|
|
auto c2 = Test::renderAndWaitForShown(surface2.data(), QSize(100, 50), Qt::blue);
|
|
|
|
QVERIFY(c2);
|
|
|
|
QVERIFY(c2->isActive());
|
|
|
|
QVERIFY(!c->isActive());
|
|
|
|
QCOMPARE(c2->opacity(), 0.9);
|
|
|
|
QCOMPARE(c->opacity(), 0.8);
|
|
|
|
|
|
|
|
workspace()->activateClient(c);
|
|
|
|
QVERIFY(!c2->isActive());
|
|
|
|
QVERIFY(c->isActive());
|
|
|
|
QCOMPARE(c->opacity(), 0.9);
|
|
|
|
QCOMPARE(c2->opacity(), 0.8);
|
|
|
|
}
|
|
|
|
|
2018-03-12 20:06:33 +03:00
|
|
|
void TestShellClientRules::testMatchAfterNameChange()
|
|
|
|
{
|
|
|
|
KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
|
|
|
|
config->group("General").writeEntry("count", 1);
|
|
|
|
|
|
|
|
auto group = config->group("1");
|
|
|
|
group.writeEntry("above", true);
|
|
|
|
group.writeEntry("aboverule", 2);
|
|
|
|
group.writeEntry("wmclass", "org.kde.foo");
|
|
|
|
group.writeEntry("wmclasscomplete", false);
|
|
|
|
group.writeEntry("wmclassmatch", 1);
|
|
|
|
group.sync();
|
|
|
|
|
|
|
|
RuleBook::self()->setConfig(config);
|
|
|
|
workspace()->slotReconfigure();
|
|
|
|
|
|
|
|
QScopedPointer<Surface> surface(Test::createSurface());
|
|
|
|
QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellV6Surface(surface.data()));
|
|
|
|
|
|
|
|
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
|
|
|
QVERIFY(c);
|
|
|
|
QVERIFY(c->isActive());
|
|
|
|
QCOMPARE(c->keepAbove(), false);
|
|
|
|
|
|
|
|
QSignalSpy desktopFileNameSpy(c, &AbstractClient::desktopFileNameChanged);
|
|
|
|
QVERIFY(desktopFileNameSpy.isValid());
|
|
|
|
|
|
|
|
shellSurface->setAppId(QByteArrayLiteral("org.kde.foo"));
|
|
|
|
QVERIFY(desktopFileNameSpy.wait());
|
|
|
|
QCOMPARE(c->keepAbove(), true);
|
|
|
|
}
|
|
|
|
|
2017-10-07 15:09:07 +03:00
|
|
|
WAYLANDTEST_MAIN(TestShellClientRules)
|
|
|
|
#include "shell_client_rules_test.moc"
|