From 411124b1abee95b8ff9a6c4c4f4d187b775b53fe Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 11 Jan 2012 16:18:21 +0200 Subject: [PATCH] Make touch events working in the qml example compositor. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: I03318359d13caf7287671bcc9e01da91acb928dd Sanity-Review: Qt Sanity Bot Reviewed-by: Jørgen Lind --- src/compositor/compositor_api/waylandsurfaceitem.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/compositor/compositor_api/waylandsurfaceitem.cpp b/src/compositor/compositor_api/waylandsurfaceitem.cpp index 8d34232..9ecd79e 100644 --- a/src/compositor/compositor_api/waylandsurfaceitem.cpp +++ b/src/compositor/compositor_api/waylandsurfaceitem.cpp @@ -106,6 +106,7 @@ void WaylandSurfaceItem::init(WaylandSurface *surface) setSmooth(true); setFlag(ItemHasContents); setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton); + setAcceptHoverEvents(true); connect(surface, SIGNAL(mapped()), this, SLOT(surfaceMapped())); connect(surface, SIGNAL(unmapped()), this, SLOT(surfaceUnmapped())); connect(surface, SIGNAL(destroyed(QObject *)), this, SLOT(surfaceDestroyed(QObject *))); @@ -189,15 +190,14 @@ void WaylandSurfaceItem::touchEvent(QTouchEvent *event) if (m_touchEventsEnabled && m_surface) { WaylandInputDevice *inputDevice = m_surface->compositor()->defaultInputDevice(); event->accept(); - QList points = event->touchPoints(); - if (!points.isEmpty()) { - for (int i = 0; i < points.count(); ++i) { - const QTouchEvent::TouchPoint &point(points.at(i)); - // Wayland expects surface-relative coordinates. - inputDevice->sendTouchPointEvent(point.id(), point.pos().x(), point.pos().y(), point.state()); - } - inputDevice->sendTouchFrameEvent(); + if (inputDevice->mouseFocus() != m_surface) { + QPoint pointPos; + QList points = event->touchPoints(); + if (!points.isEmpty()) + pointPos = points.at(0).pos().toPoint(); + inputDevice->setMouseFocus(m_surface, pointPos, pointPos); } + inputDevice->sendFullTouchEvent(event); } else { event->ignore(); } -- 2.7.4