summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2016-09-21 12:37:12 +0200
committerJohan Helsing <johan.helsing@qt.io>2016-09-28 13:09:06 +0000
commit151048920fed4ed15af12936010e66d5d4bd5555 (patch)
tree9381330c1d45563c44851a9ee187438da2d1b0d8
parent21ab16ca3c8d19a31d915d8fe46172a0d6b73bd3 (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>
-rw-r--r--src/compositor/compositor_api/qwaylandseat.cpp8
-rw-r--r--src/compositor/compositor_api/qwaylandseat.h2
-rw-r--r--src/compositor/compositor_api/qwaylandtouch.cpp23
-rw-r--r--src/compositor/compositor_api/qwaylandtouch.h2
-rw-r--r--src/compositor/compositor_api/qwaylandtouch_p.h4
5 files changed, 23 insertions, 16 deletions
diff --git a/src/compositor/compositor_api/qwaylandseat.cpp b/src/compositor/compositor_api/qwaylandseat.cpp
index f84325185..145184c0e 100644
--- a/src/compositor/compositor_api/qwaylandseat.cpp
+++ b/src/compositor/compositor_api/qwaylandseat.cpp
@@ -242,14 +242,16 @@ void QWaylandSeat::sendKeyReleaseEvent(uint code)
/*!
* Sends a touch point event with the given \a id and \a state to the touch device. The position
* of the touch point is given by \a point.
+ *
+ * Returns the serial for the touch up or touch down event.
*/
-void QWaylandSeat::sendTouchPointEvent(int id, const QPointF &point, Qt::TouchPointState state)
+uint QWaylandSeat::sendTouchPointEvent(int id, const QPointF &point, Qt::TouchPointState state)
{
Q_D(QWaylandSeat);
if (d->touch.isNull()) {
- return;
+ return 0;
}
- d->touch->sendTouchPointEvent(id, point,state);
+ return d->touch->sendTouchPointEvent(id, point,state);
}
/*!
diff --git a/src/compositor/compositor_api/qwaylandseat.h b/src/compositor/compositor_api/qwaylandseat.h
index bfd6e4041..5501d9202 100644
--- a/src/compositor/compositor_api/qwaylandseat.h
+++ b/src/compositor/compositor_api/qwaylandseat.h
@@ -91,7 +91,7 @@ public:
void sendFullKeyEvent(QKeyEvent *event);
void sendFullKeyEvent(QWaylandSurface *surface, QKeyEvent *event);
- void sendTouchPointEvent(int id, const QPointF &point, Qt::TouchPointState state);
+ uint sendTouchPointEvent(int id, const QPointF &point, Qt::TouchPointState state);
void sendTouchFrameEvent();
void sendTouchCancelEvent();
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;
}
/*!
diff --git a/src/compositor/compositor_api/qwaylandtouch.h b/src/compositor/compositor_api/qwaylandtouch.h
index c058d42ae..f539ce2cd 100644
--- a/src/compositor/compositor_api/qwaylandtouch.h
+++ b/src/compositor/compositor_api/qwaylandtouch.h
@@ -62,7 +62,7 @@ public:
QWaylandSeat *seat() const;
QWaylandCompositor *compositor() const;
- virtual void sendTouchPointEvent(int id, const QPointF &position, Qt::TouchPointState state);
+ virtual uint sendTouchPointEvent(int id, const QPointF &position, Qt::TouchPointState state);
virtual void sendFrameEvent();
virtual void sendCancelEvent();
diff --git a/src/compositor/compositor_api/qwaylandtouch_p.h b/src/compositor/compositor_api/qwaylandtouch_p.h
index 2f60076a7..35cd30502 100644
--- a/src/compositor/compositor_api/qwaylandtouch_p.h
+++ b/src/compositor/compositor_api/qwaylandtouch_p.h
@@ -71,9 +71,9 @@ public:
QWaylandCompositor *compositor() const { return seat->compositor(); }
- void sendDown(uint32_t time, int touch_id, const QPointF &position);
+ uint sendDown(uint32_t time, int touch_id, const QPointF &position);
void sendMotion(uint32_t time, int touch_id, const QPointF &position);
- void sendUp(uint32_t time, int touch_id);
+ uint sendUp(uint32_t time, int touch_id);
void setFocusResource()
{