summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/compositor/compositor_api/qwaylandtouch.cpp19
-rw-r--r--src/compositor/compositor_api/qwaylandtouch_p.h2
2 files changed, 20 insertions, 1 deletions
diff --git a/src/compositor/compositor_api/qwaylandtouch.cpp b/src/compositor/compositor_api/qwaylandtouch.cpp
index 3e7298001..15746cb5f 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 de1b748de..0b87f8475 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<int, 10> ids;
};
QT_END_NAMESPACE