diff options
author | Giulio Camuffo <giulio.camuffo@jollamobile.com> | 2015-01-16 12:18:43 +0200 |
---|---|---|
committer | Giulio Camuffo <giulio.camuffo@jollamobile.com> | 2015-01-20 09:28:10 +0100 |
commit | 498946d6e9c20d4e8af28ee942de5bf4cf5eaf78 (patch) | |
tree | de0161d1d94ebeb2f702858eddc3d6e1ec489fb1 | |
parent | c3fafd16d380e031463c3f9e25320e914afbccf0 (diff) |
Send a touch cancel event when we stop getting input
Take a grab when a touch gesture begins and send a touch cancel event
when we lose the grab. That makes sure that we don't leave the client
with a broken input state if some item like Flickable steals the
events from the QWaylandSurfaceItem.
Change-Id: I1e07836041a25cdbabff0d8559c4e06cbac27e7e
Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
-rw-r--r-- | src/compositor/compositor_api/qwaylandsurfaceitem.cpp | 14 | ||||
-rw-r--r-- | src/compositor/compositor_api/qwaylandsurfaceitem.h | 1 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/compositor/compositor_api/qwaylandsurfaceitem.cpp b/src/compositor/compositor_api/qwaylandsurfaceitem.cpp index 1099eb764..35e0cd285 100644 --- a/src/compositor/compositor_api/qwaylandsurfaceitem.cpp +++ b/src/compositor/compositor_api/qwaylandsurfaceitem.cpp @@ -217,6 +217,12 @@ void QWaylandSurfaceItem::keyReleaseEvent(QKeyEvent *event) void QWaylandSurfaceItem::touchEvent(QTouchEvent *event) { if (m_touchEventsEnabled) { + if (event->type() == QEvent::TouchBegin) { + QQuickItem *grabber = window()->mouseGrabberItem(); + if (grabber != this) + grabMouse(); + } + QWaylandInputDevice *inputDevice = compositor()->defaultInputDevice(); event->accept(); if (inputDevice->mouseFocus() != this) { @@ -232,6 +238,14 @@ void QWaylandSurfaceItem::touchEvent(QTouchEvent *event) } } +void QWaylandSurfaceItem::mouseUngrabEvent() +{ + if (surface()) { + QTouchEvent e(QEvent::TouchCancel); + touchEvent(&e); + } +} + void QWaylandSurfaceItem::takeFocus() { setFocus(true); diff --git a/src/compositor/compositor_api/qwaylandsurfaceitem.h b/src/compositor/compositor_api/qwaylandsurfaceitem.h index 93283355f..2805db52a 100644 --- a/src/compositor/compositor_api/qwaylandsurfaceitem.h +++ b/src/compositor/compositor_api/qwaylandsurfaceitem.h @@ -100,6 +100,7 @@ protected: void keyReleaseEvent(QKeyEvent *event); void touchEvent(QTouchEvent *event); + void mouseUngrabEvent() Q_DECL_OVERRIDE; public slots: void takeFocus(); |