2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2019 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2019-08-28 08:46:30 +00:00
|
|
|
|
|
|
|
#include "kwin_wayland_test.h"
|
|
|
|
|
2020-03-04 07:55:26 +00:00
|
|
|
#include "abstract_client.h"
|
2021-08-31 07:03:05 +00:00
|
|
|
#include "abstract_output.h"
|
2019-08-28 08:46:30 +00:00
|
|
|
#include "cursor.h"
|
|
|
|
#include "platform.h"
|
|
|
|
#include "wayland_server.h"
|
|
|
|
#include "workspace.h"
|
|
|
|
|
|
|
|
#include <KWayland/Client/surface.h>
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
static const QString s_socketName = QStringLiteral("wayland_test_activation-0");
|
|
|
|
|
|
|
|
class ActivationTest : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void initTestCase();
|
|
|
|
void init();
|
|
|
|
void cleanup();
|
|
|
|
|
|
|
|
void testSwitchToWindowToLeft();
|
|
|
|
void testSwitchToWindowToRight();
|
|
|
|
void testSwitchToWindowAbove();
|
|
|
|
void testSwitchToWindowBelow();
|
|
|
|
void testSwitchToWindowMaximized();
|
|
|
|
void testSwitchToWindowFullScreen();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void stackScreensHorizontally();
|
|
|
|
void stackScreensVertically();
|
|
|
|
};
|
|
|
|
|
|
|
|
void ActivationTest::initTestCase()
|
|
|
|
{
|
|
|
|
qRegisterMetaType<AbstractClient *>();
|
|
|
|
|
2020-07-07 09:32:29 +00:00
|
|
|
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
|
|
|
|
QVERIFY(applicationStartedSpy.isValid());
|
2019-08-28 08:46:30 +00:00
|
|
|
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
|
2020-12-09 13:06:15 +00:00
|
|
|
QVERIFY(waylandServer()->init(s_socketName));
|
2019-08-28 08:46:30 +00:00
|
|
|
QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2));
|
|
|
|
|
|
|
|
kwinApp()->start();
|
2020-07-07 09:32:29 +00:00
|
|
|
QVERIFY(applicationStartedSpy.wait());
|
2021-08-31 07:03:05 +00:00
|
|
|
const auto outputs = kwinApp()->platform()->enabledOutputs();
|
|
|
|
QCOMPARE(outputs.count(), 2);
|
|
|
|
QCOMPARE(outputs[0]->geometry(), QRect(0, 0, 1280, 1024));
|
|
|
|
QCOMPARE(outputs[1]->geometry(), QRect(1280, 0, 1280, 1024));
|
2021-05-08 00:08:22 +00:00
|
|
|
Test::initWaylandWorkspace();
|
2019-08-28 08:46:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ActivationTest::init()
|
|
|
|
{
|
|
|
|
QVERIFY(Test::setupWaylandConnection());
|
|
|
|
|
2021-08-28 18:58:29 +00:00
|
|
|
workspace()->setActiveOutput(QPoint(640, 512));
|
2020-04-02 16:18:01 +00:00
|
|
|
Cursors::self()->mouse()->setPos(QPoint(640, 512));
|
2019-08-28 08:46:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ActivationTest::cleanup()
|
|
|
|
{
|
|
|
|
Test::destroyWaylandConnection();
|
|
|
|
|
|
|
|
stackScreensHorizontally();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActivationTest::testSwitchToWindowToLeft()
|
|
|
|
{
|
|
|
|
// This test verifies that "Switch to Window to the Left" shortcut works.
|
|
|
|
|
|
|
|
using namespace KWayland::Client;
|
|
|
|
|
|
|
|
// Prepare the test environment.
|
|
|
|
stackScreensHorizontally();
|
|
|
|
|
|
|
|
// Create several clients on the left screen.
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface1(Test::createSurface());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface1(Test::createXdgToplevelSurface(surface1.data()));
|
2020-03-04 07:55:26 +00:00
|
|
|
AbstractClient *client1 = Test::renderAndWaitForShown(surface1.data(), QSize(100, 50), Qt::blue);
|
2019-08-28 08:46:30 +00:00
|
|
|
QVERIFY(client1);
|
|
|
|
QVERIFY(client1->isActive());
|
|
|
|
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface2(Test::createSurface());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface2(Test::createXdgToplevelSurface(surface2.data()));
|
2020-03-04 07:55:26 +00:00
|
|
|
AbstractClient *client2 = Test::renderAndWaitForShown(surface2.data(), QSize(100, 50), Qt::blue);
|
2019-08-28 08:46:30 +00:00
|
|
|
QVERIFY(client2);
|
|
|
|
QVERIFY(client2->isActive());
|
|
|
|
|
|
|
|
client1->move(QPoint(300, 200));
|
|
|
|
client2->move(QPoint(500, 200));
|
|
|
|
|
|
|
|
// Create several clients on the right screen.
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface3(Test::createSurface());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface3(Test::createXdgToplevelSurface(surface3.data()));
|
2020-03-04 07:55:26 +00:00
|
|
|
AbstractClient *client3 = Test::renderAndWaitForShown(surface3.data(), QSize(100, 50), Qt::blue);
|
2019-08-28 08:46:30 +00:00
|
|
|
QVERIFY(client3);
|
|
|
|
QVERIFY(client3->isActive());
|
|
|
|
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface4(Test::createSurface());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface4(Test::createXdgToplevelSurface(surface4.data()));
|
2020-03-04 07:55:26 +00:00
|
|
|
AbstractClient *client4 = Test::renderAndWaitForShown(surface4.data(), QSize(100, 50), Qt::blue);
|
2019-08-28 08:46:30 +00:00
|
|
|
QVERIFY(client4);
|
|
|
|
QVERIFY(client4->isActive());
|
|
|
|
|
|
|
|
client3->move(QPoint(1380, 200));
|
|
|
|
client4->move(QPoint(1580, 200));
|
|
|
|
|
|
|
|
// Switch to window to the left.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionWest);
|
|
|
|
QVERIFY(client3->isActive());
|
|
|
|
|
|
|
|
// Switch to window to the left.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionWest);
|
|
|
|
QVERIFY(client2->isActive());
|
|
|
|
|
|
|
|
// Switch to window to the left.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionWest);
|
|
|
|
QVERIFY(client1->isActive());
|
|
|
|
|
|
|
|
// Switch to window to the left.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionWest);
|
|
|
|
QVERIFY(client4->isActive());
|
|
|
|
|
|
|
|
// Destroy all clients.
|
|
|
|
shellSurface1.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(client1));
|
|
|
|
shellSurface2.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(client2));
|
|
|
|
shellSurface3.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(client3));
|
|
|
|
shellSurface4.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(client4));
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActivationTest::testSwitchToWindowToRight()
|
|
|
|
{
|
|
|
|
// This test verifies that "Switch to Window to the Right" shortcut works.
|
|
|
|
|
|
|
|
using namespace KWayland::Client;
|
|
|
|
|
|
|
|
// Prepare the test environment.
|
|
|
|
stackScreensHorizontally();
|
|
|
|
|
|
|
|
// Create several clients on the left screen.
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface1(Test::createSurface());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface1(Test::createXdgToplevelSurface(surface1.data()));
|
2020-03-04 07:55:26 +00:00
|
|
|
AbstractClient *client1 = Test::renderAndWaitForShown(surface1.data(), QSize(100, 50), Qt::blue);
|
2019-08-28 08:46:30 +00:00
|
|
|
QVERIFY(client1);
|
|
|
|
QVERIFY(client1->isActive());
|
|
|
|
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface2(Test::createSurface());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface2(Test::createXdgToplevelSurface(surface2.data()));
|
2020-03-04 07:55:26 +00:00
|
|
|
AbstractClient *client2 = Test::renderAndWaitForShown(surface2.data(), QSize(100, 50), Qt::blue);
|
2019-08-28 08:46:30 +00:00
|
|
|
QVERIFY(client2);
|
|
|
|
QVERIFY(client2->isActive());
|
|
|
|
|
|
|
|
client1->move(QPoint(300, 200));
|
|
|
|
client2->move(QPoint(500, 200));
|
|
|
|
|
|
|
|
// Create several clients on the right screen.
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface3(Test::createSurface());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface3(Test::createXdgToplevelSurface(surface3.data()));
|
2020-03-04 07:55:26 +00:00
|
|
|
AbstractClient *client3 = Test::renderAndWaitForShown(surface3.data(), QSize(100, 50), Qt::blue);
|
2019-08-28 08:46:30 +00:00
|
|
|
QVERIFY(client3);
|
|
|
|
QVERIFY(client3->isActive());
|
|
|
|
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface4(Test::createSurface());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface4(Test::createXdgToplevelSurface(surface4.data()));
|
2020-03-04 07:55:26 +00:00
|
|
|
AbstractClient *client4 = Test::renderAndWaitForShown(surface4.data(), QSize(100, 50), Qt::blue);
|
2019-08-28 08:46:30 +00:00
|
|
|
QVERIFY(client4);
|
|
|
|
QVERIFY(client4->isActive());
|
|
|
|
|
|
|
|
client3->move(QPoint(1380, 200));
|
|
|
|
client4->move(QPoint(1580, 200));
|
|
|
|
|
|
|
|
// Switch to window to the right.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionEast);
|
|
|
|
QVERIFY(client1->isActive());
|
|
|
|
|
|
|
|
// Switch to window to the right.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionEast);
|
|
|
|
QVERIFY(client2->isActive());
|
|
|
|
|
|
|
|
// Switch to window to the right.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionEast);
|
|
|
|
QVERIFY(client3->isActive());
|
|
|
|
|
|
|
|
// Switch to window to the right.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionEast);
|
|
|
|
QVERIFY(client4->isActive());
|
|
|
|
|
|
|
|
// Destroy all clients.
|
|
|
|
shellSurface1.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(client1));
|
|
|
|
shellSurface2.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(client2));
|
|
|
|
shellSurface3.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(client3));
|
|
|
|
shellSurface4.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(client4));
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActivationTest::testSwitchToWindowAbove()
|
|
|
|
{
|
|
|
|
// This test verifies that "Switch to Window Above" shortcut works.
|
|
|
|
|
|
|
|
using namespace KWayland::Client;
|
|
|
|
|
|
|
|
// Prepare the test environment.
|
|
|
|
stackScreensVertically();
|
|
|
|
|
|
|
|
// Create several clients on the top screen.
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface1(Test::createSurface());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface1(Test::createXdgToplevelSurface(surface1.data()));
|
2020-03-04 07:55:26 +00:00
|
|
|
AbstractClient *client1 = Test::renderAndWaitForShown(surface1.data(), QSize(100, 50), Qt::blue);
|
2019-08-28 08:46:30 +00:00
|
|
|
QVERIFY(client1);
|
|
|
|
QVERIFY(client1->isActive());
|
|
|
|
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface2(Test::createSurface());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface2(Test::createXdgToplevelSurface(surface2.data()));
|
2020-03-04 07:55:26 +00:00
|
|
|
AbstractClient *client2 = Test::renderAndWaitForShown(surface2.data(), QSize(100, 50), Qt::blue);
|
2019-08-28 08:46:30 +00:00
|
|
|
QVERIFY(client2);
|
|
|
|
QVERIFY(client2->isActive());
|
|
|
|
|
|
|
|
client1->move(QPoint(200, 300));
|
|
|
|
client2->move(QPoint(200, 500));
|
|
|
|
|
|
|
|
// Create several clients on the bottom screen.
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface3(Test::createSurface());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface3(Test::createXdgToplevelSurface(surface3.data()));
|
2020-03-04 07:55:26 +00:00
|
|
|
AbstractClient *client3 = Test::renderAndWaitForShown(surface3.data(), QSize(100, 50), Qt::blue);
|
2019-08-28 08:46:30 +00:00
|
|
|
QVERIFY(client3);
|
|
|
|
QVERIFY(client3->isActive());
|
|
|
|
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface4(Test::createSurface());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface4(Test::createXdgToplevelSurface(surface4.data()));
|
2020-03-04 07:55:26 +00:00
|
|
|
AbstractClient *client4 = Test::renderAndWaitForShown(surface4.data(), QSize(100, 50), Qt::blue);
|
2019-08-28 08:46:30 +00:00
|
|
|
QVERIFY(client4);
|
|
|
|
QVERIFY(client4->isActive());
|
|
|
|
|
|
|
|
client3->move(QPoint(200, 1224));
|
|
|
|
client4->move(QPoint(200, 1424));
|
|
|
|
|
|
|
|
// Switch to window above.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionNorth);
|
|
|
|
QVERIFY(client3->isActive());
|
|
|
|
|
|
|
|
// Switch to window above.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionNorth);
|
|
|
|
QVERIFY(client2->isActive());
|
|
|
|
|
|
|
|
// Switch to window above.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionNorth);
|
|
|
|
QVERIFY(client1->isActive());
|
|
|
|
|
|
|
|
// Switch to window above.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionNorth);
|
|
|
|
QVERIFY(client4->isActive());
|
|
|
|
|
|
|
|
// Destroy all clients.
|
|
|
|
shellSurface1.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(client1));
|
|
|
|
shellSurface2.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(client2));
|
|
|
|
shellSurface3.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(client3));
|
|
|
|
shellSurface4.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(client4));
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActivationTest::testSwitchToWindowBelow()
|
|
|
|
{
|
|
|
|
// This test verifies that "Switch to Window Bottom" shortcut works.
|
|
|
|
|
|
|
|
using namespace KWayland::Client;
|
|
|
|
|
|
|
|
// Prepare the test environment.
|
|
|
|
stackScreensVertically();
|
|
|
|
|
|
|
|
// Create several clients on the top screen.
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface1(Test::createSurface());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface1(Test::createXdgToplevelSurface(surface1.data()));
|
2020-03-04 07:55:26 +00:00
|
|
|
AbstractClient *client1 = Test::renderAndWaitForShown(surface1.data(), QSize(100, 50), Qt::blue);
|
2019-08-28 08:46:30 +00:00
|
|
|
QVERIFY(client1);
|
|
|
|
QVERIFY(client1->isActive());
|
|
|
|
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface2(Test::createSurface());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface2(Test::createXdgToplevelSurface(surface2.data()));
|
2020-03-04 07:55:26 +00:00
|
|
|
AbstractClient *client2 = Test::renderAndWaitForShown(surface2.data(), QSize(100, 50), Qt::blue);
|
2019-08-28 08:46:30 +00:00
|
|
|
QVERIFY(client2);
|
|
|
|
QVERIFY(client2->isActive());
|
|
|
|
|
|
|
|
client1->move(QPoint(200, 300));
|
|
|
|
client2->move(QPoint(200, 500));
|
|
|
|
|
|
|
|
// Create several clients on the bottom screen.
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface3(Test::createSurface());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface3(Test::createXdgToplevelSurface(surface3.data()));
|
2020-03-04 07:55:26 +00:00
|
|
|
AbstractClient *client3 = Test::renderAndWaitForShown(surface3.data(), QSize(100, 50), Qt::blue);
|
2019-08-28 08:46:30 +00:00
|
|
|
QVERIFY(client3);
|
|
|
|
QVERIFY(client3->isActive());
|
|
|
|
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface4(Test::createSurface());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface4(Test::createXdgToplevelSurface(surface4.data()));
|
2020-03-04 07:55:26 +00:00
|
|
|
AbstractClient *client4 = Test::renderAndWaitForShown(surface4.data(), QSize(100, 50), Qt::blue);
|
2019-08-28 08:46:30 +00:00
|
|
|
QVERIFY(client4);
|
|
|
|
QVERIFY(client4->isActive());
|
|
|
|
|
|
|
|
client3->move(QPoint(200, 1224));
|
|
|
|
client4->move(QPoint(200, 1424));
|
|
|
|
|
|
|
|
// Switch to window below.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionSouth);
|
|
|
|
QVERIFY(client1->isActive());
|
|
|
|
|
|
|
|
// Switch to window below.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionSouth);
|
|
|
|
QVERIFY(client2->isActive());
|
|
|
|
|
|
|
|
// Switch to window below.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionSouth);
|
|
|
|
QVERIFY(client3->isActive());
|
|
|
|
|
|
|
|
// Switch to window below.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionSouth);
|
|
|
|
QVERIFY(client4->isActive());
|
|
|
|
|
|
|
|
// Destroy all clients.
|
|
|
|
shellSurface1.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(client1));
|
|
|
|
shellSurface2.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(client2));
|
|
|
|
shellSurface3.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(client3));
|
|
|
|
shellSurface4.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(client4));
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActivationTest::testSwitchToWindowMaximized()
|
|
|
|
{
|
|
|
|
// This test verifies that we switch to the top-most maximized client, i.e.
|
|
|
|
// the one that user sees at the moment. See bug 411356.
|
|
|
|
|
|
|
|
using namespace KWayland::Client;
|
|
|
|
|
|
|
|
// Prepare the test environment.
|
|
|
|
stackScreensHorizontally();
|
|
|
|
|
|
|
|
// Create several maximized clients on the left screen.
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface1(Test::createSurface());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface1(Test::createXdgToplevelSurface(surface1.data()));
|
2021-05-12 17:44:18 +00:00
|
|
|
QSignalSpy toplevelConfigureRequestedSpy1(shellSurface1.data(), &Test::XdgToplevel::configureRequested);
|
|
|
|
QSignalSpy surfaceConfigureRequestedSpy1(shellSurface1->xdgSurface(), &Test::XdgSurface::configureRequested);
|
2020-03-04 07:55:26 +00:00
|
|
|
AbstractClient *client1 = Test::renderAndWaitForShown(surface1.data(), QSize(100, 50), Qt::blue);
|
2019-08-28 08:46:30 +00:00
|
|
|
QVERIFY(client1);
|
|
|
|
QVERIFY(client1->isActive());
|
2021-05-12 17:44:18 +00:00
|
|
|
QVERIFY(surfaceConfigureRequestedSpy1.wait()); // Wait for the configure event with the activated state.
|
2019-08-28 08:46:30 +00:00
|
|
|
workspace()->slotWindowMaximize();
|
2021-05-11 05:26:51 +00:00
|
|
|
QVERIFY(surfaceConfigureRequestedSpy1.wait());
|
2020-03-04 07:55:26 +00:00
|
|
|
QSignalSpy frameGeometryChangedSpy1(client1, &AbstractClient::frameGeometryChanged);
|
2020-02-05 09:28:50 +00:00
|
|
|
QVERIFY(frameGeometryChangedSpy1.isValid());
|
2021-05-11 05:26:51 +00:00
|
|
|
shellSurface1->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy1.last().at(0).value<quint32>());
|
|
|
|
Test::render(surface1.data(), toplevelConfigureRequestedSpy1.last().at(0).toSize(), Qt::red);
|
2020-02-05 09:28:50 +00:00
|
|
|
QVERIFY(frameGeometryChangedSpy1.wait());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface2(Test::createSurface());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface2(Test::createXdgToplevelSurface(surface2.data()));
|
2021-05-12 17:44:18 +00:00
|
|
|
QSignalSpy toplevelConfigureRequestedSpy2(shellSurface2.data(), &Test::XdgToplevel::configureRequested);
|
|
|
|
QSignalSpy surfaceConfigureRequestedSpy2(shellSurface2->xdgSurface(), &Test::XdgSurface::configureRequested);
|
2020-03-04 07:55:26 +00:00
|
|
|
AbstractClient *client2 = Test::renderAndWaitForShown(surface2.data(), QSize(100, 50), Qt::blue);
|
2019-08-28 08:46:30 +00:00
|
|
|
QVERIFY(client2);
|
|
|
|
QVERIFY(client2->isActive());
|
2021-05-12 17:44:18 +00:00
|
|
|
QVERIFY(surfaceConfigureRequestedSpy2.wait()); // Wait for the configure event with the activated state.
|
2019-08-28 08:46:30 +00:00
|
|
|
workspace()->slotWindowMaximize();
|
2021-05-11 05:26:51 +00:00
|
|
|
QVERIFY(surfaceConfigureRequestedSpy2.wait());
|
2020-03-04 07:55:26 +00:00
|
|
|
QSignalSpy frameGeometryChangedSpy2(client2, &AbstractClient::frameGeometryChanged);
|
2020-02-05 09:28:50 +00:00
|
|
|
QVERIFY(frameGeometryChangedSpy2.isValid());
|
2021-05-11 05:26:51 +00:00
|
|
|
shellSurface2->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy2.last().at(0).value<quint32>());
|
|
|
|
Test::render(surface2.data(), toplevelConfigureRequestedSpy2.last().at(0).toSize(), Qt::red);
|
2020-02-05 09:28:50 +00:00
|
|
|
QVERIFY(frameGeometryChangedSpy2.wait());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
Drop some custom list typedefs
Summary:
Qt has its own thing where a type might also have corresponding list
alias, e.g. QObject and QObjectList, QWidget and QWidgetList. I don't
know why Qt does that, maybe for some historical reasons, but what
matters is that we copy this pattern here in KWin. While this pattern
might be useful with some long list types, for example
QList<QWeakPointer<TabBoxClient>> TabBoxClientList
in general, it causes more harm than good. For example, we've got two
new client types, do we need corresponding list typedefs for them? If
no, why do we have ClientList and so on?
Another problem with these typedefs is that you need to include utils.h
header in order to use them. A better way to handle such things is to
just forward declare a client class (if that's possible) and use it
directly with QList or QVector. This way translation units don't get
"bloated" with utils.h stuff for no apparent reason.
So, in order to make code more consistent and easier to follow, this
change drops some of our custom typedefs. Namely ConstClientList,
ClientList, DeletedList, UnmanagedList, ToplevelList, and GroupList.
Test Plan: Compiles.
Reviewers: #kwin
Subscribers: kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D24950
2019-10-16 09:11:04 +00:00
|
|
|
const QList<Toplevel *> stackingOrder = workspace()->stackingOrder();
|
2019-08-28 08:46:30 +00:00
|
|
|
QVERIFY(stackingOrder.indexOf(client1) < stackingOrder.indexOf(client2));
|
|
|
|
QCOMPARE(client1->maximizeMode(), MaximizeFull);
|
|
|
|
QCOMPARE(client2->maximizeMode(), MaximizeFull);
|
|
|
|
|
|
|
|
// Create several clients on the right screen.
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface3(Test::createSurface());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface3(Test::createXdgToplevelSurface(surface3.data()));
|
2020-03-04 07:55:26 +00:00
|
|
|
AbstractClient *client3 = Test::renderAndWaitForShown(surface3.data(), QSize(100, 50), Qt::blue);
|
2019-08-28 08:46:30 +00:00
|
|
|
QVERIFY(client3);
|
|
|
|
QVERIFY(client3->isActive());
|
|
|
|
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface4(Test::createSurface());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface4(Test::createXdgToplevelSurface(surface4.data()));
|
2020-03-04 07:55:26 +00:00
|
|
|
AbstractClient *client4 = Test::renderAndWaitForShown(surface4.data(), QSize(100, 50), Qt::blue);
|
2019-08-28 08:46:30 +00:00
|
|
|
QVERIFY(client4);
|
|
|
|
QVERIFY(client4->isActive());
|
|
|
|
|
|
|
|
client3->move(QPoint(1380, 200));
|
|
|
|
client4->move(QPoint(1580, 200));
|
|
|
|
|
|
|
|
// Switch to window to the left.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionWest);
|
|
|
|
QVERIFY(client3->isActive());
|
|
|
|
|
|
|
|
// Switch to window to the left.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionWest);
|
|
|
|
QVERIFY(client2->isActive());
|
|
|
|
|
|
|
|
// Switch to window to the left.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionWest);
|
|
|
|
QVERIFY(client4->isActive());
|
|
|
|
|
|
|
|
// Destroy all clients.
|
|
|
|
shellSurface1.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(client1));
|
|
|
|
shellSurface2.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(client2));
|
|
|
|
shellSurface3.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(client3));
|
|
|
|
shellSurface4.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(client4));
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActivationTest::testSwitchToWindowFullScreen()
|
|
|
|
{
|
|
|
|
// This test verifies that we switch to the top-most fullscreen client, i.e.
|
|
|
|
// the one that user sees at the moment. See bug 411356.
|
|
|
|
|
|
|
|
using namespace KWayland::Client;
|
|
|
|
|
|
|
|
// Prepare the test environment.
|
|
|
|
stackScreensVertically();
|
|
|
|
|
|
|
|
// Create several maximized clients on the top screen.
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface1(Test::createSurface());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface1(Test::createXdgToplevelSurface(surface1.data()));
|
2021-05-12 16:21:38 +00:00
|
|
|
QSignalSpy toplevelConfigureRequestedSpy1(shellSurface1.data(), &Test::XdgToplevel::configureRequested);
|
|
|
|
QSignalSpy surfaceConfigureRequestedSpy1(shellSurface1->xdgSurface(), &Test::XdgSurface::configureRequested);
|
2020-03-04 07:55:26 +00:00
|
|
|
AbstractClient *client1 = Test::renderAndWaitForShown(surface1.data(), QSize(100, 50), Qt::blue);
|
2019-08-28 08:46:30 +00:00
|
|
|
QVERIFY(client1);
|
|
|
|
QVERIFY(client1->isActive());
|
2021-05-12 16:21:38 +00:00
|
|
|
QVERIFY(surfaceConfigureRequestedSpy1.wait()); // Wait for the configure event with the activated state.
|
2019-08-28 08:46:30 +00:00
|
|
|
workspace()->slotWindowFullScreen();
|
2021-05-11 05:26:51 +00:00
|
|
|
QVERIFY(surfaceConfigureRequestedSpy1.wait());
|
2020-03-04 07:55:26 +00:00
|
|
|
QSignalSpy frameGeometryChangedSpy1(client1, &AbstractClient::frameGeometryChanged);
|
2020-02-05 09:28:50 +00:00
|
|
|
QVERIFY(frameGeometryChangedSpy1.isValid());
|
2021-05-11 05:26:51 +00:00
|
|
|
shellSurface1->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy1.last().at(0).value<quint32>());
|
|
|
|
Test::render(surface1.data(), toplevelConfigureRequestedSpy1.last().at(0).toSize(), Qt::red);
|
2020-02-05 09:28:50 +00:00
|
|
|
QVERIFY(frameGeometryChangedSpy1.wait());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface2(Test::createSurface());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface2(Test::createXdgToplevelSurface(surface2.data()));
|
2021-05-12 16:21:38 +00:00
|
|
|
QSignalSpy toplevelConfigureRequestedSpy2(shellSurface2.data(), &Test::XdgToplevel::configureRequested);
|
|
|
|
QSignalSpy surfaceConfigureRequestedSpy2(shellSurface2->xdgSurface(), &Test::XdgSurface::configureRequested);
|
2020-03-04 07:55:26 +00:00
|
|
|
AbstractClient *client2 = Test::renderAndWaitForShown(surface2.data(), QSize(100, 50), Qt::blue);
|
2019-08-28 08:46:30 +00:00
|
|
|
QVERIFY(client2);
|
|
|
|
QVERIFY(client2->isActive());
|
2021-05-12 16:21:38 +00:00
|
|
|
QVERIFY(surfaceConfigureRequestedSpy2.wait()); // Wait for the configure event with the activated state.
|
2019-08-28 08:46:30 +00:00
|
|
|
workspace()->slotWindowFullScreen();
|
2021-05-11 05:26:51 +00:00
|
|
|
QVERIFY(surfaceConfigureRequestedSpy2.wait());
|
2020-03-04 07:55:26 +00:00
|
|
|
QSignalSpy frameGeometryChangedSpy2(client2, &AbstractClient::frameGeometryChanged);
|
2020-02-05 09:28:50 +00:00
|
|
|
QVERIFY(frameGeometryChangedSpy2.isValid());
|
2021-05-11 05:26:51 +00:00
|
|
|
shellSurface2->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy2.last().at(0).value<quint32>());
|
|
|
|
Test::render(surface2.data(), toplevelConfigureRequestedSpy2.last().at(0).toSize(), Qt::red);
|
2020-02-05 09:28:50 +00:00
|
|
|
QVERIFY(frameGeometryChangedSpy2.wait());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
Drop some custom list typedefs
Summary:
Qt has its own thing where a type might also have corresponding list
alias, e.g. QObject and QObjectList, QWidget and QWidgetList. I don't
know why Qt does that, maybe for some historical reasons, but what
matters is that we copy this pattern here in KWin. While this pattern
might be useful with some long list types, for example
QList<QWeakPointer<TabBoxClient>> TabBoxClientList
in general, it causes more harm than good. For example, we've got two
new client types, do we need corresponding list typedefs for them? If
no, why do we have ClientList and so on?
Another problem with these typedefs is that you need to include utils.h
header in order to use them. A better way to handle such things is to
just forward declare a client class (if that's possible) and use it
directly with QList or QVector. This way translation units don't get
"bloated" with utils.h stuff for no apparent reason.
So, in order to make code more consistent and easier to follow, this
change drops some of our custom typedefs. Namely ConstClientList,
ClientList, DeletedList, UnmanagedList, ToplevelList, and GroupList.
Test Plan: Compiles.
Reviewers: #kwin
Subscribers: kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D24950
2019-10-16 09:11:04 +00:00
|
|
|
const QList<Toplevel *> stackingOrder = workspace()->stackingOrder();
|
2019-08-28 08:46:30 +00:00
|
|
|
QVERIFY(stackingOrder.indexOf(client1) < stackingOrder.indexOf(client2));
|
|
|
|
QVERIFY(client1->isFullScreen());
|
|
|
|
QVERIFY(client2->isFullScreen());
|
|
|
|
|
|
|
|
// Create several clients on the bottom screen.
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface3(Test::createSurface());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface3(Test::createXdgToplevelSurface(surface3.data()));
|
2020-03-04 07:55:26 +00:00
|
|
|
AbstractClient *client3 = Test::renderAndWaitForShown(surface3.data(), QSize(100, 50), Qt::blue);
|
2019-08-28 08:46:30 +00:00
|
|
|
QVERIFY(client3);
|
|
|
|
QVERIFY(client3->isActive());
|
|
|
|
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface4(Test::createSurface());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface4(Test::createXdgToplevelSurface(surface4.data()));
|
2020-03-04 07:55:26 +00:00
|
|
|
AbstractClient *client4 = Test::renderAndWaitForShown(surface4.data(), QSize(100, 50), Qt::blue);
|
2019-08-28 08:46:30 +00:00
|
|
|
QVERIFY(client4);
|
|
|
|
QVERIFY(client4->isActive());
|
|
|
|
|
|
|
|
client3->move(QPoint(200, 1224));
|
|
|
|
client4->move(QPoint(200, 1424));
|
|
|
|
|
|
|
|
// Switch to window above.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionNorth);
|
|
|
|
QVERIFY(client3->isActive());
|
|
|
|
|
|
|
|
// Switch to window above.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionNorth);
|
|
|
|
QVERIFY(client2->isActive());
|
|
|
|
|
|
|
|
// Switch to window above.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionNorth);
|
|
|
|
QVERIFY(client4->isActive());
|
|
|
|
|
|
|
|
// Destroy all clients.
|
|
|
|
shellSurface1.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(client1));
|
|
|
|
shellSurface2.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(client2));
|
|
|
|
shellSurface3.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(client3));
|
|
|
|
shellSurface4.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(client4));
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActivationTest::stackScreensHorizontally()
|
|
|
|
{
|
|
|
|
// Process pending wl_output bind requests before destroying all outputs.
|
|
|
|
QTest::qWait(1);
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
const QVector<QRect> screenGeometries{
|
2019-08-28 08:46:30 +00:00
|
|
|
QRect(0, 0, 1280, 1024),
|
|
|
|
QRect(1280, 0, 1280, 1024),
|
|
|
|
};
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
const QVector<int> screenScales{
|
2019-08-28 08:46:30 +00:00
|
|
|
1,
|
|
|
|
1,
|
|
|
|
};
|
|
|
|
|
|
|
|
QMetaObject::invokeMethod(kwinApp()->platform(),
|
2022-03-23 10:13:38 +00:00
|
|
|
"setVirtualOutputs",
|
|
|
|
Qt::DirectConnection,
|
|
|
|
Q_ARG(int, screenGeometries.count()),
|
|
|
|
Q_ARG(QVector<QRect>, screenGeometries),
|
|
|
|
Q_ARG(QVector<int>, screenScales));
|
2019-08-28 08:46:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ActivationTest::stackScreensVertically()
|
|
|
|
{
|
|
|
|
// Process pending wl_output bind requests before destroying all outputs.
|
|
|
|
QTest::qWait(1);
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
const QVector<QRect> screenGeometries{
|
2019-08-28 08:46:30 +00:00
|
|
|
QRect(0, 0, 1280, 1024),
|
|
|
|
QRect(0, 1024, 1280, 1024),
|
|
|
|
};
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
const QVector<int> screenScales{
|
2019-08-28 08:46:30 +00:00
|
|
|
1,
|
|
|
|
1,
|
|
|
|
};
|
|
|
|
|
|
|
|
QMetaObject::invokeMethod(kwinApp()->platform(),
|
2022-03-23 10:13:38 +00:00
|
|
|
"setVirtualOutputs",
|
|
|
|
Qt::DirectConnection,
|
|
|
|
Q_ARG(int, screenGeometries.count()),
|
|
|
|
Q_ARG(QVector<QRect>, screenGeometries),
|
|
|
|
Q_ARG(QVector<int>, screenScales));
|
2019-08-28 08:46:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
WAYLANDTEST_MAIN(KWin::ActivationTest)
|
|
|
|
#include "activation_test.moc"
|