Commit 79f41026 authored by Martin Flöser's avatar Martin Flöser
Browse files

Support request resizing on ShellSurface

Implemented in both client and server side.

REVIEW: 125836
parent c72313be
......@@ -43,6 +43,7 @@ class TestWaylandShell : public QObject
public:
explicit TestWaylandShell(QObject *parent = nullptr);
private Q_SLOTS:
void initTestCase();
void init();
void cleanup();
......@@ -58,6 +59,8 @@ private Q_SLOTS:
void testDestroy();
void testCast();
void testMove();
void testResize_data();
void testResize();
private:
KWayland::Server::Display *m_display;
......@@ -91,6 +94,11 @@ TestWaylandShell::TestWaylandShell(QObject *parent)
{
}
void TestWaylandShell::initTestCase()
{
qRegisterMetaType<Qt::Edges>();
}
void TestWaylandShell::init()
{
using namespace KWayland::Server;
......@@ -631,5 +639,65 @@ void TestWaylandShell::testMove()
QCOMPARE(moveRequestedSpy.first().at(1).value<quint32>(), m_seatInterface->pointerButtonSerial(Qt::LeftButton));
}
void TestWaylandShell::testResize_data()
{
QTest::addColumn<Qt::Edges>("resizeEdge");
QTest::addColumn<Qt::Edges>("expectedEdge");
QTest::newRow("None") << Qt::Edges() << Qt::Edges();
QTest::newRow("Top") << Qt::Edges(Qt::TopEdge) << Qt::Edges(Qt::TopEdge);
QTest::newRow("Bottom") << Qt::Edges(Qt::BottomEdge) << Qt::Edges(Qt::BottomEdge);
QTest::newRow("Left") << Qt::Edges(Qt::LeftEdge) << Qt::Edges(Qt::LeftEdge);
QTest::newRow("Right") << Qt::Edges(Qt::RightEdge) << Qt::Edges(Qt::RightEdge);
QTest::newRow("Top Left") << Qt::Edges(Qt::TopEdge | Qt::LeftEdge) << Qt::Edges(Qt::TopEdge | Qt::LeftEdge);
QTest::newRow("Top Right") << Qt::Edges(Qt::TopEdge | Qt::RightEdge) << Qt::Edges(Qt::TopEdge | Qt::RightEdge);
QTest::newRow("Bottom Left") << Qt::Edges(Qt::BottomEdge | Qt::LeftEdge) << Qt::Edges(Qt::BottomEdge | Qt::LeftEdge);
QTest::newRow("Bottom Right") << Qt::Edges(Qt::BottomEdge | Qt::RightEdge) << Qt::Edges(Qt::BottomEdge | Qt::RightEdge);
// invalid combinations
QTest::newRow("Top Bottom") << Qt::Edges(Qt::TopEdge | Qt::BottomEdge) << Qt::Edges();
QTest::newRow("Left Right") << Qt::Edges(Qt::RightEdge | Qt::LeftEdge) << Qt::Edges();
QTest::newRow("Top Bottom Right") << Qt::Edges(Qt::TopEdge | Qt::BottomEdge | Qt::RightEdge) << Qt::Edges();
QTest::newRow("Top Bottom Left") << Qt::Edges(Qt::TopEdge | Qt::BottomEdge | Qt::LeftEdge) << Qt::Edges();
QTest::newRow("Left Right Top") << Qt::Edges(Qt::RightEdge | Qt::LeftEdge | Qt::TopEdge) << Qt::Edges();
QTest::newRow("Left Right Bottom") << Qt::Edges(Qt::RightEdge | Qt::LeftEdge | Qt::BottomEdge) << Qt::Edges();
QTest::newRow("All") << Qt::Edges(Qt::RightEdge | Qt::LeftEdge | Qt::BottomEdge | Qt::TopEdge) << Qt::Edges();
}
void TestWaylandShell::testResize()
{
using namespace KWayland::Client;
using namespace KWayland::Server;
QScopedPointer<KWayland::Client::Surface> s(m_compositor->createSurface());
QVERIFY(!s.isNull());
QVERIFY(s->isValid());
ShellSurface *surface = m_shell->createSurface(s.data(), m_shell);
QSignalSpy serverSurfaceSpy(m_shellInterface, &ShellInterface::surfaceCreated);
QVERIFY(serverSurfaceSpy.isValid());
QVERIFY(serverSurfaceSpy.wait());
ShellSurfaceInterface *serverSurface = serverSurfaceSpy.first().first().value<ShellSurfaceInterface*>();
QVERIFY(serverSurface);
QSignalSpy resizeRequestedSpy(serverSurface, &ShellSurfaceInterface::resizeRequested);
QVERIFY(resizeRequestedSpy.isValid());
QSignalSpy pointerButtonChangedSpy(m_pointer, &Pointer::buttonStateChanged);
QVERIFY(pointerButtonChangedSpy.isValid());
m_seatInterface->setFocusedPointerSurface(serverSurface->surface());
m_seatInterface->pointerButtonPressed(Qt::LeftButton);
QVERIFY(pointerButtonChangedSpy.wait());
QFETCH(Qt::Edges, resizeEdge);
surface->requestResize(m_seat, pointerButtonChangedSpy.first().first().value<quint32>(), resizeEdge);
QVERIFY(resizeRequestedSpy.wait());
QCOMPARE(resizeRequestedSpy.count(), 1);
QCOMPARE(resizeRequestedSpy.first().at(0).value<SeatInterface*>(), m_seatInterface);
QCOMPARE(resizeRequestedSpy.first().at(1).value<quint32>(), m_seatInterface->pointerButtonSerial(Qt::LeftButton));
QTEST(resizeRequestedSpy.first().at(2).value<Qt::Edges>(), "expectedEdge");
}
QTEST_GUILESS_MAIN(TestWaylandShell)
#include "test_wayland_shell.moc"
......@@ -259,12 +259,38 @@ void ShellSurfaceInterface::Private::moveCallback(wl_client *client, wl_resource
void ShellSurfaceInterface::Private::resizeCallback(wl_client *client, wl_resource *resource, wl_resource *seat, uint32_t serial, uint32_t edges)
{
Q_UNUSED(seat)
Q_UNUSED(serial)
Q_UNUSED(edges)
auto s = cast<Private>(resource);
Q_ASSERT(client == *s->client);
// TODO: implement
Qt::Edges qtEdges;
switch (edges) {
case WL_SHELL_SURFACE_RESIZE_TOP:
qtEdges = Qt::TopEdge;
break;
case WL_SHELL_SURFACE_RESIZE_BOTTOM:
qtEdges = Qt::BottomEdge;
break;
case WL_SHELL_SURFACE_RESIZE_LEFT:
qtEdges = Qt::LeftEdge;
break;
case WL_SHELL_SURFACE_RESIZE_TOP_LEFT:
qtEdges = Qt::TopEdge | Qt::LeftEdge;
break;
case WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT:
qtEdges = Qt::BottomEdge | Qt::LeftEdge;
break;
case WL_SHELL_SURFACE_RESIZE_RIGHT:
qtEdges = Qt::RightEdge;
break;
case WL_SHELL_SURFACE_RESIZE_TOP_RIGHT:
qtEdges = Qt::TopEdge | Qt::RightEdge;
break;
case WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT:
qtEdges = Qt::BottomEdge | Qt::RightEdge;
break;
default:
break;
}
emit s->q_func()->resizeRequested(SeatInterface::get(seat), serial, qtEdges);
}
void ShellSurfaceInterface::Private::setToplevelCallback(wl_client *client, wl_resource *resource)
......
......@@ -280,6 +280,15 @@ Q_SIGNALS:
* @since 5.5
**/
void moveRequested(KWayland::Server::SeatInterface *seat, quint32 serial);
/**
* The surface requested a window resize.
*
* @param seat The SeatInterface on which the surface requested the resize
* @param serial The serial of the implicit mouse grab which triggered the resize
* @param edges A hint which edges are involved in the resize
* @since 5.5
**/
void resizeRequested(KWayland::Server::SeatInterface *seat, quint32 serial, Qt::Edges edges);
private:
friend class ShellInterface;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment