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"
|
|
|
|
|
2022-08-29 07:55:49 +00:00
|
|
|
#include "core/output.h"
|
2023-02-09 13:07:56 +00:00
|
|
|
#include "pointer_input.h"
|
2019-08-28 08:46:30 +00:00
|
|
|
#include "wayland_server.h"
|
2022-04-22 17:39:12 +00:00
|
|
|
#include "window.h"
|
2019-08-28 08:46:30 +00:00
|
|
|
#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()
|
|
|
|
{
|
2022-04-22 17:39:12 +00:00
|
|
|
qRegisterMetaType<Window *>();
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2020-07-07 09:32:29 +00:00
|
|
|
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
|
2020-12-09 13:06:15 +00:00
|
|
|
QVERIFY(waylandServer()->init(s_socketName));
|
2023-05-08 10:16:00 +00:00
|
|
|
Test::setOutputConfig({
|
|
|
|
QRect(0, 0, 1280, 1024),
|
|
|
|
QRect(1280, 0, 1280, 1024),
|
|
|
|
});
|
2019-08-28 08:46:30 +00:00
|
|
|
|
|
|
|
kwinApp()->start();
|
2020-07-07 09:32:29 +00:00
|
|
|
QVERIFY(applicationStartedSpy.wait());
|
2022-07-11 10:41:15 +00:00
|
|
|
const auto outputs = workspace()->outputs();
|
2021-08-31 07:03:05 +00:00
|
|
|
QCOMPARE(outputs.count(), 2);
|
|
|
|
QCOMPARE(outputs[0]->geometry(), QRect(0, 0, 1280, 1024));
|
|
|
|
QCOMPARE(outputs[1]->geometry(), QRect(1280, 0, 1280, 1024));
|
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));
|
2023-02-09 13:07:56 +00:00
|
|
|
input()->pointer()->warp(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.
|
|
|
|
|
|
|
|
// Prepare the test environment.
|
|
|
|
stackScreensHorizontally();
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Create several windows on the left screen.
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface1(Test::createSurface());
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface1(Test::createXdgToplevelSurface(surface1.get()));
|
|
|
|
Window *window1 = Test::renderAndWaitForShown(surface1.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window1);
|
|
|
|
QVERIFY(window1->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface2(Test::createSurface());
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface2(Test::createXdgToplevelSurface(surface2.get()));
|
|
|
|
Window *window2 = Test::renderAndWaitForShown(surface2.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window2);
|
|
|
|
QVERIFY(window2->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
window1->move(QPoint(300, 200));
|
|
|
|
window2->move(QPoint(500, 200));
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Create several windows on the right screen.
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface3(Test::createSurface());
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface3(Test::createXdgToplevelSurface(surface3.get()));
|
|
|
|
Window *window3 = Test::renderAndWaitForShown(surface3.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window3);
|
|
|
|
QVERIFY(window3->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface4(Test::createSurface());
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface4(Test::createXdgToplevelSurface(surface4.get()));
|
|
|
|
Window *window4 = Test::renderAndWaitForShown(surface4.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window4);
|
|
|
|
QVERIFY(window4->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
window3->move(QPoint(1380, 200));
|
|
|
|
window4->move(QPoint(1580, 200));
|
2019-08-28 08:46:30 +00:00
|
|
|
|
|
|
|
// Switch to window to the left.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionWest);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window3->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
|
|
|
// Switch to window to the left.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionWest);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window2->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
|
|
|
// Switch to window to the left.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionWest);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window1->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
|
|
|
// Switch to window to the left.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionWest);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window4->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Destroy all windows.
|
2019-08-28 08:46:30 +00:00
|
|
|
shellSurface1.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
QVERIFY(Test::waitForWindowClosed(window1));
|
2019-08-28 08:46:30 +00:00
|
|
|
shellSurface2.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
QVERIFY(Test::waitForWindowClosed(window2));
|
2019-08-28 08:46:30 +00:00
|
|
|
shellSurface3.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
QVERIFY(Test::waitForWindowClosed(window3));
|
2019-08-28 08:46:30 +00:00
|
|
|
shellSurface4.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
QVERIFY(Test::waitForWindowClosed(window4));
|
2019-08-28 08:46:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ActivationTest::testSwitchToWindowToRight()
|
|
|
|
{
|
|
|
|
// This test verifies that "Switch to Window to the Right" shortcut works.
|
|
|
|
|
|
|
|
// Prepare the test environment.
|
|
|
|
stackScreensHorizontally();
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Create several windows on the left screen.
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface1(Test::createSurface());
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface1(Test::createXdgToplevelSurface(surface1.get()));
|
|
|
|
Window *window1 = Test::renderAndWaitForShown(surface1.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window1);
|
|
|
|
QVERIFY(window1->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface2(Test::createSurface());
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface2(Test::createXdgToplevelSurface(surface2.get()));
|
|
|
|
Window *window2 = Test::renderAndWaitForShown(surface2.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window2);
|
|
|
|
QVERIFY(window2->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
window1->move(QPoint(300, 200));
|
|
|
|
window2->move(QPoint(500, 200));
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Create several windows on the right screen.
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface3(Test::createSurface());
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface3(Test::createXdgToplevelSurface(surface3.get()));
|
|
|
|
Window *window3 = Test::renderAndWaitForShown(surface3.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window3);
|
|
|
|
QVERIFY(window3->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface4(Test::createSurface());
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface4(Test::createXdgToplevelSurface(surface4.get()));
|
|
|
|
Window *window4 = Test::renderAndWaitForShown(surface4.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window4);
|
|
|
|
QVERIFY(window4->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
window3->move(QPoint(1380, 200));
|
|
|
|
window4->move(QPoint(1580, 200));
|
2019-08-28 08:46:30 +00:00
|
|
|
|
|
|
|
// Switch to window to the right.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionEast);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window1->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
|
|
|
// Switch to window to the right.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionEast);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window2->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
|
|
|
// Switch to window to the right.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionEast);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window3->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
|
|
|
// Switch to window to the right.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionEast);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window4->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Destroy all windows.
|
2019-08-28 08:46:30 +00:00
|
|
|
shellSurface1.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
QVERIFY(Test::waitForWindowClosed(window1));
|
2019-08-28 08:46:30 +00:00
|
|
|
shellSurface2.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
QVERIFY(Test::waitForWindowClosed(window2));
|
2019-08-28 08:46:30 +00:00
|
|
|
shellSurface3.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
QVERIFY(Test::waitForWindowClosed(window3));
|
2019-08-28 08:46:30 +00:00
|
|
|
shellSurface4.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
QVERIFY(Test::waitForWindowClosed(window4));
|
2019-08-28 08:46:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ActivationTest::testSwitchToWindowAbove()
|
|
|
|
{
|
|
|
|
// This test verifies that "Switch to Window Above" shortcut works.
|
|
|
|
|
|
|
|
// Prepare the test environment.
|
|
|
|
stackScreensVertically();
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Create several windows on the top screen.
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface1(Test::createSurface());
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface1(Test::createXdgToplevelSurface(surface1.get()));
|
|
|
|
Window *window1 = Test::renderAndWaitForShown(surface1.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window1);
|
|
|
|
QVERIFY(window1->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface2(Test::createSurface());
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface2(Test::createXdgToplevelSurface(surface2.get()));
|
|
|
|
Window *window2 = Test::renderAndWaitForShown(surface2.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window2);
|
|
|
|
QVERIFY(window2->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
window1->move(QPoint(200, 300));
|
|
|
|
window2->move(QPoint(200, 500));
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Create several windows on the bottom screen.
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface3(Test::createSurface());
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface3(Test::createXdgToplevelSurface(surface3.get()));
|
|
|
|
Window *window3 = Test::renderAndWaitForShown(surface3.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window3);
|
|
|
|
QVERIFY(window3->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface4(Test::createSurface());
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface4(Test::createXdgToplevelSurface(surface4.get()));
|
|
|
|
Window *window4 = Test::renderAndWaitForShown(surface4.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window4);
|
|
|
|
QVERIFY(window4->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
window3->move(QPoint(200, 1224));
|
|
|
|
window4->move(QPoint(200, 1424));
|
2019-08-28 08:46:30 +00:00
|
|
|
|
|
|
|
// Switch to window above.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionNorth);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window3->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
|
|
|
// Switch to window above.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionNorth);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window2->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
|
|
|
// Switch to window above.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionNorth);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window1->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
|
|
|
// Switch to window above.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionNorth);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window4->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Destroy all windows.
|
2019-08-28 08:46:30 +00:00
|
|
|
shellSurface1.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
QVERIFY(Test::waitForWindowClosed(window1));
|
2019-08-28 08:46:30 +00:00
|
|
|
shellSurface2.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
QVERIFY(Test::waitForWindowClosed(window2));
|
2019-08-28 08:46:30 +00:00
|
|
|
shellSurface3.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
QVERIFY(Test::waitForWindowClosed(window3));
|
2019-08-28 08:46:30 +00:00
|
|
|
shellSurface4.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
QVERIFY(Test::waitForWindowClosed(window4));
|
2019-08-28 08:46:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ActivationTest::testSwitchToWindowBelow()
|
|
|
|
{
|
|
|
|
// This test verifies that "Switch to Window Bottom" shortcut works.
|
|
|
|
|
|
|
|
// Prepare the test environment.
|
|
|
|
stackScreensVertically();
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Create several windows on the top screen.
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface1(Test::createSurface());
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface1(Test::createXdgToplevelSurface(surface1.get()));
|
|
|
|
Window *window1 = Test::renderAndWaitForShown(surface1.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window1);
|
|
|
|
QVERIFY(window1->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface2(Test::createSurface());
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface2(Test::createXdgToplevelSurface(surface2.get()));
|
|
|
|
Window *window2 = Test::renderAndWaitForShown(surface2.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window2);
|
|
|
|
QVERIFY(window2->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
window1->move(QPoint(200, 300));
|
|
|
|
window2->move(QPoint(200, 500));
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Create several windows on the bottom screen.
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface3(Test::createSurface());
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface3(Test::createXdgToplevelSurface(surface3.get()));
|
|
|
|
Window *window3 = Test::renderAndWaitForShown(surface3.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window3);
|
|
|
|
QVERIFY(window3->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface4(Test::createSurface());
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface4(Test::createXdgToplevelSurface(surface4.get()));
|
|
|
|
Window *window4 = Test::renderAndWaitForShown(surface4.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window4);
|
|
|
|
QVERIFY(window4->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
window3->move(QPoint(200, 1224));
|
|
|
|
window4->move(QPoint(200, 1424));
|
2019-08-28 08:46:30 +00:00
|
|
|
|
|
|
|
// Switch to window below.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionSouth);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window1->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
|
|
|
// Switch to window below.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionSouth);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window2->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
|
|
|
// Switch to window below.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionSouth);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window3->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
|
|
|
// Switch to window below.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionSouth);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window4->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Destroy all windows.
|
2019-08-28 08:46:30 +00:00
|
|
|
shellSurface1.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
QVERIFY(Test::waitForWindowClosed(window1));
|
2019-08-28 08:46:30 +00:00
|
|
|
shellSurface2.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
QVERIFY(Test::waitForWindowClosed(window2));
|
2019-08-28 08:46:30 +00:00
|
|
|
shellSurface3.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
QVERIFY(Test::waitForWindowClosed(window3));
|
2019-08-28 08:46:30 +00:00
|
|
|
shellSurface4.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
QVERIFY(Test::waitForWindowClosed(window4));
|
2019-08-28 08:46:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ActivationTest::testSwitchToWindowMaximized()
|
|
|
|
{
|
2022-04-23 19:51:16 +00:00
|
|
|
// This test verifies that we switch to the top-most maximized window, i.e.
|
2019-08-28 08:46:30 +00:00
|
|
|
// the one that user sees at the moment. See bug 411356.
|
|
|
|
|
|
|
|
// Prepare the test environment.
|
|
|
|
stackScreensHorizontally();
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Create several maximized windows on the left screen.
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface1(Test::createSurface());
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface1(Test::createXdgToplevelSurface(surface1.get()));
|
|
|
|
QSignalSpy toplevelConfigureRequestedSpy1(shellSurface1.get(), &Test::XdgToplevel::configureRequested);
|
2021-05-12 17:44:18 +00:00
|
|
|
QSignalSpy surfaceConfigureRequestedSpy1(shellSurface1->xdgSurface(), &Test::XdgSurface::configureRequested);
|
2022-08-01 21:29:02 +00:00
|
|
|
Window *window1 = Test::renderAndWaitForShown(surface1.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window1);
|
|
|
|
QVERIFY(window1->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());
|
2022-04-23 19:51:16 +00:00
|
|
|
QSignalSpy frameGeometryChangedSpy1(window1, &Window::frameGeometryChanged);
|
2021-05-11 05:26:51 +00:00
|
|
|
shellSurface1->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy1.last().at(0).value<quint32>());
|
2022-08-01 21:29:02 +00:00
|
|
|
Test::render(surface1.get(), 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
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface2(Test::createSurface());
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface2(Test::createXdgToplevelSurface(surface2.get()));
|
|
|
|
QSignalSpy toplevelConfigureRequestedSpy2(shellSurface2.get(), &Test::XdgToplevel::configureRequested);
|
2021-05-12 17:44:18 +00:00
|
|
|
QSignalSpy surfaceConfigureRequestedSpy2(shellSurface2->xdgSurface(), &Test::XdgSurface::configureRequested);
|
2022-08-01 21:29:02 +00:00
|
|
|
Window *window2 = Test::renderAndWaitForShown(surface2.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window2);
|
|
|
|
QVERIFY(window2->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());
|
2022-04-23 19:51:16 +00:00
|
|
|
QSignalSpy frameGeometryChangedSpy2(window2, &Window::frameGeometryChanged);
|
2021-05-11 05:26:51 +00:00
|
|
|
shellSurface2->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy2.last().at(0).value<quint32>());
|
2022-08-01 21:29:02 +00:00
|
|
|
Test::render(surface2.get(), 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
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
const QList<Window *> stackingOrder = workspace()->stackingOrder();
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(stackingOrder.indexOf(window1) < stackingOrder.indexOf(window2));
|
|
|
|
QCOMPARE(window1->maximizeMode(), MaximizeFull);
|
|
|
|
QCOMPARE(window2->maximizeMode(), MaximizeFull);
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Create several windows on the right screen.
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface3(Test::createSurface());
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface3(Test::createXdgToplevelSurface(surface3.get()));
|
|
|
|
Window *window3 = Test::renderAndWaitForShown(surface3.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window3);
|
|
|
|
QVERIFY(window3->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface4(Test::createSurface());
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface4(Test::createXdgToplevelSurface(surface4.get()));
|
|
|
|
Window *window4 = Test::renderAndWaitForShown(surface4.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window4);
|
|
|
|
QVERIFY(window4->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
window3->move(QPoint(1380, 200));
|
|
|
|
window4->move(QPoint(1580, 200));
|
2019-08-28 08:46:30 +00:00
|
|
|
|
|
|
|
// Switch to window to the left.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionWest);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window3->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
|
|
|
// Switch to window to the left.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionWest);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window2->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
|
|
|
// Switch to window to the left.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionWest);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window4->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Destroy all windows.
|
2019-08-28 08:46:30 +00:00
|
|
|
shellSurface1.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
QVERIFY(Test::waitForWindowClosed(window1));
|
2019-08-28 08:46:30 +00:00
|
|
|
shellSurface2.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
QVERIFY(Test::waitForWindowClosed(window2));
|
2019-08-28 08:46:30 +00:00
|
|
|
shellSurface3.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
QVERIFY(Test::waitForWindowClosed(window3));
|
2019-08-28 08:46:30 +00:00
|
|
|
shellSurface4.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
QVERIFY(Test::waitForWindowClosed(window4));
|
2019-08-28 08:46:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ActivationTest::testSwitchToWindowFullScreen()
|
|
|
|
{
|
2022-04-23 19:51:16 +00:00
|
|
|
// This test verifies that we switch to the top-most fullscreen window, i.e.
|
2019-08-28 08:46:30 +00:00
|
|
|
// the one that user sees at the moment. See bug 411356.
|
|
|
|
|
|
|
|
// Prepare the test environment.
|
|
|
|
stackScreensVertically();
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Create several maximized windows on the top screen.
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface1(Test::createSurface());
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface1(Test::createXdgToplevelSurface(surface1.get()));
|
|
|
|
QSignalSpy toplevelConfigureRequestedSpy1(shellSurface1.get(), &Test::XdgToplevel::configureRequested);
|
2021-05-12 16:21:38 +00:00
|
|
|
QSignalSpy surfaceConfigureRequestedSpy1(shellSurface1->xdgSurface(), &Test::XdgSurface::configureRequested);
|
2022-08-01 21:29:02 +00:00
|
|
|
Window *window1 = Test::renderAndWaitForShown(surface1.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window1);
|
|
|
|
QVERIFY(window1->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());
|
2022-04-23 19:51:16 +00:00
|
|
|
QSignalSpy frameGeometryChangedSpy1(window1, &Window::frameGeometryChanged);
|
2021-05-11 05:26:51 +00:00
|
|
|
shellSurface1->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy1.last().at(0).value<quint32>());
|
2022-08-01 21:29:02 +00:00
|
|
|
Test::render(surface1.get(), 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
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface2(Test::createSurface());
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface2(Test::createXdgToplevelSurface(surface2.get()));
|
|
|
|
QSignalSpy toplevelConfigureRequestedSpy2(shellSurface2.get(), &Test::XdgToplevel::configureRequested);
|
2021-05-12 16:21:38 +00:00
|
|
|
QSignalSpy surfaceConfigureRequestedSpy2(shellSurface2->xdgSurface(), &Test::XdgSurface::configureRequested);
|
2022-08-01 21:29:02 +00:00
|
|
|
Window *window2 = Test::renderAndWaitForShown(surface2.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window2);
|
|
|
|
QVERIFY(window2->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());
|
2022-04-23 19:51:16 +00:00
|
|
|
QSignalSpy frameGeometryChangedSpy2(window2, &Window::frameGeometryChanged);
|
2021-05-11 05:26:51 +00:00
|
|
|
shellSurface2->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy2.last().at(0).value<quint32>());
|
2022-08-01 21:29:02 +00:00
|
|
|
Test::render(surface2.get(), 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
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
const QList<Window *> stackingOrder = workspace()->stackingOrder();
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(stackingOrder.indexOf(window1) < stackingOrder.indexOf(window2));
|
|
|
|
QVERIFY(window1->isFullScreen());
|
|
|
|
QVERIFY(window2->isFullScreen());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Create several windows on the bottom screen.
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface3(Test::createSurface());
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface3(Test::createXdgToplevelSurface(surface3.get()));
|
|
|
|
Window *window3 = Test::renderAndWaitForShown(surface3.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window3);
|
|
|
|
QVERIFY(window3->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface4(Test::createSurface());
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface4(Test::createXdgToplevelSurface(surface4.get()));
|
|
|
|
Window *window4 = Test::renderAndWaitForShown(surface4.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window4);
|
|
|
|
QVERIFY(window4->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
window3->move(QPoint(200, 1224));
|
|
|
|
window4->move(QPoint(200, 1424));
|
2019-08-28 08:46:30 +00:00
|
|
|
|
|
|
|
// Switch to window above.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionNorth);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window3->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
|
|
|
// Switch to window above.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionNorth);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window2->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
|
|
|
// Switch to window above.
|
|
|
|
workspace()->switchWindow(Workspace::DirectionNorth);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window4->isActive());
|
2019-08-28 08:46:30 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Destroy all windows.
|
2019-08-28 08:46:30 +00:00
|
|
|
shellSurface1.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
QVERIFY(Test::waitForWindowClosed(window1));
|
2019-08-28 08:46:30 +00:00
|
|
|
shellSurface2.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
QVERIFY(Test::waitForWindowClosed(window2));
|
2019-08-28 08:46:30 +00:00
|
|
|
shellSurface3.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
QVERIFY(Test::waitForWindowClosed(window3));
|
2019-08-28 08:46:30 +00:00
|
|
|
shellSurface4.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
QVERIFY(Test::waitForWindowClosed(window4));
|
2019-08-28 08:46:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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),
|
|
|
|
};
|
2023-05-08 10:16:00 +00:00
|
|
|
Test::setOutputConfig(screenGeometries);
|
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),
|
|
|
|
};
|
2023-05-08 10:16:00 +00:00
|
|
|
Test::setOutputConfig(screenGeometries);
|
2019-08-28 08:46:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
WAYLANDTEST_MAIN(KWin::ActivationTest)
|
|
|
|
#include "activation_test.moc"
|