diff options
author | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2016-09-21 12:37:12 +0200 |
---|---|---|
committer | Johan Helsing <johan.helsing@qt.io> | 2016-09-28 13:09:06 +0000 |
commit | 151048920fed4ed15af12936010e66d5d4bd5555 (patch) | |
tree | 9381330c1d45563c44851a9ee187438da2d1b0d8 /src/compositor/compositor_api/qwaylandtouch.cpp | |
parent | 21ab16ca3c8d19a31d915d8fe46172a0d6b73bd3 (diff) |
Return serial from sendTouchPointEvent
Note that sendFullTouchEvent does not return any serial, because it might
result in multiple events being sent with different serials, choosing one
doesn't make sense and returning a vector of them seems a little over the top
since they won't be used most of the time.
Change-Id: Ie38b57dae1c7553668b04d4a62f5a074d78f63dd
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'src/compositor/compositor_api/qwaylandtouch.cpp')
-rw-r--r-- | src/compositor/compositor_api/qwaylandtouch.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/compositor/compositor_api/qwaylandtouch.cpp b/src/compositor/compositor_api/qwaylandtouch.cpp index c07809e71..2caa06bee 100644 --- a/src/compositor/compositor_api/qwaylandtouch.cpp +++ b/src/compositor/compositor_api/qwaylandtouch.cpp @@ -77,26 +77,28 @@ void QWaylandTouchPrivate::touch_release(Resource *resource) wl_resource_destroy(resource->handle); } -void QWaylandTouchPrivate::sendDown(uint32_t time, int touch_id, const QPointF &position) +uint QWaylandTouchPrivate::sendDown(uint32_t time, int touch_id, const QPointF &position) { Q_Q(QWaylandTouch); if (!focusResource || !seat->mouseFocus()) - return; + return 0; uint32_t serial = q->compositor()->nextSerial(); wl_touch_send_down(focusResource->handle, serial, time, seat->mouseFocus()->surfaceResource(), touch_id, wl_fixed_from_double(position.x()), wl_fixed_from_double(position.y())); + return serial; } -void QWaylandTouchPrivate::sendUp(uint32_t time, int touch_id) +uint QWaylandTouchPrivate::sendUp(uint32_t time, int touch_id) { if (!focusResource) - return; + return 0; uint32_t serial = compositor()->nextSerial(); wl_touch_send_up(focusResource->handle, serial, time, touch_id); + return serial; } void QWaylandTouchPrivate::sendMotion(uint32_t time, int touch_id, const QPointF &position) { @@ -147,27 +149,30 @@ QWaylandCompositor *QWaylandTouch::compositor() const /*! * Sends a touch point event for the touch device with the given \a id, * \a position, and \a state. + * + * Returns the serial of the down or up event if sent, otherwise 0. */ -void QWaylandTouch::sendTouchPointEvent(int id, const QPointF &position, Qt::TouchPointState state) +uint QWaylandTouch::sendTouchPointEvent(int id, const QPointF &position, Qt::TouchPointState state) { Q_D(QWaylandTouch); uint32_t time = compositor()->currentTimeMsecs(); + uint serial = 0; switch (state) { case Qt::TouchPointPressed: - d->sendDown(time, id, position); + serial = d->sendDown(time, id, position); break; case Qt::TouchPointMoved: d->sendMotion(time, id, position); break; case Qt::TouchPointReleased: - d->sendUp(time, id); + serial = d->sendUp(time, id); break; case Qt::TouchPointStationary: // stationary points are not sent through wayland, the client must cache them break; - default: - break; } + + return serial; } /*! |