summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2019-03-06 13:20:04 +0100
committerJohan Klokkhammer Helsing <johan.helsing@qt.io>2019-05-22 12:17:01 +0200
commitcde2fe3fba31b9b8d258f0663bc34009fd769efd (patch)
tree90c44e9046151378acc2fc2fdb1eb7312e6921fa
parente008c69e231169425e2ae602deabc0eb749376ab (diff)
downloadqtwayland-cde2fe3fba31b9b8d258f0663bc34009fd769efd.tar.gz
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 <paul.tvete@qt.io> (cherry picked from commit 869a38c082daf150a16b2abb230b420de3e4af31)
-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 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<int, 10> ids;
};
QT_END_NAMESPACE