From cde2fe3fba31b9b8d258f0663bc34009fd769efd Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Wed, 6 Mar 2019 13:20:04 +0100 Subject: [PATCH 2/8] Compositor: Map touch ids to contiguous ids The protocol doesn't require this, but some clients seem to depend on it nevertheless. Fixes: QTBUG-75667 Change-Id: I47491c396d3c9193c7e51e13c7ca1586246e335c Reviewed-by: Paul Olav Tvete (cherry picked from commit 869a38c082daf150a16b2abb230b420de3e4af31) --- .../compositor_api/qwaylandtouch.cpp | 19 ++++++++++++++++++- .../compositor_api/qwaylandtouch_p.h | 2 ++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/compositor/compositor_api/qwaylandtouch.cpp b/src/compositor/compositor_api/qwaylandtouch.cpp index 3e729800..15746cb5 100644 --- a/src/compositor/compositor_api/qwaylandtouch.cpp +++ b/src/compositor/compositor_api/qwaylandtouch.cpp @@ -98,6 +98,20 @@ void QWaylandTouchPrivate::sendMotion(QWaylandClient *client, uint32_t time, int wl_fixed_from_double(position.x()), wl_fixed_from_double(position.y())); } +int QWaylandTouchPrivate::toSequentialWaylandId(int touchId) +{ + const int waylandId = ids.indexOf(touchId); + if (waylandId != -1) + return waylandId; + const int availableId = ids.indexOf(-1); + if (availableId != -1) { + ids[availableId] = touchId; + return availableId; + } + ids.append(touchId); + return ids.length() - 1; +} + /*! * \class QWaylandTouch * \inmodule QtWaylandCompositor @@ -212,7 +226,10 @@ void QWaylandTouch::sendFullTouchEvent(QWaylandSurface *surface, QTouchEvent *ev for (int i = 0; i < pointCount; ++i) { const QTouchEvent::TouchPoint &tp(points.at(i)); // Convert the local pos in the compositor window to surface-relative. - sendTouchPointEvent(surface, tp.id(), tp.pos(), tp.state()); + const int id = d->toSequentialWaylandId(tp.id()); + sendTouchPointEvent(surface, id, tp.pos(), tp.state()); + if (tp.state() == Qt::TouchPointReleased) + d->ids[id] = -1; } sendFrameEvent(surface->client()); } diff --git a/src/compositor/compositor_api/qwaylandtouch_p.h b/src/compositor/compositor_api/qwaylandtouch_p.h index de1b748d..0b87f847 100644 --- a/src/compositor/compositor_api/qwaylandtouch_p.h +++ b/src/compositor/compositor_api/qwaylandtouch_p.h @@ -80,8 +80,10 @@ public: private: void touch_release(Resource *resource) override; + int toSequentialWaylandId(int touchId); QWaylandSeat *seat = nullptr; + QVarLengthArray ids; }; QT_END_NAMESPACE -- 2.17.1