Consider all client in Workspace::packPositionFoo
We need to use m_allClients (AbstractClient) instead of clients (just Client). Thus packing against another AbstractClient works.
This commit is contained in:
parent
b19da3cb14
commit
45fb1680fc
2 changed files with 91 additions and 4 deletions
|
@ -54,6 +54,8 @@ private Q_SLOTS:
|
|||
void testMove();
|
||||
void testPackTo_data();
|
||||
void testPackTo();
|
||||
void testPackAgainstClient_data();
|
||||
void testPackAgainstClient();
|
||||
|
||||
private:
|
||||
KWayland::Client::ConnectionThread *m_connection = nullptr;
|
||||
|
@ -286,6 +288,91 @@ void MoveResizeWindowTest::testPackTo()
|
|||
QTEST(c->geometry(), "expectedGeometry");
|
||||
}
|
||||
|
||||
void MoveResizeWindowTest::testPackAgainstClient_data()
|
||||
{
|
||||
QTest::addColumn<QString>("methodCall");
|
||||
QTest::addColumn<QRect>("expectedGeometry");
|
||||
|
||||
QTest::newRow("left") << QStringLiteral("slotWindowPackLeft") << QRect(10, 487, 100, 50);
|
||||
QTest::newRow("up") << QStringLiteral("slotWindowPackUp") << QRect(590, 10, 100, 50);
|
||||
QTest::newRow("right") << QStringLiteral("slotWindowPackRight") << QRect(1170, 487, 100, 50);
|
||||
QTest::newRow("down") << QStringLiteral("slotWindowPackDown") << QRect(590, 964, 100, 50);
|
||||
}
|
||||
|
||||
void MoveResizeWindowTest::testPackAgainstClient()
|
||||
{
|
||||
using namespace KWayland::Client;
|
||||
|
||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||
QVERIFY(clientAddedSpy.isValid());
|
||||
|
||||
QScopedPointer<Surface> surface1(m_compositor->createSurface());
|
||||
QVERIFY(!surface1.isNull());
|
||||
QScopedPointer<Surface> surface2(m_compositor->createSurface());
|
||||
QVERIFY(!surface2.isNull());
|
||||
QScopedPointer<Surface> surface3(m_compositor->createSurface());
|
||||
QVERIFY(!surface3.isNull());
|
||||
QScopedPointer<Surface> surface4(m_compositor->createSurface());
|
||||
QVERIFY(!surface4.isNull());
|
||||
|
||||
QScopedPointer<ShellSurface> shellSurface1(m_shell->createSurface(surface1.data()));
|
||||
QVERIFY(!shellSurface1.isNull());
|
||||
QScopedPointer<ShellSurface> shellSurface2(m_shell->createSurface(surface2.data()));
|
||||
QVERIFY(!shellSurface2.isNull());
|
||||
QScopedPointer<ShellSurface> shellSurface3(m_shell->createSurface(surface3.data()));
|
||||
QVERIFY(!shellSurface3.isNull());
|
||||
QScopedPointer<ShellSurface> shellSurface4(m_shell->createSurface(surface4.data()));
|
||||
QVERIFY(!shellSurface4.isNull());
|
||||
auto renderWindow = [this, &clientAddedSpy] (Surface *surface, const QString &methodCall, const QRect &expectedGeometry) {
|
||||
// let's render
|
||||
QImage img(QSize(10, 10), QImage::Format_ARGB32);
|
||||
img.fill(Qt::blue);
|
||||
surface->attachBuffer(m_shm->createBuffer(img));
|
||||
surface->damage(QRect(0, 0, 10, 10));
|
||||
surface->commit(Surface::CommitFlag::None);
|
||||
|
||||
m_connection->flush();
|
||||
QVERIFY(clientAddedSpy.wait());
|
||||
AbstractClient *c = workspace()->activeClient();
|
||||
QVERIFY(c);
|
||||
QCOMPARE(clientAddedSpy.first().first().value<ShellClient*>(), c);
|
||||
QCOMPARE(c->geometry().size(), QSize(10, 10));
|
||||
clientAddedSpy.clear();
|
||||
// let's place it centered
|
||||
Placement::self()->placeCentered(c, QRect(0, 0, 1280, 1024));
|
||||
QCOMPARE(c->geometry(), QRect(635, 507, 10, 10));
|
||||
QMetaObject::invokeMethod(workspace(), methodCall.toLocal8Bit().constData());
|
||||
QCOMPARE(c->geometry(), expectedGeometry);
|
||||
};
|
||||
renderWindow(surface1.data(), QStringLiteral("slotWindowPackLeft"), QRect(0, 507, 10, 10));
|
||||
renderWindow(surface2.data(), QStringLiteral("slotWindowPackUp"), QRect(635, 0, 10, 10));
|
||||
renderWindow(surface3.data(), QStringLiteral("slotWindowPackRight"), QRect(1270, 507, 10, 10));
|
||||
renderWindow(surface4.data(), QStringLiteral("slotWindowPackDown"), QRect(635, 1014, 10, 10));
|
||||
|
||||
QScopedPointer<Surface> surface(m_compositor->createSurface());
|
||||
QVERIFY(!surface.isNull());
|
||||
QScopedPointer<ShellSurface> shellSurface(m_shell->createSurface(surface.data()));
|
||||
QVERIFY(!shellSurface.isNull());
|
||||
QImage img(QSize(100, 50), QImage::Format_ARGB32);
|
||||
img.fill(Qt::blue);
|
||||
surface->attachBuffer(m_shm->createBuffer(img));
|
||||
surface->damage(QRect(0, 0, 100, 50));
|
||||
surface->commit(Surface::CommitFlag::None);
|
||||
|
||||
m_connection->flush();
|
||||
QVERIFY(clientAddedSpy.wait());
|
||||
AbstractClient *c = workspace()->activeClient();
|
||||
QVERIFY(c);
|
||||
QCOMPARE(clientAddedSpy.first().first().value<ShellClient*>(), c);
|
||||
// let's place it centered
|
||||
Placement::self()->placeCentered(c, QRect(0, 0, 1280, 1024));
|
||||
QCOMPARE(c->geometry(), QRect(590, 487, 100, 50));
|
||||
|
||||
QFETCH(QString, methodCall);
|
||||
QMetaObject::invokeMethod(workspace(), methodCall.toLocal8Bit().constData());
|
||||
QTEST(c->geometry(), "expectedGeometry");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
WAYLANTEST_MAIN(KWin::MoveResizeWindowTest)
|
||||
|
|
|
@ -891,7 +891,7 @@ int Workspace::packPositionLeft(const AbstractClient* cl, int oldx, bool left_ed
|
|||
if (oldx <= newx)
|
||||
return oldx;
|
||||
const int desktop = cl->desktop() == 0 || cl->isOnAllDesktops() ? VirtualDesktopManager::self()->current() : cl->desktop();
|
||||
for (ClientList::ConstIterator it = clients.constBegin(), end = clients.constEnd(); it != end; ++it) {
|
||||
for (auto it = m_allClients.constBegin(), end = m_allClients.constEnd(); it != end; ++it) {
|
||||
if (isIrrelevant(*it, cl, desktop))
|
||||
continue;
|
||||
int x = left_edge ? (*it)->geometry().right() + 1 : (*it)->geometry().left() - 1;
|
||||
|
@ -919,7 +919,7 @@ int Workspace::packPositionRight(const AbstractClient* cl, int oldx, bool right_
|
|||
if (oldx >= newx)
|
||||
return oldx;
|
||||
const int desktop = cl->desktop() == 0 || cl->isOnAllDesktops() ? VirtualDesktopManager::self()->current() : cl->desktop();
|
||||
for (ClientList::ConstIterator it = clients.constBegin(), end = clients.constEnd(); it != end; ++it) {
|
||||
for (auto it = m_allClients.constBegin(), end = m_allClients.constEnd(); it != end; ++it) {
|
||||
if (isIrrelevant(*it, cl, desktop))
|
||||
continue;
|
||||
int x = right_edge ? (*it)->geometry().left() - 1 : (*it)->geometry().right() + 1;
|
||||
|
@ -947,7 +947,7 @@ int Workspace::packPositionUp(const AbstractClient* cl, int oldy, bool top_edge)
|
|||
if (oldy <= newy)
|
||||
return oldy;
|
||||
const int desktop = cl->desktop() == 0 || cl->isOnAllDesktops() ? VirtualDesktopManager::self()->current() : cl->desktop();
|
||||
for (ClientList::ConstIterator it = clients.constBegin(), end = clients.constEnd(); it != end; ++it) {
|
||||
for (auto it = m_allClients.constBegin(), end = m_allClients.constEnd(); it != end; ++it) {
|
||||
if (isIrrelevant(*it, cl, desktop))
|
||||
continue;
|
||||
int y = top_edge ? (*it)->geometry().bottom() + 1 : (*it)->geometry().top() - 1;
|
||||
|
@ -975,7 +975,7 @@ int Workspace::packPositionDown(const AbstractClient* cl, int oldy, bool bottom_
|
|||
if (oldy >= newy)
|
||||
return oldy;
|
||||
const int desktop = cl->desktop() == 0 || cl->isOnAllDesktops() ? VirtualDesktopManager::self()->current() : cl->desktop();
|
||||
for (ClientList::ConstIterator it = clients.constBegin(), end = clients.constEnd(); it != end; ++it) {
|
||||
for (auto it = m_allClients.constBegin(), end = m_allClients.constEnd(); it != end; ++it) {
|
||||
if (isIrrelevant(*it, cl, desktop))
|
||||
continue;
|
||||
int y = bottom_edge ? (*it)->geometry().top() - 1 : (*it)->geometry().bottom() + 1;
|
||||
|
|
Loading…
Reference in a new issue