Commit 253cb85f authored by Martin Flöser's avatar Martin Flöser
Browse files

[src/server] Verify that surface has a resource before sending pointer enter

Summary:
If we try to send a pointer enter on a null resource of a Surface
(e.g. after unbound) we hit a marshalling error:
error marshalling arguments for enter (signature uoff): null value passed for arg 1

The added test case hits this error without the change and passes
cleanly with the change.

Reviewers: #plasma_on_wayland

Subscribers: plasma-devel

Tags: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D2159
parent 53f27fee
......@@ -79,6 +79,7 @@ private Q_SLOTS:
void testSelection();
void testTouch();
void testDisconnect();
void testPointerEnterOnUnboundSurface();
// TODO: add test for keymap
private:
......@@ -1756,5 +1757,40 @@ void TestWaylandSeat::testDisconnect()
m_queue->destroy();
}
void TestWaylandSeat::testPointerEnterOnUnboundSurface()
{
using namespace KWayland::Client;
using namespace KWayland::Server;
// create the things we need
m_seatInterface->setHasKeyboard(true);
m_seatInterface->setHasPointer(true);
m_seatInterface->setHasTouch(true);
QSignalSpy pointerChangedSpy(m_seat, &Seat::hasPointerChanged);
QVERIFY(pointerChangedSpy.isValid());
QVERIFY(pointerChangedSpy.wait());
// create pointer and Surface
QScopedPointer<Pointer> pointer(m_seat->createPointer());
QVERIFY(!pointer.isNull());
// create the surface
QSignalSpy surfaceCreatedSpy(m_compositorInterface, &CompositorInterface::surfaceCreated);
QVERIFY(surfaceCreatedSpy.isValid());
QScopedPointer<Surface> s(m_compositor->createSurface());
QVERIFY(surfaceCreatedSpy.wait());
SurfaceInterface *serverSurface = surfaceCreatedSpy.first().first().value<KWayland::Server::SurfaceInterface*>();
QVERIFY(serverSurface);
// unbind the surface again
QSignalSpy surfaceUnboundSpy(serverSurface, &SurfaceInterface::unbound);
QVERIFY(surfaceUnboundSpy.isValid());
s.reset();
QVERIFY(surfaceUnboundSpy.wait());
QSignalSpy clientErrorSpy(m_connection, &ConnectionThread::errorOccurred);
QVERIFY(clientErrorSpy.isValid());
m_seatInterface->setFocusedPointerSurface(serverSurface);
QVERIFY(!clientErrorSpy.wait(100));
}
QTEST_GUILESS_MAIN(TestWaylandSeat)
#include "test_wayland_seat.moc"
......@@ -88,7 +88,7 @@ static QPointF surfacePosition(SurfaceInterface *surface) {
void PointerInterface::Private::sendEnter(SurfaceInterface *surface, const QPointF &parentSurfacePosition, quint32 serial)
{
if (!surface) {
if (!surface || !surface->resource()) {
return;
}
const QPointF adjustedPos = parentSurfacePosition - surfacePosition(surface);
......
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