2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2019-07-10 17:41:41 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2019 David Edmundson <davidedmundson@kde.org>
|
|
|
|
SPDX-FileCopyrightText: 2019 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
2019-07-10 17:41:41 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2022-03-23 10:13:38 +00:00
|
|
|
#include "kwin_wayland_test.h"
|
|
|
|
|
2019-07-10 17:41:41 +00:00
|
|
|
#include "cursor.h"
|
2022-04-14 12:33:28 +00:00
|
|
|
#include "output.h"
|
2019-07-10 17:41:41 +00:00
|
|
|
#include "platform.h"
|
|
|
|
#include "screens.h"
|
|
|
|
#include "wayland_server.h"
|
2022-04-22 17:39:12 +00:00
|
|
|
#include "window.h"
|
2019-07-10 17:41:41 +00:00
|
|
|
#include "workspace.h"
|
|
|
|
|
|
|
|
#include <KWayland/Client/compositor.h>
|
|
|
|
#include <KWayland/Client/plasmashell.h>
|
|
|
|
#include <KWayland/Client/shm_pool.h>
|
|
|
|
#include <KWayland/Client/surface.h>
|
|
|
|
|
|
|
|
using namespace KWin;
|
|
|
|
|
|
|
|
static const QString s_socketName = QStringLiteral("wayland_test_kwin_placement-0");
|
|
|
|
|
|
|
|
struct PlaceWindowResult
|
|
|
|
{
|
|
|
|
QSize initiallyConfiguredSize;
|
2021-05-11 05:26:51 +00:00
|
|
|
Test::XdgToplevel::States initiallyConfiguredStates;
|
2019-07-10 17:41:41 +00:00
|
|
|
QRect finalGeometry;
|
|
|
|
};
|
|
|
|
|
|
|
|
class TestPlacement : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2019-09-12 16:43:18 +00:00
|
|
|
|
2019-07-10 17:41:41 +00:00
|
|
|
private Q_SLOTS:
|
|
|
|
void init();
|
|
|
|
void cleanup();
|
|
|
|
void initTestCase();
|
|
|
|
|
|
|
|
void testPlaceSmart();
|
|
|
|
void testPlaceZeroCornered();
|
2019-09-12 16:43:18 +00:00
|
|
|
void testPlaceMaximized();
|
2019-10-11 08:46:08 +00:00
|
|
|
void testPlaceMaximizedLeavesFullscreen();
|
2019-09-12 16:43:18 +00:00
|
|
|
void testPlaceCentered();
|
|
|
|
void testPlaceUnderMouse();
|
|
|
|
void testPlaceCascaded();
|
|
|
|
void testPlaceRandom();
|
2021-01-20 18:03:45 +00:00
|
|
|
void testFullscreen();
|
2019-07-10 17:41:41 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void setPlacementPolicy(Placement::Policy policy);
|
|
|
|
/*
|
|
|
|
* Create a window with the lifespan of parent and return relevant results for testing
|
|
|
|
* defaultSize is the buffer size to use if the compositor returns an empty size in the first configure
|
|
|
|
* event.
|
|
|
|
*/
|
|
|
|
PlaceWindowResult createAndPlaceWindow(const QSize &defaultSize, QObject *parent);
|
|
|
|
};
|
|
|
|
|
|
|
|
void TestPlacement::init()
|
|
|
|
{
|
2021-05-11 05:26:51 +00:00
|
|
|
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::PlasmaShell));
|
2019-07-10 17:41:41 +00:00
|
|
|
|
2021-08-28 18:58:29 +00:00
|
|
|
workspace()->setActiveOutput(QPoint(640, 512));
|
2021-08-28 18:40:12 +00:00
|
|
|
KWin::Cursors::self()->mouse()->setPos(QPoint(640, 512));
|
2019-07-10 17:41:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestPlacement::cleanup()
|
|
|
|
{
|
|
|
|
Test::destroyWaylandConnection();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestPlacement::initTestCase()
|
|
|
|
{
|
2022-04-22 17:39:12 +00:00
|
|
|
qRegisterMetaType<KWin::Window *>();
|
2020-07-07 09:32:29 +00:00
|
|
|
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
|
|
|
|
QVERIFY(applicationStartedSpy.isValid());
|
2019-07-10 17:41:41 +00:00
|
|
|
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
|
2020-12-09 13:06:15 +00:00
|
|
|
QVERIFY(waylandServer()->init(s_socketName));
|
2019-08-26 21:16:53 +00:00
|
|
|
QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2));
|
2019-07-10 17:41:41 +00:00
|
|
|
|
|
|
|
kwinApp()->setConfig(KSharedConfig::openConfig(QString(), KConfig::SimpleConfig));
|
|
|
|
|
|
|
|
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-07-10 17:41:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestPlacement::setPlacementPolicy(Placement::Policy policy)
|
|
|
|
{
|
|
|
|
auto group = kwinApp()->config()->group("Windows");
|
|
|
|
group.writeEntry("Placement", Placement::policyToString(policy));
|
|
|
|
group.sync();
|
|
|
|
Workspace::self()->slotReconfigure();
|
|
|
|
}
|
|
|
|
|
|
|
|
PlaceWindowResult TestPlacement::createAndPlaceWindow(const QSize &defaultSize, QObject *parent)
|
|
|
|
{
|
|
|
|
PlaceWindowResult rc;
|
|
|
|
|
|
|
|
// create a new window
|
|
|
|
auto surface = Test::createSurface(parent);
|
2021-12-09 07:47:55 +00:00
|
|
|
auto shellSurface = Test::createXdgToplevelSurface(surface, Test::CreationSetup::CreateOnly, surface);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
|
|
|
QSignalSpy toplevelConfigureRequestedSpy(shellSurface, &Test::XdgToplevel::configureRequested);
|
|
|
|
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
|
2021-09-03 17:54:03 +00:00
|
|
|
surface->commit(KWayland::Client::Surface::CommitFlag::None);
|
2021-05-11 05:26:51 +00:00
|
|
|
surfaceConfigureRequestedSpy.wait();
|
2019-07-10 17:41:41 +00:00
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
rc.initiallyConfiguredSize = toplevelConfigureRequestedSpy[0][0].toSize();
|
|
|
|
rc.initiallyConfiguredStates = toplevelConfigureRequestedSpy[0][1].value<Test::XdgToplevel::States>();
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy[0][0].toUInt());
|
2019-07-10 17:41:41 +00:00
|
|
|
|
|
|
|
QSize size = rc.initiallyConfiguredSize;
|
|
|
|
|
|
|
|
if (size.isEmpty()) {
|
|
|
|
size = defaultSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto c = Test::renderAndWaitForShown(surface, size, Qt::red);
|
|
|
|
|
2019-09-27 10:01:10 +00:00
|
|
|
rc.finalGeometry = c->frameGeometry();
|
2019-07-10 17:41:41 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestPlacement::testPlaceSmart()
|
|
|
|
{
|
|
|
|
setPlacementPolicy(Placement::Smart);
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
QScopedPointer<QObject> testParent(new QObject); // dumb QObject just for scoping surfaces to the test
|
2019-07-10 17:41:41 +00:00
|
|
|
|
|
|
|
QRegion usedArea;
|
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
PlaceWindowResult windowPlacement = createAndPlaceWindow(QSize(600, 500), testParent.data());
|
|
|
|
// smart placement shouldn't define a size on clients
|
|
|
|
QCOMPARE(windowPlacement.initiallyConfiguredSize, QSize(0, 0));
|
|
|
|
QCOMPARE(windowPlacement.finalGeometry.size(), QSize(600, 500));
|
|
|
|
|
|
|
|
// exact placement isn't a defined concept that should be tested
|
|
|
|
// but the goal of smart placement is to make sure windows don't overlap until they need to
|
|
|
|
// 4 windows of 600, 500 should fit without overlap
|
|
|
|
QVERIFY(!usedArea.intersects(windowPlacement.finalGeometry));
|
|
|
|
usedArea += windowPlacement.finalGeometry;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestPlacement::testPlaceZeroCornered()
|
|
|
|
{
|
|
|
|
setPlacementPolicy(Placement::ZeroCornered);
|
|
|
|
|
|
|
|
QScopedPointer<QObject> testParent(new QObject);
|
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
PlaceWindowResult windowPlacement = createAndPlaceWindow(QSize(600, 500), testParent.data());
|
|
|
|
// smart placement shouldn't define a size on clients
|
|
|
|
QCOMPARE(windowPlacement.initiallyConfiguredSize, QSize(0, 0));
|
|
|
|
// size should match our buffer
|
|
|
|
QCOMPARE(windowPlacement.finalGeometry.size(), QSize(600, 500));
|
2022-03-23 10:13:38 +00:00
|
|
|
// and it should be in the corner
|
2019-07-10 17:41:41 +00:00
|
|
|
QCOMPARE(windowPlacement.finalGeometry.topLeft(), QPoint(0, 0));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-12 16:43:18 +00:00
|
|
|
void TestPlacement::testPlaceMaximized()
|
2019-07-10 17:41:41 +00:00
|
|
|
{
|
|
|
|
setPlacementPolicy(Placement::Maximizing);
|
|
|
|
|
|
|
|
// add a top panel
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> panelSurface(Test::createSurface());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<QObject> panelShellSurface(Test::createXdgToplevelSurface(panelSurface.data()));
|
2022-04-14 12:27:50 +00:00
|
|
|
QScopedPointer<KWayland::Client::PlasmaShellSurface> plasmaSurface(Test::waylandPlasmaShell()->createSurface(panelSurface.data()));
|
|
|
|
plasmaSurface->setRole(KWayland::Client::PlasmaShellSurface::Role::Panel);
|
2019-07-10 17:41:41 +00:00
|
|
|
plasmaSurface->setPosition(QPoint(0, 0));
|
|
|
|
Test::renderAndWaitForShown(panelSurface.data(), QSize(1280, 20), Qt::blue);
|
|
|
|
|
|
|
|
QScopedPointer<QObject> testParent(new QObject);
|
|
|
|
|
|
|
|
// all windows should be initially maximized with an initial configure size sent
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
PlaceWindowResult windowPlacement = createAndPlaceWindow(QSize(600, 500), testParent.data());
|
2021-05-11 05:26:51 +00:00
|
|
|
QVERIFY(windowPlacement.initiallyConfiguredStates & Test::XdgToplevel::State::Maximized);
|
2019-07-10 17:41:41 +00:00
|
|
|
QCOMPARE(windowPlacement.initiallyConfiguredSize, QSize(1280, 1024 - 20));
|
|
|
|
QCOMPARE(windowPlacement.finalGeometry, QRect(0, 20, 1280, 1024 - 20)); // under the panel
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-11 08:46:08 +00:00
|
|
|
void TestPlacement::testPlaceMaximizedLeavesFullscreen()
|
|
|
|
{
|
|
|
|
setPlacementPolicy(Placement::Maximizing);
|
|
|
|
|
|
|
|
// add a top panel
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> panelSurface(Test::createSurface());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<QObject> panelShellSurface(Test::createXdgToplevelSurface(panelSurface.data()));
|
2022-04-14 12:27:50 +00:00
|
|
|
QScopedPointer<KWayland::Client::PlasmaShellSurface> plasmaSurface(Test::waylandPlasmaShell()->createSurface(panelSurface.data()));
|
|
|
|
plasmaSurface->setRole(KWayland::Client::PlasmaShellSurface::Role::Panel);
|
2019-10-11 08:46:08 +00:00
|
|
|
plasmaSurface->setPosition(QPoint(0, 0));
|
|
|
|
Test::renderAndWaitForShown(panelSurface.data(), QSize(1280, 20), Qt::blue);
|
|
|
|
|
|
|
|
QScopedPointer<QObject> testParent(new QObject);
|
|
|
|
|
|
|
|
// all windows should be initially fullscreen with an initial configure size sent, despite the policy
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
auto surface = Test::createSurface(testParent.data());
|
2021-12-09 07:47:55 +00:00
|
|
|
auto shellSurface = Test::createXdgToplevelSurface(surface, Test::CreationSetup::CreateOnly, surface);
|
2021-05-11 05:26:51 +00:00
|
|
|
shellSurface->set_fullscreen(nullptr);
|
|
|
|
QSignalSpy toplevelConfigureRequestedSpy(shellSurface, &Test::XdgToplevel::configureRequested);
|
|
|
|
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
|
2021-09-03 17:54:03 +00:00
|
|
|
surface->commit(KWayland::Client::Surface::CommitFlag::None);
|
2021-05-11 05:26:51 +00:00
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
2019-10-11 08:46:08 +00:00
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
auto initiallyConfiguredSize = toplevelConfigureRequestedSpy[0][0].toSize();
|
|
|
|
auto initiallyConfiguredStates = toplevelConfigureRequestedSpy[0][1].value<Test::XdgToplevel::States>();
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy[0][0].toUInt());
|
2019-10-11 08:46:08 +00:00
|
|
|
|
|
|
|
auto c = Test::renderAndWaitForShown(surface, initiallyConfiguredSize, Qt::red);
|
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
QVERIFY(initiallyConfiguredStates & Test::XdgToplevel::State::Fullscreen);
|
2022-03-23 10:13:38 +00:00
|
|
|
QCOMPARE(initiallyConfiguredSize, QSize(1280, 1024));
|
2019-10-11 08:46:08 +00:00
|
|
|
QCOMPARE(c->frameGeometry(), QRect(0, 0, 1280, 1024));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-12 16:43:18 +00:00
|
|
|
void TestPlacement::testPlaceCentered()
|
|
|
|
{
|
|
|
|
// This test verifies that Centered placement policy works.
|
|
|
|
|
|
|
|
KConfigGroup group = kwinApp()->config()->group("Windows");
|
|
|
|
group.writeEntry("Placement", Placement::policyToString(Placement::Centered));
|
|
|
|
group.sync();
|
|
|
|
workspace()->slotReconfigure();
|
|
|
|
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface(Test::createSurface());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.data()));
|
2022-04-22 17:39:12 +00:00
|
|
|
Window *client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::red);
|
2019-09-12 16:43:18 +00:00
|
|
|
QVERIFY(client);
|
2019-09-27 10:01:10 +00:00
|
|
|
QCOMPARE(client->frameGeometry(), QRect(590, 487, 100, 50));
|
2019-09-12 16:43:18 +00:00
|
|
|
|
|
|
|
shellSurface.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(client));
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestPlacement::testPlaceUnderMouse()
|
|
|
|
{
|
|
|
|
// This test verifies that Under Mouse placement policy works.
|
|
|
|
|
|
|
|
KConfigGroup group = kwinApp()->config()->group("Windows");
|
|
|
|
group.writeEntry("Placement", Placement::policyToString(Placement::UnderMouse));
|
|
|
|
group.sync();
|
|
|
|
workspace()->slotReconfigure();
|
|
|
|
|
2020-04-02 16:18:01 +00:00
|
|
|
KWin::Cursors::self()->mouse()->setPos(QPoint(200, 300));
|
|
|
|
QCOMPARE(KWin::Cursors::self()->mouse()->pos(), QPoint(200, 300));
|
2019-09-12 16:43:18 +00:00
|
|
|
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface(Test::createSurface());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.data()));
|
2022-04-22 17:39:12 +00:00
|
|
|
Window *client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::red);
|
2019-09-12 16:43:18 +00:00
|
|
|
QVERIFY(client);
|
2019-09-27 10:01:10 +00:00
|
|
|
QCOMPARE(client->frameGeometry(), QRect(151, 276, 100, 50));
|
2019-09-12 16:43:18 +00:00
|
|
|
|
|
|
|
shellSurface.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(client));
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestPlacement::testPlaceCascaded()
|
|
|
|
{
|
|
|
|
// This test verifies that Cascaded placement policy works.
|
|
|
|
|
|
|
|
KConfigGroup group = kwinApp()->config()->group("Windows");
|
|
|
|
group.writeEntry("Placement", Placement::policyToString(Placement::Cascade));
|
|
|
|
group.sync();
|
|
|
|
workspace()->slotReconfigure();
|
|
|
|
|
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()));
|
2022-04-22 17:39:12 +00:00
|
|
|
Window *client1 = Test::renderAndWaitForShown(surface1.data(), QSize(100, 50), Qt::red);
|
2019-09-12 16:43:18 +00:00
|
|
|
QVERIFY(client1);
|
|
|
|
QCOMPARE(client1->pos(), QPoint(0, 0));
|
|
|
|
QCOMPARE(client1->size(), QSize(100, 50));
|
|
|
|
|
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()));
|
2022-04-22 17:39:12 +00:00
|
|
|
Window *client2 = Test::renderAndWaitForShown(surface2.data(), QSize(100, 50), Qt::blue);
|
2019-09-12 16:43:18 +00:00
|
|
|
QVERIFY(client2);
|
|
|
|
QCOMPARE(client2->pos(), client1->pos() + workspace()->cascadeOffset(client2));
|
|
|
|
QCOMPARE(client2->size(), QSize(100, 50));
|
|
|
|
|
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()));
|
2022-04-22 17:39:12 +00:00
|
|
|
Window *client3 = Test::renderAndWaitForShown(surface3.data(), QSize(100, 50), Qt::green);
|
2019-09-12 16:43:18 +00:00
|
|
|
QVERIFY(client3);
|
|
|
|
QCOMPARE(client3->pos(), client2->pos() + workspace()->cascadeOffset(client3));
|
|
|
|
QCOMPARE(client3->size(), QSize(100, 50));
|
|
|
|
|
|
|
|
shellSurface3.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(client3));
|
|
|
|
shellSurface2.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(client2));
|
|
|
|
shellSurface1.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(client1));
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestPlacement::testPlaceRandom()
|
|
|
|
{
|
|
|
|
// This test verifies that Random placement policy works.
|
|
|
|
|
|
|
|
KConfigGroup group = kwinApp()->config()->group("Windows");
|
|
|
|
group.writeEntry("Placement", Placement::policyToString(Placement::Random));
|
|
|
|
group.sync();
|
|
|
|
workspace()->slotReconfigure();
|
|
|
|
|
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()));
|
2022-04-22 17:39:12 +00:00
|
|
|
Window *client1 = Test::renderAndWaitForShown(surface1.data(), QSize(100, 50), Qt::red);
|
2019-09-12 16:43:18 +00:00
|
|
|
QVERIFY(client1);
|
|
|
|
QCOMPARE(client1->size(), QSize(100, 50));
|
|
|
|
|
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()));
|
2022-04-22 17:39:12 +00:00
|
|
|
Window *client2 = Test::renderAndWaitForShown(surface2.data(), QSize(100, 50), Qt::blue);
|
2019-09-12 16:43:18 +00:00
|
|
|
QVERIFY(client2);
|
|
|
|
QVERIFY(client2->pos() != client1->pos());
|
|
|
|
QCOMPARE(client2->size(), QSize(100, 50));
|
|
|
|
|
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()));
|
2022-04-22 17:39:12 +00:00
|
|
|
Window *client3 = Test::renderAndWaitForShown(surface3.data(), QSize(100, 50), Qt::green);
|
2019-09-12 16:43:18 +00:00
|
|
|
QVERIFY(client3);
|
|
|
|
QVERIFY(client3->pos() != client1->pos());
|
|
|
|
QVERIFY(client3->pos() != client2->pos());
|
|
|
|
QCOMPARE(client3->size(), QSize(100, 50));
|
|
|
|
|
|
|
|
shellSurface3.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(client3));
|
|
|
|
shellSurface2.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(client2));
|
|
|
|
shellSurface1.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(client1));
|
|
|
|
}
|
|
|
|
|
2021-01-20 18:03:45 +00:00
|
|
|
void TestPlacement::testFullscreen()
|
|
|
|
{
|
2022-04-14 12:33:28 +00:00
|
|
|
const QVector<Output *> outputs = kwinApp()->platform()->enabledOutputs();
|
2021-08-28 14:51:00 +00:00
|
|
|
|
2021-01-20 18:03:45 +00:00
|
|
|
setPlacementPolicy(Placement::Smart);
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface(Test::createSurface());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.data()));
|
2021-01-20 18:03:45 +00:00
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
Window *client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::red);
|
2021-01-20 18:03:45 +00:00
|
|
|
QVERIFY(client);
|
2021-08-28 14:51:00 +00:00
|
|
|
client->sendToOutput(outputs[0]);
|
2021-01-20 18:03:45 +00:00
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
// Wait for the configure event with the activated state.
|
|
|
|
QSignalSpy toplevelConfigureRequestedSpy(shellSurface.data(), &Test::XdgToplevel::configureRequested);
|
|
|
|
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
2021-01-20 18:03:45 +00:00
|
|
|
client->setFullScreen(true);
|
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
QSignalSpy geometryChangedSpy(client, &Window::frameGeometryChanged);
|
2021-05-11 05:26:51 +00:00
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
|
|
|
Test::render(surface.data(), toplevelConfigureRequestedSpy.last().at(0).toSize(), Qt::red);
|
2021-01-20 18:03:45 +00:00
|
|
|
QVERIFY(geometryChangedSpy.wait());
|
|
|
|
QCOMPARE(client->frameGeometry(), screens()->geometry(0));
|
|
|
|
|
|
|
|
// this doesn't require a round trip, so should be immediate
|
2021-08-28 14:51:00 +00:00
|
|
|
client->sendToOutput(outputs[1]);
|
2021-01-20 18:03:45 +00:00
|
|
|
QCOMPARE(client->frameGeometry(), screens()->geometry(1));
|
|
|
|
QCOMPARE(geometryChangedSpy.count(), 2);
|
|
|
|
}
|
|
|
|
|
2019-07-10 17:41:41 +00:00
|
|
|
WAYLANDTEST_MAIN(TestPlacement)
|
2019-09-12 16:45:53 +00:00
|
|
|
#include "placement_test.moc"
|