2021-12-10 10:22:19 +00:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "kwin_wayland_test.h"
|
|
|
|
|
2022-08-29 07:55:49 +00:00
|
|
|
#include "core/output.h"
|
|
|
|
#include "core/outputconfiguration.h"
|
|
|
|
#include "core/platform.h"
|
2021-12-10 10:22:19 +00:00
|
|
|
#include "cursor.h"
|
|
|
|
#include "wayland_server.h"
|
2022-04-22 17:39:12 +00:00
|
|
|
#include "window.h"
|
2021-12-10 10:22:19 +00:00
|
|
|
#include "workspace.h"
|
|
|
|
|
|
|
|
#include <KWayland/Client/surface.h>
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
static const QString s_socketName = QStringLiteral("wayland_test_output_changes-0");
|
|
|
|
|
|
|
|
class OutputChangesTest : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void initTestCase();
|
|
|
|
void init();
|
|
|
|
void cleanup();
|
|
|
|
|
|
|
|
void testWindowSticksToOutputAfterOutputIsDisabled();
|
|
|
|
void testWindowSticksToOutputAfterAnotherOutputIsDisabled();
|
|
|
|
void testWindowSticksToOutputAfterOutputIsMoved();
|
2022-09-13 07:43:17 +00:00
|
|
|
void testWindowSticksToOutputAfterOutputsAreSwappedLeftToRight();
|
|
|
|
void testWindowSticksToOutputAfterOutputsAreSwappedRightToLeft();
|
2022-09-13 08:13:37 +00:00
|
|
|
|
|
|
|
void testWindowRestoredAfterEnablingOutput();
|
2022-10-04 09:40:54 +00:00
|
|
|
void testMaximizedWindowRestoredAfterEnablingOutput();
|
|
|
|
void testFullScreenWindowRestoredAfterEnablingOutput();
|
2022-09-13 08:13:37 +00:00
|
|
|
|
|
|
|
void testWindowNotRestoredAfterMovingWindowAndEnablingOutput();
|
2021-12-10 10:22:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void OutputChangesTest::initTestCase()
|
|
|
|
{
|
2022-04-22 17:39:12 +00:00
|
|
|
qRegisterMetaType<Window *>();
|
2021-12-10 10:22:19 +00:00
|
|
|
|
|
|
|
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
|
|
|
|
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
|
|
|
|
QVERIFY(waylandServer()->init(s_socketName));
|
|
|
|
QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2));
|
|
|
|
|
|
|
|
kwinApp()->start();
|
|
|
|
QVERIFY(applicationStartedSpy.wait());
|
2022-07-11 10:41:15 +00:00
|
|
|
const auto outputs = workspace()->outputs();
|
2021-12-10 10:22:19 +00:00
|
|
|
QCOMPARE(outputs.count(), 2);
|
|
|
|
QCOMPARE(outputs[0]->geometry(), QRect(0, 0, 1280, 1024));
|
|
|
|
QCOMPARE(outputs[1]->geometry(), QRect(1280, 0, 1280, 1024));
|
|
|
|
}
|
|
|
|
|
|
|
|
void OutputChangesTest::init()
|
|
|
|
{
|
|
|
|
QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2));
|
|
|
|
QVERIFY(Test::setupWaylandConnection());
|
|
|
|
|
|
|
|
workspace()->setActiveOutput(QPoint(640, 512));
|
|
|
|
Cursors::self()->mouse()->setPos(QPoint(640, 512));
|
|
|
|
}
|
|
|
|
|
|
|
|
void OutputChangesTest::cleanup()
|
|
|
|
{
|
|
|
|
Test::destroyWaylandConnection();
|
|
|
|
}
|
|
|
|
|
|
|
|
void OutputChangesTest::testWindowSticksToOutputAfterOutputIsDisabled()
|
|
|
|
{
|
|
|
|
auto outputs = kwinApp()->platform()->outputs();
|
|
|
|
|
|
|
|
// Create a window.
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window);
|
2021-12-10 10:22:19 +00:00
|
|
|
|
|
|
|
// Move the window to some predefined position so the test is more robust.
|
2022-04-23 19:51:16 +00:00
|
|
|
window->move(QPoint(42, 67));
|
|
|
|
QCOMPARE(window->frameGeometry(), QRect(42, 67, 100, 50));
|
2021-12-10 10:22:19 +00:00
|
|
|
|
|
|
|
// Disable the output where the window is on.
|
2022-04-14 10:51:20 +00:00
|
|
|
OutputConfiguration config;
|
2021-12-10 10:22:19 +00:00
|
|
|
{
|
2022-04-14 08:32:51 +00:00
|
|
|
auto changeSet = config.changeSet(outputs[0]);
|
2021-12-10 10:22:19 +00:00
|
|
|
changeSet->enabled = false;
|
|
|
|
}
|
2022-09-05 07:31:57 +00:00
|
|
|
workspace()->applyOutputConfiguration(config);
|
2021-12-10 10:22:19 +00:00
|
|
|
|
|
|
|
// The window will be sent to the second output, which is at (1280, 0).
|
2022-04-23 19:51:16 +00:00
|
|
|
QCOMPARE(window->frameGeometry(), QRect(1280 + 42, 0 + 67, 100, 50));
|
2021-12-10 10:22:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OutputChangesTest::testWindowSticksToOutputAfterAnotherOutputIsDisabled()
|
|
|
|
{
|
|
|
|
auto outputs = kwinApp()->platform()->outputs();
|
|
|
|
|
|
|
|
// Create a window.
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window);
|
2021-12-10 10:22:19 +00:00
|
|
|
|
|
|
|
// Move the window to the second output.
|
2022-04-23 19:51:16 +00:00
|
|
|
window->move(QPoint(1280 + 42, 67));
|
|
|
|
QCOMPARE(window->frameGeometry(), QRect(1280 + 42, 67, 100, 50));
|
2021-12-10 10:22:19 +00:00
|
|
|
|
|
|
|
// Disable the first output.
|
2022-04-14 10:51:20 +00:00
|
|
|
OutputConfiguration config;
|
2021-12-10 10:22:19 +00:00
|
|
|
{
|
2022-04-14 08:32:51 +00:00
|
|
|
auto changeSet = config.changeSet(outputs[0]);
|
2021-12-10 10:22:19 +00:00
|
|
|
changeSet->enabled = false;
|
|
|
|
}
|
|
|
|
{
|
2022-04-14 08:32:51 +00:00
|
|
|
auto changeSet = config.changeSet(outputs[1]);
|
2021-12-10 10:22:19 +00:00
|
|
|
changeSet->pos = QPoint(0, 0);
|
|
|
|
}
|
2022-09-05 07:31:57 +00:00
|
|
|
workspace()->applyOutputConfiguration(config);
|
2021-12-10 10:22:19 +00:00
|
|
|
|
|
|
|
// The position of the window relative to its output should remain the same.
|
2022-04-23 19:51:16 +00:00
|
|
|
QCOMPARE(window->frameGeometry(), QRect(42, 67, 100, 50));
|
2021-12-10 10:22:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OutputChangesTest::testWindowSticksToOutputAfterOutputIsMoved()
|
|
|
|
{
|
|
|
|
auto outputs = kwinApp()->platform()->outputs();
|
|
|
|
|
|
|
|
// Create a window.
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window);
|
2021-12-10 10:22:19 +00:00
|
|
|
|
|
|
|
// Move the window to some predefined position so the test is more robust.
|
2022-04-23 19:51:16 +00:00
|
|
|
window->move(QPoint(42, 67));
|
|
|
|
QCOMPARE(window->frameGeometry(), QRect(42, 67, 100, 50));
|
2021-12-10 10:22:19 +00:00
|
|
|
|
|
|
|
// Disable the first output.
|
2022-04-14 10:51:20 +00:00
|
|
|
OutputConfiguration config;
|
2021-12-10 10:22:19 +00:00
|
|
|
{
|
2022-04-14 08:32:51 +00:00
|
|
|
auto changeSet = config.changeSet(outputs[0]);
|
2021-12-10 10:22:19 +00:00
|
|
|
changeSet->pos = QPoint(-10, 20);
|
|
|
|
}
|
2022-09-05 07:31:57 +00:00
|
|
|
workspace()->applyOutputConfiguration(config);
|
2021-12-10 10:22:19 +00:00
|
|
|
|
|
|
|
// The position of the window relative to its output should remain the same.
|
2022-04-23 19:51:16 +00:00
|
|
|
QCOMPARE(window->frameGeometry(), QRect(-10 + 42, 20 + 67, 100, 50));
|
2021-12-10 10:22:19 +00:00
|
|
|
}
|
|
|
|
|
2022-09-13 07:43:17 +00:00
|
|
|
void OutputChangesTest::testWindowSticksToOutputAfterOutputsAreSwappedLeftToRight()
|
|
|
|
{
|
|
|
|
// This test verifies that a window placed on the left monitor sticks
|
|
|
|
// to that monitor even after the monitors are swapped horizontally.
|
|
|
|
|
|
|
|
const auto outputs = kwinApp()->platform()->outputs();
|
|
|
|
|
|
|
|
// Create a window.
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
|
|
|
|
QVERIFY(window);
|
|
|
|
|
|
|
|
// Move the window to the left output.
|
|
|
|
window->move(QPointF(0, 0));
|
|
|
|
QCOMPARE(window->output(), outputs[0]);
|
|
|
|
QCOMPARE(window->frameGeometry(), QRectF(0, 0, 100, 50));
|
|
|
|
|
|
|
|
// Swap outputs.
|
|
|
|
OutputConfiguration config;
|
|
|
|
{
|
|
|
|
auto changeSet1 = config.changeSet(outputs[0]);
|
|
|
|
changeSet1->pos = QPoint(1280, 0);
|
|
|
|
auto changeSet2 = config.changeSet(outputs[1]);
|
|
|
|
changeSet2->pos = QPoint(0, 0);
|
|
|
|
}
|
|
|
|
workspace()->applyOutputConfiguration(config);
|
|
|
|
|
|
|
|
// The window should be still on its original output.
|
|
|
|
QCOMPARE(window->output(), outputs[0]);
|
|
|
|
QCOMPARE(window->frameGeometry(), QRectF(1280, 0, 100, 50));
|
2021-12-10 10:22:19 +00:00
|
|
|
}
|
|
|
|
|
2022-09-13 07:43:17 +00:00
|
|
|
void OutputChangesTest::testWindowSticksToOutputAfterOutputsAreSwappedRightToLeft()
|
|
|
|
{
|
|
|
|
// This test verifies that a window placed on the right monitor sticks
|
|
|
|
// to that monitor even after the monitors are swapped horizontally.
|
|
|
|
|
|
|
|
const auto outputs = kwinApp()->platform()->outputs();
|
|
|
|
|
|
|
|
// Create a window.
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
|
|
|
|
QVERIFY(window);
|
|
|
|
|
|
|
|
// Move the window to the right output.
|
|
|
|
window->move(QPointF(1280, 0));
|
|
|
|
QCOMPARE(window->output(), outputs[1]);
|
|
|
|
QCOMPARE(window->frameGeometry(), QRectF(1280, 0, 100, 50));
|
|
|
|
|
|
|
|
// Swap outputs.
|
|
|
|
OutputConfiguration config;
|
|
|
|
{
|
|
|
|
auto changeSet1 = config.changeSet(outputs[0]);
|
|
|
|
changeSet1->pos = QPoint(1280, 0);
|
|
|
|
auto changeSet2 = config.changeSet(outputs[1]);
|
|
|
|
changeSet2->pos = QPoint(0, 0);
|
|
|
|
}
|
|
|
|
workspace()->applyOutputConfiguration(config);
|
|
|
|
|
|
|
|
// The window should be still on its original output.
|
|
|
|
QCOMPARE(window->output(), outputs[1]);
|
|
|
|
QCOMPARE(window->frameGeometry(), QRectF(0, 0, 100, 50));
|
|
|
|
}
|
|
|
|
|
2022-09-13 08:13:37 +00:00
|
|
|
void OutputChangesTest::testWindowRestoredAfterEnablingOutput()
|
|
|
|
{
|
|
|
|
// This test verifies that a window will be moved back to its original output when it's hotplugged.
|
|
|
|
|
|
|
|
const auto outputs = kwinApp()->platform()->outputs();
|
|
|
|
|
|
|
|
// Create a window.
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
|
|
|
|
QVERIFY(window);
|
|
|
|
|
|
|
|
// Move the window to the right output.
|
|
|
|
window->move(QPointF(1280 + 50, 100));
|
|
|
|
QCOMPARE(window->output(), outputs[1]);
|
|
|
|
QCOMPARE(window->frameGeometry(), QRectF(1280 + 50, 100, 100, 50));
|
|
|
|
|
|
|
|
// Disable the right output.
|
|
|
|
OutputConfiguration config1;
|
|
|
|
{
|
|
|
|
auto changeSet = config1.changeSet(outputs[1]);
|
|
|
|
changeSet->enabled = false;
|
|
|
|
}
|
|
|
|
workspace()->applyOutputConfiguration(config1);
|
|
|
|
|
|
|
|
// The window will be moved to the left monitor.
|
|
|
|
QCOMPARE(window->output(), outputs[0]);
|
|
|
|
QCOMPARE(window->frameGeometry(), QRectF(50, 100, 100, 50));
|
|
|
|
|
|
|
|
// Enable the right monitor.
|
|
|
|
OutputConfiguration config2;
|
|
|
|
{
|
|
|
|
auto changeSet = config2.changeSet(outputs[1]);
|
|
|
|
changeSet->enabled = true;
|
|
|
|
}
|
|
|
|
workspace()->applyOutputConfiguration(config2);
|
|
|
|
|
|
|
|
// The window will be moved back to the right monitor.
|
|
|
|
QCOMPARE(window->output(), outputs[1]);
|
|
|
|
QCOMPARE(window->frameGeometry(), QRectF(1280 + 50, 100, 100, 50));
|
|
|
|
}
|
|
|
|
|
|
|
|
void OutputChangesTest::testWindowNotRestoredAfterMovingWindowAndEnablingOutput()
|
|
|
|
{
|
|
|
|
// This test verifies that a window won't be moved to its original output when it's
|
|
|
|
// hotplugged because the window was moved manually by the user.
|
|
|
|
|
|
|
|
const auto outputs = kwinApp()->platform()->outputs();
|
|
|
|
|
|
|
|
// Create a window.
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
|
|
|
|
QVERIFY(window);
|
|
|
|
|
|
|
|
// Move the window to the right output.
|
|
|
|
window->move(QPointF(1280 + 50, 100));
|
|
|
|
QCOMPARE(window->output(), outputs[1]);
|
|
|
|
QCOMPARE(window->frameGeometry(), QRectF(1280 + 50, 100, 100, 50));
|
|
|
|
|
|
|
|
// Disable the right output.
|
|
|
|
OutputConfiguration config1;
|
|
|
|
{
|
|
|
|
auto changeSet = config1.changeSet(outputs[1]);
|
|
|
|
changeSet->enabled = false;
|
|
|
|
}
|
|
|
|
workspace()->applyOutputConfiguration(config1);
|
|
|
|
|
|
|
|
// The window will be moved to the left monitor.
|
|
|
|
QCOMPARE(window->output(), outputs[0]);
|
|
|
|
QCOMPARE(window->frameGeometry(), QRectF(50, 100, 100, 50));
|
|
|
|
|
|
|
|
// Pretend that the user moved the window.
|
|
|
|
workspace()->slotWindowMove();
|
|
|
|
QVERIFY(window->isInteractiveMove());
|
|
|
|
window->keyPressEvent(Qt::Key_Right);
|
|
|
|
window->keyPressEvent(Qt::Key_Enter);
|
|
|
|
QCOMPARE(window->frameGeometry(), QRectF(58, 100, 100, 50));
|
|
|
|
|
|
|
|
// Enable the right monitor.
|
|
|
|
OutputConfiguration config2;
|
|
|
|
{
|
|
|
|
auto changeSet = config2.changeSet(outputs[1]);
|
|
|
|
changeSet->enabled = true;
|
|
|
|
}
|
|
|
|
workspace()->applyOutputConfiguration(config2);
|
|
|
|
|
|
|
|
// The window is still on the left monitor because user manually moved it.
|
|
|
|
QCOMPARE(window->output(), outputs[0]);
|
|
|
|
QCOMPARE(window->frameGeometry(), QRectF(58, 100, 100, 50));
|
|
|
|
}
|
|
|
|
|
2022-10-04 09:40:54 +00:00
|
|
|
void OutputChangesTest::testMaximizedWindowRestoredAfterEnablingOutput()
|
|
|
|
{
|
|
|
|
// This test verifies that a maximized window will be moved to its original
|
|
|
|
// output when it's re-enabled.
|
|
|
|
|
|
|
|
const auto outputs = kwinApp()->platform()->outputs();
|
|
|
|
|
|
|
|
// Create a window.
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
|
|
|
|
QVERIFY(window);
|
|
|
|
|
|
|
|
// kwin will send a configure event with the actived state.
|
|
|
|
QSignalSpy toplevelConfigureRequestedSpy(shellSurface.get(), &Test::XdgToplevel::configureRequested);
|
|
|
|
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
|
|
|
// Move the window to the right monitor and make it maximized.
|
|
|
|
QSignalSpy frameGeometryChangedSpy(window, &Window::frameGeometryChanged);
|
|
|
|
window->move(QPointF(1280 + 50, 100));
|
|
|
|
window->maximize(MaximizeFull);
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), QSize(1280, 1024));
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
|
|
|
Test::render(surface.get(), QSize(1280, 1024), Qt::blue);
|
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
|
|
|
QCOMPARE(window->frameGeometry(), QRectF(1280, 0, 1280, 1024));
|
|
|
|
QCOMPARE(window->moveResizeGeometry(), QRectF(1280, 0, 1280, 1024));
|
|
|
|
QCOMPARE(window->output(), outputs[1]);
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeFull);
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeFull);
|
|
|
|
QCOMPARE(window->geometryRestore(), QRectF(1280 + 50, 100, 100, 50));
|
|
|
|
|
|
|
|
// Disable the right output.
|
|
|
|
OutputConfiguration config1;
|
|
|
|
{
|
|
|
|
auto changeSet = config1.changeSet(outputs[1]);
|
|
|
|
changeSet->enabled = false;
|
|
|
|
}
|
|
|
|
workspace()->applyOutputConfiguration(config1);
|
|
|
|
|
|
|
|
// The window will be moved to the left monitor, the geometry restore will be updated too.
|
|
|
|
QCOMPARE(window->frameGeometry(), QRectF(0, 0, 1280, 1024));
|
|
|
|
QCOMPARE(window->moveResizeGeometry(), QRectF(0, 0, 1280, 1024));
|
|
|
|
QCOMPARE(window->output(), outputs[0]);
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeFull);
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeFull);
|
|
|
|
QCOMPARE(window->geometryRestore(), QRectF(50, 100, 100, 50));
|
|
|
|
|
|
|
|
// Enable the right monitor.
|
|
|
|
OutputConfiguration config2;
|
|
|
|
{
|
|
|
|
auto changeSet = config2.changeSet(outputs[1]);
|
|
|
|
changeSet->enabled = true;
|
|
|
|
}
|
|
|
|
workspace()->applyOutputConfiguration(config2);
|
|
|
|
|
|
|
|
// The window will be moved back to the right monitor, the geometry restore will be updated too.
|
|
|
|
QCOMPARE(window->frameGeometry(), QRectF(1280, 0, 1280, 1024));
|
|
|
|
QCOMPARE(window->moveResizeGeometry(), QRectF(1280, 0, 1280, 1024));
|
|
|
|
QCOMPARE(window->output(), outputs[1]);
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeFull);
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeFull);
|
|
|
|
QCOMPARE(window->geometryRestore(), QRectF(1280 + 50, 100, 100, 50));
|
|
|
|
}
|
|
|
|
|
|
|
|
void OutputChangesTest::testFullScreenWindowRestoredAfterEnablingOutput()
|
|
|
|
{
|
|
|
|
// This test verifies that a fullscreen window will be moved to its original
|
|
|
|
// output when it's re-enabled.
|
|
|
|
|
|
|
|
const auto outputs = kwinApp()->platform()->outputs();
|
|
|
|
|
|
|
|
// Create a window.
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
|
|
|
|
QVERIFY(window);
|
|
|
|
|
|
|
|
// kwin will send a configure event with the actived state.
|
|
|
|
QSignalSpy toplevelConfigureRequestedSpy(shellSurface.get(), &Test::XdgToplevel::configureRequested);
|
|
|
|
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
|
|
|
// Move the window to the right monitor and make it fullscreen.
|
|
|
|
QSignalSpy frameGeometryChangedSpy(window, &Window::frameGeometryChanged);
|
|
|
|
window->move(QPointF(1280 + 50, 100));
|
|
|
|
window->setFullScreen(true);
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), QSize(1280, 1024));
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
|
|
|
Test::render(surface.get(), QSize(1280, 1024), Qt::blue);
|
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
|
|
|
QCOMPARE(window->frameGeometry(), QRectF(1280, 0, 1280, 1024));
|
|
|
|
QCOMPARE(window->moveResizeGeometry(), QRectF(1280, 0, 1280, 1024));
|
|
|
|
QCOMPARE(window->output(), outputs[1]);
|
|
|
|
QCOMPARE(window->isFullScreen(), true);
|
|
|
|
QCOMPARE(window->isRequestedFullScreen(), true);
|
|
|
|
QCOMPARE(window->fullscreenGeometryRestore(), QRectF(1280 + 50, 100, 100, 50));
|
|
|
|
|
|
|
|
// Disable the right output.
|
|
|
|
OutputConfiguration config1;
|
|
|
|
{
|
|
|
|
auto changeSet = config1.changeSet(outputs[1]);
|
|
|
|
changeSet->enabled = false;
|
|
|
|
}
|
|
|
|
workspace()->applyOutputConfiguration(config1);
|
|
|
|
|
|
|
|
// The window will be moved to the left monitor, the geometry restore will be updated too.
|
|
|
|
QCOMPARE(window->frameGeometry(), QRectF(0, 0, 1280, 1024));
|
|
|
|
QCOMPARE(window->moveResizeGeometry(), QRectF(0, 0, 1280, 1024));
|
|
|
|
QCOMPARE(window->output(), outputs[0]);
|
|
|
|
QCOMPARE(window->isFullScreen(), true);
|
|
|
|
QCOMPARE(window->isRequestedFullScreen(), true);
|
|
|
|
QCOMPARE(window->fullscreenGeometryRestore(), QRectF(50, 100, 100, 50));
|
|
|
|
|
|
|
|
// Enable the right monitor.
|
|
|
|
OutputConfiguration config2;
|
|
|
|
{
|
|
|
|
auto changeSet = config2.changeSet(outputs[1]);
|
|
|
|
changeSet->enabled = true;
|
|
|
|
}
|
|
|
|
workspace()->applyOutputConfiguration(config2);
|
|
|
|
|
|
|
|
// The window will be moved back to the right monitor, the geometry restore will be updated too.
|
|
|
|
QCOMPARE(window->frameGeometry(), QRectF(1280, 0, 1280, 1024));
|
|
|
|
QCOMPARE(window->moveResizeGeometry(), QRectF(1280, 0, 1280, 1024));
|
|
|
|
QCOMPARE(window->output(), outputs[1]);
|
|
|
|
QCOMPARE(window->isFullScreen(), true);
|
|
|
|
QCOMPARE(window->isRequestedFullScreen(), true);
|
|
|
|
QCOMPARE(window->fullscreenGeometryRestore(), QRectF(1280 + 50, 100, 100, 50));
|
|
|
|
}
|
|
|
|
|
2022-09-13 07:43:17 +00:00
|
|
|
} // namespace KWin
|
|
|
|
|
2021-12-10 10:22:19 +00:00
|
|
|
WAYLANDTEST_MAIN(KWin::OutputChangesTest)
|
|
|
|
#include "outputchanges_test.moc"
|