From 2c65b78b400ec27e6e559829b9a970dca2df6669 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 4 Dec 2013 12:51:28 +0100 Subject: Avoid duplicate emulated mouse events with XInput2 When using a touch screen on a Linux machine, we receive both touch-events and emulated mouse events from XInput, on top of that we synthesize mouse- events ourselves for the touch events. This patch grabs the touch device for touch events whenever it processes a touch-begin thereby avoiding XInput from synthesizing mouse events. Task-number: QTBUG-35157 Change-Id: I5849d5841be236d6719cd080af2e9e39eb9cdd84 Reviewed-by: Laszlo Agocs --- src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/plugins/platforms/xcb/qxcbconnection_xi2.cpp') diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index 6869baad95..a571f16eb6 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -432,6 +432,22 @@ void QXcbConnection::xi2HandleEvent(xcb_ge_event_t *event) qDebug() << " touchpoint " << touchPoint.id << " state " << touchPoint.state << " pos norm " << touchPoint.normalPosition << " area " << touchPoint.area << " pressure " << touchPoint.pressure; QWindowSystemInterface::handleTouchEvent(platformWindow->window(), xiEvent->time, dev->qtTouchDevice, m_touchPoints.values()); + if (has_touch_without_mouse_emulation) { + // We need to grab the touch event to prevent mouse emulation. + if (xiEvent->evtype == XI_TouchBegin) { + XIEventMask xieventmask; + unsigned int bitMask = 0; + unsigned char *xiBitMask = reinterpret_cast(&bitMask); + xieventmask.deviceid = xiEvent->deviceid; + xieventmask.mask = xiBitMask; + xieventmask.mask_len = sizeof(bitMask); + bitMask |= XI_TouchBeginMask; + bitMask |= XI_TouchUpdateMask; + bitMask |= XI_TouchEndMask; + XIGrabDevice(static_cast(m_xlib_display), xiEvent->deviceid, platformWindow->winId(), xiEvent->time, None, GrabModeAsync, GrabModeAsync, true, &xieventmask); + } else if (xiEvent->evtype == XI_TouchEnd) + XIUngrabDevice(static_cast(m_xlib_display), xiEvent->deviceid, xiEvent->time); + } if (touchPoint.state == Qt::TouchPointReleased) // If a touchpoint was released, we can forget it, because the ID won't be reused. m_touchPoints.remove(touchPoint.id); -- cgit v1.2.3